Hello,
I have a requirement to calculate the centroid or geodesic midpoint of when a user clicks in between the lat/long grid crossing. The crossing forms a square in most parts of GE and sometimes elongated rectangles. This is due to the shape of the earth of course. I'm looking for a valid mathematical formula that would allow a user to click anywhere in between this grid and then an accurate function (in Javascript or server side code) that would take an assumed grid resolution (say 1km intervals for this discussion) and the input coordinates that should return a centroid coordinate within that graticule grid.
To clarify please take a look at the attached image to my google group post:
What I need to be able to do is if a user clicks anywhere in this grid square, I need to find the centroid or center point of that grid intersection/square or at least the bounding grid coordinates (that make the square).
If we assume that the grid is UTM standard and has a max resolution of 1km (or make this a parameter), I need to detect the four other points nearby and then calculating the centroid is not as difficult. I welcome any feedback you all may have and appreciate it.
I don't have a simple way of letting a user click anywhere on the grid and finding the grid bounding coordinates (making a square of 4 coordinates) or the centroid / midpoint of the graticule grid square necessary.
One thought is to use assumptions as much as possible using a reference such as UTM coordinate reference.
If I assume that the grid is X degrees wide, can we have a pure javascript function take any input coordinate and return for me the bounding graticule coordinates in Decimal Degrees?
Another thought I had was to create the grid in a geo-spatial layer to take any input coordinate and return the nearest centroid of the graticule?
Does this make sense?
Thanks!
Omar