Question

Okay, here's my problem. The system I'm working with uses objects called Areas to represent a 920x920 metre area on a map. The only reference given for the Area, however, is the latitude and longitude for the top-left corner of the grid square.

What I need to do is work out whether the user's current GPS location falls within a specific area, so I'm writing a function that checks if this is the case, and if so returns data from that area object.

Where I'm struggling is actually working out the best way to do the location checking, when all I have to go on is the user's exact lat/long and a known lat/long for the top left of the grid square...what would be the best way to approach this problem?

Many thanks for any help.

Was it helpful?

Solution

Step #1: Port these calculations (or the equivalent) to Java and use them to determine how many degrees of latitude or longitude 920 meters is given your coordinates

Step #2: Use the values from Step #1 to determine the latitude/longitude coordinates of the lower-right corner of your square

Step #3: See if the user's longitude is between the left and right values, and if the user's latitude is between the top and bottom values

Just be careful as you get to the key inflection points (0 degrees latitude, +/-180 degrees latitude, etc.).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top