c# - GPS 计算器转换,计算新点的纬度/经度值

标签 c# gps latitude-longitude

这是我遇到的问题:

我在 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 hladnopivo1990@gmail.com

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;
    }

最佳答案

根据您需要覆盖的距离,线性外推法效果不佳;地球不是平坦的,纬度距离随经度变化。

一个近似值是一个球体,您可以在该球体上计算 Great-circle distance .

(GPS) 坐标通常是相对于地球的(非球体)模型记录的,WGS-84 椭圆体是当今最常见的。因此,为了获得最大的准确性,您必须根据相应的引用模型计算距离。

此外,如果图像的引用模型与 GPS 坐标的引用模型不同,您可能需要两个以上的引用点才能确定准确的映射。

关于c# - GPS 计算器转换,计算新点的纬度/经度值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25686596/

相关文章:

c# - 缓存 IEnumerable

javascript - 在文本框中按下 Enter 键时,重定向到 page.aspx

php - 按接近特定纬度/经度排序表(使用 MySQL+PHP)

open-source - UTM 和 MGRS 到纬度/经度转换源代码?

php - mysql查询优化——索引

c# - 另一个项目限制中引用的项目

c# - 防止 ToolStripMenuItems 跳转到第二个屏幕

Android 应用程序崩溃并显示 QMI_LOC_EVENT_POSITION_REPORT_IND_V02

iphone - 根据设备 iPhone 或 iPod touch 关闭功能

java - 如何从连接到 Android 设备的串行 GPS 获取数据?