You need some sort of solution that can query the database. If by
'encoded' you mean something like the Maps encodeding system, you are
probably going to have to decode the data to run spatial queries on
it.
Perhaps you need to run a batch process, to decode the lines, and
store a bounding rectangle in the database. It trival then to find
points in those rectangles.
But this all depends on your database, and its capablities.
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/un-nuHSYT8UJ.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
... the whole basis is you need to build some sort of 'spatial index'.
Could use the mysql functions, or your own homegrown system - like
noted in last reply.
Most spatial indexes involve duplicating the data into some easily
queryable format.
Because these probably just work on bounding rectangles -rather than
the detailed polygone, maybe you will still need to do a proper
point-in-polygone check, to be sure.
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/_rRXJwFwbJsJ.
I have that many, and I don't have spatial extensions in MySQL.
I have a table containing all the boundary points of each polygon, and
another table containing the bounds of each polygon (a rectangle). I
use this denormalised data to determine a subset of possible polygons
for the point, and then test each polygon in that subset to find the
one(s) containing the point. I don't use encoded polygons server-side,
although I do encode the polygon in the server and send that
compressed data to the client to display the polygon.
It is fast: try it at http://www.acny.org.uk/parishfinder.php .
Although the map is a Version 2 map, all the expensive processing is
server-side so that doesn't matter. Just click anywhere in England;
using Firebug or something similar will allow you to see how each
server interaction works -- it's getparish_new.php which finds the
right polygon and encodes the boundary and that's generally around
350ms, occasionally up to 750ms, which isn't bad to find and draw a
polygon.
I don't know how this would compare to upgrading to a
spatially-equipped version of MySQL. I suspect that I gain with the
denormalised bounding rectangles and lose slightly on the
point-in-polygon analysis; but to encode the boundary it's necessary
to have actual coordinates, and I don't have to decode those from
spatial data before using them. It's probably fairly similar.