0

im working on a project in which I need to store some google maps polygons in a database. By now, I get the polygon's vertex and save it in an array. Then I format the array into JSON and store it as a string in a database.

The next thing I have to do is to find the polygon that contains a certain location. Google maps javascript API has a function that return if some point is contained into a polygon, but I have to do it on server side (PHP).

¿Any suggestions for how to store the data in DB and how to check which polygon contains a point (latitude, longitude) on server side?

Thank you, and sorry about my English.

dhalfageme
  • 1,444
  • 4
  • 21
  • 42
  • Seems to me, if the location data is a lat/long format, and you are storing the data in JSON format, you theoretically could add a `LIKE` clause to your query to search for the lat or long. Unfortunately this will probably not be performant, as indexing the json string wouldn't make much sense, as the index should not be coupled to JSON / array constructs, as the elements could change in order of entry. – Mike Purcell Mar 28 '13 at 22:51
  • The questioner probably isn't interested in points which are on the boundary of the polygon (e.g. appear in the string), but ones which are inside the boundary. – Kaitlin Duck Sherwood Apr 01 '13 at 00:42

0 Answers0