这里是我有的问题:GPS计算器转换,计算新点的纬度/经度值
我用C#加载图像。在该图像上,我必须通过点击随机拍摄的鼠标来插入2点:点A和点B.
点A有它从程序中读取的线(Xa,Ya),我需要手动插入它的GPS坐标(LatitudeA和LongtudeA)。
B点有它自己的电线(Xb,Yb),它也从程序中读取,我需要手动插入它的GPS坐标(LatitudeB和LongtudeB)。
所以主要的问题是下一步:在屏幕上每下一次点击,我必须知道GPS点。对于那个点C也有(Xc,Yc)。
这是我的ComputeLatitudeAndLogitude方法,但它似乎并不完美。我需要这个街道级别的大小。
实施例:
A(487,361,45.252464,19.850337)
B(1167,397,45.252026,19.853990)
C(810,513,...,?? ?);结果应该是C(810,513,45.251592,19.852075)
请随时与我联系,以便我们能够解决问题,mymailis [email protected]
public void ComputeLatitudeAndLogitud (Wpf_Maps.Point point)
{
int diffX = pointA.X - pointB.X;
int diffY = pointA.Y - pointB.Y;
double diffLatitude = pointA.Latitude - pointB.Latitude;
double diffLongitude = pointA.Longitude - pointB.Longitude;
double latitudePerPixel = Math.Abs(diffLatitude/diffX);
double longitudePerPixel = Math.Abs(diffLongitude/diffY);
int diffXforA = pointA.X - point.X;
int diffYforA = pointA.Y - point.Y;
int diffXforB = pointB.X - point.X;
int diffYforB = pointB.Y - point.Y;
double newLatitudeFromA = pointA.Latitude + (diffXforA * latitudePerPixel);
double newLatitudeFromB = pointB.Latitude + (diffXforB * latitudePerPixel);
double newLongitudeFromA = pointA.Longitude + (diffYforA * longitudePerPixel);
double newLongitudeFromB = pointB.Longitude + (diffYforB * longitudePerPixel);
point.Latitude = (newLatitudeFromA + newLatitudeFromB)/2;
point.Longitude = (newLongitudeFromA + newLongitudeFromB)/2;
}
我点击加载图像随机它是地图点A,并随意在地图上的点B. 需要输入经纬度对于A和B. 程序需要重新计算经度和纬度的每一个点,我随机点击我的图像。 – 2014-09-05 13:31:19
嗯...现在我重新读你的文章,你说A和B是随机的。如果他们具有相同的X或Y会怎么样?各种各样的事情都会出错。没有增量,你不能计算latPerPixel。 – Sandy 2014-09-05 13:31:24
您是如何设置pointA和pointB的纬度和经度属性的?为什么你不能这样设置pointC? – Sandy 2014-09-05 13:33:40