For a given point (lat and long), find the coordinates of the corners of a square with a given distance

I got a point with latitude 'x' and longitude 'y' using decimals. The point is concentrated in a square, the length of each side is 12 meters. How to find the latitude and longitude of each corner of the area? I program in Java, but I appreciate any pseudo-code .:-)

After reading the articles on this subject, I think that the change in "d-meters" is equal to "e-degrees (in decimal form) ..? If so, what is the" conversion rate "?

I don’t know if this helps, but given that it is 12 meters on each side, each corner should be 16.97 meters from the point.

Thanks in advance: -)

+5
source share
3 answers

Keep the center lat / lon point, as well as the distance to the corner (use some trigger to figure this out), and the radius of the earth in meters. Your bearing in degrees will be 45 to give you the top right, 115 for the top left, etc. Use fancy math below to find the lat / long of your desired angle in decimal format. Convert to degrees by multiplying each by 180 / PI

lat1 = centerPoint.lat * ( Math.PI / 180 );  //Only do this if you need to convert from deg. to dec.
lon1 = centerPoint.lng * ( Math.PI / 180 );  //Only do this if you need to convert from deg. to dec.
d = distance;
R = EARTHS_RADIUS_IN_METERS;
brng = bearingInDegrees * ( Math.PI / 180 );
lat2 = Math.asin( Math.sin( lat1 ) * Math.cos( d / R ) + Math.cos( lat1 ) * Math.sin( d / R ) * Math.cos( brng ) );
lon2 = lon1 + Math.atan2( Math.sin( brng ) * Math.sin( d / R ) * Math.cos( lat1 ), Math.cos( d / R ) - Math.sin( lat1 ) * Math.sin( lat2 ) );

return new LatLong( lat2 * ( 180 / Math.PI ), lon2 * ( 180 / Math.PI ) );
+3
source

I can simplify the problem, but ...

top-left = x - 12, y + 12
top-right = x + 12, y + 12
bottom-left = x - 12, y - 12
bottom-left = x - 12, y - 12

no?

+1
source

, GeographicLib, , :

// Assumes GeographicLib, http://geographiclib.sf.net, is installed
// 
// Compile and link with
//   g++ -o foo foo.cpp -L /usr/local/lib -Wl,-rpath=/usr/local/lib -lGeographic

#include <GeographicLib/Geodesic.hpp>
#include <iostream>
#include <iomanip>

using namespace GeographicLib;
using namespace std;

int main() {
  double lat1, lon1, side;
  cin >> lat1 >> lon1 >> side;
  cout << fixed << setprecision(14);
  double s12 = sqrt(0.5) * side;
  const Geodesic& g = Geodesic::WGS84;
  for (int i = 0; i < 4; ++i) {
    double azi1 = i * 90 - 135;
    double lat2, lon2;
    g.Direct(lat1, lon1, azi1, s12, lat2, lon2);
    cout << lat2 << " " << lon2 << "\n";
  }
  return 0;
}
+1

All Articles