??????? 研究了一下Google Map上的根據(jù)經(jīng)緯度求地球表面兩點(diǎn)間距離的實(shí)現(xiàn),?用java實(shí)現(xiàn)了一把,對(duì)我國(guó)境內(nèi)的Beijing54,?Xian80,WGS84三種坐標(biāo)系的空間距離計(jì)算感覺(jué)這個(gè)實(shí)現(xiàn)是比較準(zhǔn)確的。當(dāng)然,這里只是個(gè)人的感覺(jué)而已。。。可能我還沒(méi)有遇到那種對(duì)精度要求非常嚴(yán)格的地方,或許,本身我這個(gè)方式就是錯(cuò)誤的。。。呵呵。。。這里只是作個(gè)記號(hào)先。。。各位達(dá)人多多指教
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;
?}
}