I have access to a list of lat/long coordinates, and I want to know (roughly) the US State these coordinates are located in. I can do with loss of precision, but I can't rely on external libraries or API. I can also add a database of locations in my code.
What is a reasonable way to do this? I thought about 3 possibilities:
- Represent each state by a single point at its center, then do a nearest-neighbour search
- Represent each state by points located at cities in the state, then do a nearest-neighbour search (with much more points)
- Represent each state by a simple bounding box, then use some algorithm to query which bounding box my point belongs to
What do you think is best? I would tend to think about solution 3, but I can't find a list of coarse "bounding boxes" for US states