You can just store it just like the C app code by creating a "points"
text column and serializing the array of points as a YAML file.
-
MaurĂcio Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
On Sun, May 10, 2009 at 12:14 AM, Dan Bogdan
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> I am new to rails and I have a question on tables.
>
> I have 2 tables.
>
> 1. Points with :id, :name, :x, :y
>
> 2. Polygons with :id, :name and an array of points (references to points
> from the Points table). What matters is the order of points in the
> polygon, which follows the order points are linked in the polygon. There
> is a many to many relationship between Points and Polygons through a
> Points_Polygons table (:point_id :polygon_id)
>
> My question is what''s the best way to implement this ordering in
Rails?
>
> I thought of adding a :point_order field to the Points_Polygons table,
> but this seems very inefficient in case of frequent insertion/deletion
> of points in/from polygons, as each time I insert a point inside a
> polygon I need to update the point_order field for the points folowing
> the insertion point.
>
> P.S. In the C implementation I have a linked list of Points, and a
> Linked list of Polygons, where each Polygon stores its own list of
> points in a form of a linked list of pointers to points from the Points
> list.
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>