如何处理TileSystem中的错误? [英] What to do about rounding errors in TileSystem?

查看:88
本文介绍了如何处理TileSystem中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在使用
中的TileSystem类时,我已经被问题弄圆了
Bing地图平铺系统文档
。问题可以在下面的单元测试中看出:

 [事实] 
public void REPRO()
{
var latitude = 41;
var longitude = 116;
var firstLevel = 4;
var secondLevel = 5;

TileSystem.LatLongToPixelXY(纬度,经度,firstLevel,out var pixelX1,out var pixelY1);
TileSystem.LatLongToPixelXY(纬度,经度,secondLevel,out var pixelX2,out var pixelY2);

TileSystem.PixelXYToTileXY(pixelX1,pixelY1,out var tileX1,out var tileY1);
TileSystem.PixelXYToTileXY(pixelX2,pixelY2,out var tileX2,out var tileY2);

var firstQuadKey = TileSystem.TileXYToQuadKey(tileX1,tileY1,firstLevel);
var secondQuadKey = TileSystem.TileXYToQuadKey(tileX2,tileY2,secondLevel);

Assert.StartsWith(secondQuadKey,firstQuadKey);
}

正如你所看到的,我正在为相同的纬度/经度解析四核密钥,但是在不同的地图级别。我的期望是更详细的四键是在不太详细的四键中。也就是说,更详细的四键将从不太详细的
四键开始。大多数情况下,这种期望是正确的,但在非常具体的情况下,例如上面的情况,它没有。


我的问题是:人们通常会对此做些什么?我的直觉反应是使用最大细节级别将纬度/经度解析为四边形,然后将结果截断到我实际需要的细节级别。这是最好的方法吗?


谢谢,

肯特

解决方案

<你好Kent,


你把它颠倒了, 放大越多,密钥越长。 密钥越短越小。


1. 这是一篇关于在代码中访问切片的精彩文章  https://docs.microsoft.com/en-us/bingmaps/rest-services/directly-accessing-the-bing-maps-tiles


2。在文章的底部有两个链接,可以帮助您了解截断时发生的情况。


此致,


IoTGirl


Hi,

I've been bitten by rounding problems when using the TileSystem class from the Bing Maps Tile System documentation. The problem can be seen in the below unit test:

[Fact]
public void REPRO()
{
    var latitude = 41;
    var longitude = 116;
    var firstLevel = 4;
    var secondLevel = 5;

    TileSystem.LatLongToPixelXY(latitude, longitude, firstLevel, out var pixelX1, out var pixelY1);
    TileSystem.LatLongToPixelXY(latitude, longitude, secondLevel, out var pixelX2, out var pixelY2);

    TileSystem.PixelXYToTileXY(pixelX1, pixelY1, out var tileX1, out var tileY1);
    TileSystem.PixelXYToTileXY(pixelX2, pixelY2, out var tileX2, out var tileY2);

    var firstQuadKey = TileSystem.TileXYToQuadKey(tileX1, tileY1, firstLevel);
    var secondQuadKey = TileSystem.TileXYToQuadKey(tileX2, tileY2, secondLevel);

    Assert.StartsWith(secondQuadKey, firstQuadKey);
}

As you can see, I'm resolving the quad key for the same lat/lon, but at different map levels. My expectation was that the more detailed quad key would be within the less detailed quad key. That is, the more detailed quad key would start with the less detailed quad key. Mostly, this expectation holds true, but in very specific scenarios such as the one above, it does not.

My question is this: what do people generally do about this? My gut reaction was to resolve lat/lons to quads using the maximum detail level, then truncate the result to the level of detail I actually require. Is this the best approach?

Thanks,
Kent

解决方案

Hi Kent,

You have it reversed,  the more zoomed in, the longer the key.  The less zoomed in the shorter the key.

1.  Here is a great article on accessing the tiles in code https://docs.microsoft.com/en-us/bingmaps/rest-services/directly-accessing-the-bing-maps-tiles

2. At the bottom of the article there are two links that will help you understand what happens when you truncate.

Sincerely,

IoTGirl


这篇关于如何处理TileSystem中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆