Latitude / Longitude 에 따라 방위, 거리 등 을 계산 합 니 다.
3134 단어 long
http://www.movable-type.co.uk/scripts/latlong.html
거 리 를 계산 하 다
방법 1.
double dist = 0.0;
double deltaLat = Math.toRadians(latVal2 - latVal1);
double deltaLon = Math.toRadians(lonVal2 - lonVal1);
latVal1 = Math.toRadians(latVal1);
latVal2 = Math.toRadians(latVal2);
lonVal1 = Math.toRadians(lonVal1);
lonVal2 = Math.toRadians(lonVal2);
double earthRadius = 6371;
double a = Math.sin(deltaLat/2) * Math.sin(deltaLat/2) +
Math.cos(latVal1) * Math.cos(latVal2) * Math.sin(deltaLon/2) * Math.sin
(deltaLon/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
dist = earthRadius * c;
방법 2.
public static double calculateHaversineMI(double lat1, double long1, double lat2,double long2) {
double dlong = (long2 - long1) * (Math.PI / 180.0f);
double dlat = (lat2 - lat1) * (Math.PI / 180.0f);
double a = Math.pow(Math.sin(dlat / 2.0), 2)
+ Math.cos(lat1 * (Math.PI / 180.0f))
* Math.cos(lat2 * (Math.PI / 180.0f))
* Math.pow(Math.sin(dlong / 2.0), 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
double d = 6367* c;
return d;
}
그리고 방위 계산.
double dLong = picLongitude - mLongitude;
double y = (Math.sin(dLong) * Math.cos(picLatitude));
double x = (Math.cos(mLatitude) * Math.sin(picLatitude) -
Math.sin(mLatitude)*Math.cos(picLatitude)*Math.cos(dLong));
double angleDegreesWrongRange = Math.abs(Math.toDegrees(Math.atan2(y,
x)));
float angleDegrees = (float) ((angleDegreesWrongRange+360) % 360);
public static String getDirection(float baseAzimuth){
String bearingText = "";
if ( (360 >= baseAzimuth && baseAzimuth >= 337.5) || (0 <= baseAzimuth && baseAzimuth <= 22.5) ) bearingText = "N";
else if (baseAzimuth > 22.5 && baseAzimuth < 67.5) bearingText = "NE";
else if (baseAzimuth >= 67.5 && baseAzimuth <= 112.5) bearingText = "E";
else if (baseAzimuth > 112.5 && baseAzimuth < 157.5) bearingText = "SE";
else if (baseAzimuth >= 157.5 && baseAzimuth <= 202.5) bearingText = "S";
else if (baseAzimuth > 202.5 && baseAzimuth < 247.5) bearingText = "SW";
else if (baseAzimuth >= 247.5 && baseAzimuth <= 292.5) bearingText = "W";
else if (baseAzimuth > 292.5 && baseAzimuth < 337.5) bearingText = "NW";
return bearingText;
}
안에서 답 을 찾 을 수 있어 요.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
uva 10285 Longest Run on a Snowboard기초 DP 복습, 기억화 검색 제목: 이름과 n*m 행렬을 주십시오. 다음은 행렬 정보입니다. 매번 한 칸에서 상하좌우로 이동할 수 있지만 그 숫자는 현재 있는 칸보다 작아야 합니다.임의의 점에서 출발해서 가장 긴 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.