php - MySQL - Find points using spatial polygons (boundaries) -


i want select photo based on location (lat/lon) when else searches country or city. eg: photo's location 12.127, 42.127 -> request "san francisco" -> select points inside area (a example instagram photo linked both city + country)

right looking use polygons find locations based on city/country. not sure how use , store polygons in database.

here visual steps (not sure if that's right technically)

  1. get polygons/areas based on city/country table1
  2. find points table2 inside polygon table1

if these steps correct, couldn't find resources polygons cities or countries

please include examples + table structures , explanations on how implement this

thanks :)

mysql quite time has been supporting geospatial data types , functions.

you can store city or other place polygon , can use 1 of within() or contains() functions (there 3 of each) test if point within city.

mysql documentation contains great deal of examples on data types , functions. can find both free , not free sources on internet contain coordinates of various metro areas. recommending offsite resource off topic on so, not making recommendations.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -