吕
吕雪松
Unregistered / Unconfirmed
GUEST, unregistred user!
//Lat:纬度,注:是度.度格式,不是度.分格式
//Lon:经度,同上。
procedure ConvertCoordinate(Lat,Lon:do
uble;var xx,yy :do
uble);
const R2D=57.2957795131;
TOLAT=(31.0+(14.0+7.55996/60.0)/60.0)/R2D;
TOLON=(121.0+(28.0+1.80651/60.0)/60)/R2D;
REARTH=6371006.84;
var
Horizerr,Frlat,Frlon,gcdist,gcbrg :do
uble;
clatf,clatt,slatf,slatt,dlon,cdlon,sdlon,sdist,cdist,sbrg,cbrg,temp :do
uble;
begin
// Frlat:=lat/R2D;
// Frlon:=lon/R2D;
// FrLat := (StrToFloat(Copy(Lat,1,2))+StrToFloat(Copy(Lat,3,7))/60)/R2D;
// FrLon := (StrToFloat(Copy(Lon,1,3))+StrToFloat(Copy(Lon,4,7))/60)/R2D;
FrLat := (Trunc(Lat)+(Lat - Trunc(Lat))/0.6)/R2D;
FrLon := (Trunc(Lon)+(Lon - Trunc(Lon))/0.6)/R2D;
clatt:=cos(Frlat);
clatf:=cos(TOLAT);
slatt:=sin(Frlat);
slatf:=sin(TOLAT);
dlon:=-TOLON+Frlon;
cdlon:=cos(dlon);
sdlon:=sin(dlon);
cdist:=slatf*slatt+clatf*clatt*cdlon;
temp:=sqr((clatt*sdlon))+sqr((clatf*slatt-slatf*clatt*cdlon));
sdist:=sqrt(abs(temp));
if((abs(sdist)>0.0000001) or (abs(cdist)>0.0000001)) then
gcdist :=arctan2(sdist,cdist)
else
gcdist :=0.0;
sbrg :=sdlon*clatt;
cbrg :=(clatf*slatt-slatf*clatt*cdlon);
if((abs(sbrg)>0.0000001) or (abs(cbrg)>0.0000001)) then
begin
temp := arctan2(sbrg,cbrg);
while (temp < 0.0)do
temp := temp+2.0*PI;
gcbrg :=temp;
end
else
gcbrg :=0.0;
Horizerr :=gcdist*REARTH;
xx := Horizerr*sin(gcbrg);
yy := Horizerr*cos(gcbrg);
end;
//Lon:经度,同上。
procedure ConvertCoordinate(Lat,Lon:do
uble;var xx,yy :do
uble);
const R2D=57.2957795131;
TOLAT=(31.0+(14.0+7.55996/60.0)/60.0)/R2D;
TOLON=(121.0+(28.0+1.80651/60.0)/60)/R2D;
REARTH=6371006.84;
var
Horizerr,Frlat,Frlon,gcdist,gcbrg :do
uble;
clatf,clatt,slatf,slatt,dlon,cdlon,sdlon,sdist,cdist,sbrg,cbrg,temp :do
uble;
begin
// Frlat:=lat/R2D;
// Frlon:=lon/R2D;
// FrLat := (StrToFloat(Copy(Lat,1,2))+StrToFloat(Copy(Lat,3,7))/60)/R2D;
// FrLon := (StrToFloat(Copy(Lon,1,3))+StrToFloat(Copy(Lon,4,7))/60)/R2D;
FrLat := (Trunc(Lat)+(Lat - Trunc(Lat))/0.6)/R2D;
FrLon := (Trunc(Lon)+(Lon - Trunc(Lon))/0.6)/R2D;
clatt:=cos(Frlat);
clatf:=cos(TOLAT);
slatt:=sin(Frlat);
slatf:=sin(TOLAT);
dlon:=-TOLON+Frlon;
cdlon:=cos(dlon);
sdlon:=sin(dlon);
cdist:=slatf*slatt+clatf*clatt*cdlon;
temp:=sqr((clatt*sdlon))+sqr((clatf*slatt-slatf*clatt*cdlon));
sdist:=sqrt(abs(temp));
if((abs(sdist)>0.0000001) or (abs(cdist)>0.0000001)) then
gcdist :=arctan2(sdist,cdist)
else
gcdist :=0.0;
sbrg :=sdlon*clatt;
cbrg :=(clatf*slatt-slatf*clatt*cdlon);
if((abs(sbrg)>0.0000001) or (abs(cbrg)>0.0000001)) then
begin
temp := arctan2(sbrg,cbrg);
while (temp < 0.0)do
temp := temp+2.0*PI;
gcbrg :=temp;
end
else
gcbrg :=0.0;
Horizerr :=gcdist*REARTH;
xx := Horizerr*sin(gcbrg);
yy := Horizerr*cos(gcbrg);
end;