gpt4 book ai didi

javascript - 如何使用 L.CRS.Simple 在传单中显示由 geojson-vt 生成的(反子午线)矢量切片?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:38:51 24 4
gpt4 key购买 nike

我有一个 GeoJSON 简单数据,我需要使用 L.CRS.Simple crs 在传单 map 上显示,因为它是反子午线数据,有时坐标可以是 [450,389](超过 180)

这是非常简单的 GeoJSON:

{
"type": "FeatureCollection",
"name": "entities",
"features": [
{
"type": "Feature",
"properties": {
"Layer": "0",
"SubClasses": "AcDbEntity:AcDbPolyline",
"EntityHandle": "1F9",
"style": "PEN(c:#FF0000)"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
0,
0
],
[
0,
150
],
[
150,
150
],
[
150,
0
],
[
0,
0
]
]
}
}
]
}

使用 geojson-vt ,(演示页面)我得到这个矩形: enter image description here

我对 geojson-vt 库做了一些修改:

投影函数:

function projectX(x, simple, projectionFactor) {
return x / 256 + 1;
}

function projectY(y, simple, projectionFactor) {
return - y / 256 + 0.5;
}

我在 GeoJSONVT.prototype.getTile 函数中添加了这一行:

y = y + (1 << (z - 1)); // xy map

结果是(标记位于 [0,0]、[150,0]、[150,150]、[0,150]):

enter image description here

有什么建议吗?为什么我在这里丢失了瓷砖?

最佳答案

我建议您阅读以下内容:https://macwright.org/2016/09/26/the-180th-meridian.html

引用 GeoJSON 规范推荐的解决方案:

In representing Features that cross the antimeridian, interoperability is improved by modifying their geometry. Any geometry that crosses the antimeridian SHOULD be represented by cutting it in two such that neither part’s representation crosses the antimeridian. - GeoJSON Spec, 3.1.9

关于javascript - 如何使用 L.CRS.Simple 在传单中显示由 geojson-vt 生成的(反子午线)矢量切片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53837326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com