??????? 研究了一下Google Map上的根據經緯度求地球表面兩點間距離的實現,?用java實現了一把,對我國境內的Beijing54,?Xian80,WGS84三種坐標系的空間距離計算感覺這個實現是比較準確的。當然,這里只是個人的感覺而已。。。可能我還沒有遇到那種對精度要求非常嚴格的地方,或許,本身我這個方式就是錯誤的。。。呵呵。。。這里只是作個記號先。。。各位達人多多指教
package com.geotools.test;
/**
?*
?* CopyRight (C)??? All rights reserved.<p>
?*
?* WuHan Inpoint Information Technology Development,Inc.<p>
?*
?* Author sinoly<p> Project Name: PostGeo
?*
?* @version 1.0??? 2006-11-13
?*
?* <p>Base on : JDK1.5<p>
?*
?*/
public class GeoUtils {
??? public enum GaussSphere{
??????? Beijing54,
??????? Xian80,
??????? WGS84,
??? }
??? private static double Rad(double d){
??????? return d * Math.PI / 180.0;
??? }
?public double DistanceOfTwoPoints(double lng1,double lat1,double lng2,double lat2,
???GaussSphere gs){
??????? double radLat1 = Rad(lat1);
??????? double radLat2 = Rad(lat2);
??????? double a = radLat1 - radLat2;
??????? double b = Rad(lng1) - Rad(lng2);
??????? double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
???????? Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b/2),2)));
??????? s = s * (gs == GaussSphere.WGS84 ? 6378137.0 : (gs == GaussSphere.Xian80 ? 6378140.0 : 6378245.0));
??????? s = Math.round(s * 10000) / 10000;
??????? return s;
?}
}