Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- JavaScript
- 생성자
- 오버로딩
- JSP
- 기본
- 예외처리
- AWT
- 배열
- 클래스
- HTML
- struts2
- 어노테이션
- Menu
- Android
- 전화걸기
- 이클립스
- Eclips
- 메소드
- 안드로이드
- 국제화
- Graphic
- oracle
- 메서드
- layout
- OGNL
- 에러페이지
- mybatis
- Java
- paint
- Spring
Archives
- Today
- Total
note
위도 경도 거리 계산 본문
검증되었습니다( 나로부터)
(C#소스는 있던데 java는 없어서 바꿔치기 하였슴)
표시 단위는 km입니다
public static double distance(double Lat1,double Long1, double Lat2, double Long2) {
double dDistance = Double.MIN_VALUE;
double dLat1InRad = Lat1 * (Math.PI / 180.0);
double dLong1InRad = Long1 * (Math.PI / 180.0);
double dLat2InRad = Lat2 * (Math.PI / 180.0);
double dLong2InRad = Long2 * (Math.PI / 180.0);
double dLongitude = dLong2InRad - dLong1InRad;
double dLatitude = dLat2InRad - dLat1InRad;
// Intermediate result a.
double a = Math.pow(Math.sin(dLatitude / 2.0), 2.0) +
Math.cos(dLat1InRad) * Math.cos(dLat2InRad) *
Math.pow(Math.sin(dLongitude / 2.0), 2.0);
// Intermediate result c (great circle distance in Radians).
double c = 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));
// Distance.
// const Double kEarthRadiusMiles = 3956.0;
Double kEarthRadiusKms = 6376.5;
dDistance = kEarthRadiusKms * c;
return dDistance;
}
'JSP > 기본' 카테고리의 다른 글
| xml Url 파싱 (0) | 2012.06.04 |
|---|---|
| JAVA 임시 비밀번호 생성 (0) | 2012.05.07 |
| 이미지 픽셀단위로 비율에 맞게 리사이징 하기 / 썸네일 (0) | 2012.03.16 |
| 날짜 며칠전 / 몇분전 / 몇년전 으로 치환 (0) | 2012.03.13 |
| JSP - Oracle Clob 사용법 (0) | 2012.02.20 |