![]() |
#2
johnjiang2011-12-20 12:30
|

create procedure tests
as
select a.road_id,a.termid,a.User_ID,b.longitude,b.latitude from SYSTEM_DATA_ROAD a,SYSTEM_DATA_ROAD_INFO b where a.begin_date <'2011-12-13' and a.begin_date>'2011-12-12' and a.road_id =b.road_id and b.timeat>'2011-12-12' and b.timeat<'2011-12-13'
select m.region_id,m.corp_id,m.corp_cnname,m.corp_address,n.longitude,n.latitude from system_data_corp m,system_data_corp_reg n where m.corp_id=n.corp_id and (n.longitude<>'0' or n.latitude<>'0')
go
我想把得到的 b.longitude,b.latitude 跟 n.longitude,n.latitude 带到一个计算公式里进行计算。 不知道怎么写。请人指点。
下面就是个计算公式。

double y1 =b.longitude
double y2 = b.latitude
double x1 = n.longitude
double x2 = n.latitude
double Ea = 6378137
double Eb = 6356725
Long = y1
Lat = x1
Long2 = y2
Lat2 = x2
LongRad = Long * 3.1415926 / 180;
LatRad = Lat * 3.1415926 / 180;
Ec = Eb + (Ea - Eb) * (90 - Lat) / 90;
Ed = Ec * Math.Cos(LatRad);
LongRad2 = Long2 * 3.1415926 / 180;
LatRad2 = Lat2 * 3.1415926 / 180;
Ec2 = Eb + (Ea - Eb) * (90 - Lat) / 90;
Ed2 = Ec * Math.Cos(LatRad2);
double dx = (LongRad2 - LongRad) * Ed;
double dy = (LatRad2 - LatRad) * Ec;
double d = Sqrt(dx * dx + dy * dy);
[ 本帖最后由 kgdipbyve 于 2011-12-14 10:19 编辑 ]