Latitude / Longitude Distance Calculation

A quick question about a Lat / Long calculation.

I want to take a value set eg Lat: 55.123456 Long -6.123456 and work out the four points that are an arbitrary distance away.

在这里输入图像描述

As the given square, I want to work out the value for Latitude on the left and right side. Thus the red lines are 1.5km from the start point. Likewise for the longitude, the blue lines will be 1.5km from the start point. The output will be 4 points, all distances in kilometres.

In short: Latitude + Y = Latitude Value X kilometers away

Working with iPhone at the moment and its for a very rough database calculation.

EDIT: Just to clarify, the distance is so short that curvature (And hence accuracy) is not an issue.


在OBJ-C中,这应该是一个体面的解决方案:

float r_earth = 6378 * 1000; //Work in meters for everything
float dy = 3000; //A point 3km away
float dx = 3000; //A point 3km away
float new_latitude  = latitude  + (dy / r_earth) * (180 / M_PI);
float new_longitude = longitude + (dx / r_earth) * (180 / M_PI) / cos(latitude * 180/M_PI);

Well, for rough calculation with relatively small distances (less than 100km) you may assume that there is 40_000_000/360=111 111 meters per degree of latitude and 111 111*cos(latitude) meters per degree of longitude. This is because a meter was defined as 1/40_000_000 part of the Paris meridian;).

Otherwise you should use great circle distances, as noted in the comments. For high precision you also need to take into account that Earth is slightly oblate spheroid rather than a sphere.


// parameter: offset in meters
float offsetM = 1500; // 1.5km

// degrees / earth circumfence
float degreesPerMeter = 360.0 / 40 000 000;
float toRad = 180 / M_PI;

float latOffsetMeters = offsetM * degreesPerMeter;
float lonOffsetMeters = offsetM * degreesPerMeter * cos (centerLatitude * toRad);

Now simply add +/- latOffsetMeters and +/- lonOffsetMeters to your centerLatitude/ centerLongitude.

Formula is usefull up to hundred kilometers.

链接地址: http://www.djcxy.com/p/70978.html

上一篇: 什么是最快的方式来获得π的价值?

下一篇: 纬度/经度距离计算