In a MySQL database, assume I have pairs of lat/lng points that create tens of thousands of polygons on a map. Given a single pair of lat/lng points, how would I find out which polygon(s) it is in?
This seems to show how to tell if a single pair of lat/lng coordinates is within a polygon: MySQL: Spatial Query to find whether a latitude/longitude point is located within a given boundary. That's great if I only need to check the lat/lng pair against one polygon, but I have a lot of polygons.
My feeling is that I cannot do this on the fly (I'm assuming the SQL query would be so large that I would exceed some limit that MySQL has in terms of number of characters). Maybe I need to loop through each polygon and test it against the lat/lng pair -- then store some sort of boolean flag to indicate whether or not the pair is within the polygon. This seems very inefficient to me.
Suggestions?