I personally use LINESTRING() for lines, POLYGON() for eh, polygons and
POINT() for points.
An example trigger i use:
CREATE TRIGGER t_markers_geo_insert
BEFORE INSERT ON markers
FOR EACH ROW
SET NEW.geo = GeometryFromText(NEW.locatie);
locatie = string formatted geoemtry "POINT(53.4 4.9)" or "LINESTRING(52.4
8.3, 52.9 8.4)"
For speed you can use a spatial index on the geo field.
ALTER TABLE markers ADD SPATIAL INDEX(geo);
To add the index the field must be NOT NULL.
There is a bug in mysql that even ifyou use a trigger to fill a NOT NULL
field it gives an error anyways when you dont send proper data to the field,
to use the trigger you will need to add a dummy value to the geo field when
you insert. Like GeomFromText('POINT(0 0)'); this way there is no error.
2009/1/2 Alan C <[email protected]>
>
> thanks for those comments, I am storing the route and information
> points as a geometry collection, that in itself is quite challenging.
> Originally I was going to use conventional fields but after studying
> the documentation decided to use the spatial extensions to avoid
> having several linked tables. Examples that show how to use geometry
> are not easy to find so the project has made very slow progress
> especially as I am new to javascript. I should not really say I wasted
> effort getting the rounding working, I learned a lot about objects and
> the google maps api and am still learning even more about mysql.
>
> On Jan 2, 7:31 am, "Björn Brala" <[email protected]> wrote:
> > Thing about MySQL is that the rounding is done when selected i think. So
> a
> > float isn't stored 10, 6 but only SELECTED 10,6.
> >
> > I'd say create a trigger ;)
> >
> > create trigger round_latlng before insert on markers STATEMENT.
> >
> > Triggers are fun ;)
> >
> > 2009/1/2 Barry Hunter <[email protected]>
> >
> >
> >
> >
> >
> > > Depends on how you are storing them in mysql, if you are using a pair
> > > of decimal(10,6) columns, then the rounding will happen anyway.
> >
> > > But you mention 'geometry' which suggests you are looking at the
> > > spatial extensions, which may well use a different system.
> >
> > > But either way roudning to 6dp isnt really going to hurt - unless you
> > > working to cm accuracy! - and doing the rounding will save you a bit
> > > of bandwidth over the wire anyway.
> >
> > > 2009/1/1 Alan C <[email protected]>:
> >
> > > > I am working on a project to store routes and associated information
> > > > points. This is going onto a linux, apache, mysql, php equipped
> > > > server.
> >
> > > > Using the examples I now have my input system working so routes and
> > > > points can be converted into a series of coordinates. I noted that
> > > > advice about storing points in mysql as 10,6 and so have gone to a
> lot
> > > > of trouble to round all my points to 6 places in the clientside
> > > > javascript before passing them to the server. My intention was to
> save
> > > > space and processing time
> >
> > > > but . . . the mysql geometry documentation says coordinates are
> > > > stored as double precision numbers
> >
> > > > so, my question is . . . have I wasted all that effort because mysql
> > > > is going to store my rounded numbers as double precision anyway?
> >
> > > --
> > > Barry
> >
> > > -www.nearby.org.uk-www.geograph.org.uk-
> >
> > --
> > Bjorn Brala
> > ----------------
> > GeoStart.nl- Google maps - Swis Webdesign
> >
>
--
Bjorn Brala
----------------
GeoStart.nl- Google maps - Swis Webdesign
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---