首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >绘图地图应用程序坐标WGS84

绘图地图应用程序坐标WGS84
EN

Stack Overflow用户
提问于 2014-03-30 18:52:08
回答 1查看 277关注 0票数 0

如何处理大的,WGS84点坐标?

我认为,我能做的是将世界(WGS84)点转换为屏幕上像素的点。这是一种好方法吗?它仍然不能正确地工作,因为需要大变焦,并且我必须将单位从米更改为毫米(但如何呢?只需将点的x和y相乘?)。

EN

回答 1

Stack Overflow用户

发布于 2014-03-30 20:17:16

对于这个映射问题,这里有一个非常简单的方法。地理学家可能会对此叫苦连天,但只要坐标低于大约70°纬度,并且窗口大小不太大,它在实践中就能很好地工作。此外,不要试图仅使用大对象的起点和终点来直接映射大对象(例如非常长的线)。

代码语言:javascript
复制
public PointF GeoCoordToPixel(IGeographicPosition geoPos)
{
    double tempLong = geoPos.Longitude;
    if (tempLong > CenterPos.Longitude && (tempLong - CenterPos.Longitude) > 180)
    {
        // the position is to the left, over the antimeridian
        tempLong = tempLong - 360;
    }

    if (tempLong < CenterPos.Longitude && (CenterPos.Longitude - tempLong) > 180)
    {
        // the position is to the right, over the antimeridian
        tempLong = tempLong + 360;
    }

    PointF pt = new PointF(
        (float)((tempLong - LongitudeOfOrigin) / LongitudeIncrement),
        (float)((-geoPos.Latitude + LatitudeOfOrigin) / LatitudeIncrement));

    return pt;
}

其中CenterPos =窗口中心;LatituteOfOrigin / LongitudeOfOrigin =窗口左上位置;LongitudeIncrement / LatitudeIncrement =视图比例。它们的关系是:

代码语言:javascript
复制
LatitudeOfOrigin = CenterPos.Latitude + (m_drawingBuffer.Height / 2.0 * LatitudeIncrement);
LongitudeOfOrigin = CenterPos.Longitude - (m_drawingBuffer.Width / 2.0 * LongitudeIncrement);

反之亦然:

代码语言:javascript
复制
public CGeographicPosition PixelToGeoCoord(PointF pt)
{
     double latitude = -(pt.Y * LatitudeIncrement) + LatitudeOfOrigin;
     double longitude = (pt.X * LongitudeIncrement) + LongitudeOfOrigin;
     if (longitude > 180)
     {
         longitude -= 360;
     }

     return (new CGeographicPosition(latitude, longitude, 0));
}

不是很难,不是吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22743069

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档