I need a function that conceptually is very simple in PHP but seems pretty complex the more I think about it.
I need a PHP function to return the US State that a particular Latitude and Longitude is in. I have access to a database of points that represent the boundaries of the states and there might be 50 points or so per State.
Is there a straightforward way of doing this or could someone get me started with the function? We have a MySQL database that I'll be quering and I can certainly put the data into a Memory table, but this function will be run many times and so needs to be efficient.
If it were a simple square it'd be straightforward to me, but the crazy sizes of the states give me pause.
I'm also open if there is an existing script and/or product out there to achieve this as well.