更改 Cesium.js 中的地图投影以匹配来自 turf.js 内部查询的结果

Change map projection in Cesium.js to match results from turf.js inside query

我在 Cesium.js 中显示一个点和一个多边形,并使用 turf.js 检查多边形内的点。

在Cesium(或geojson.io)中显示时,该点明显在多边形之外,如下所示:

http://geojson.io/#id=gist:kujosHeist/1030e392bd751daf5d9af57aa412a49c&map=3/46.80/-22.76

但是,当我在 turf.js issiues 页面上查询时:

https://github.com/Turfjs/turf-inside/issues/15

有人告诉我这是因为 geojson(因此 Cesium)是 "misrepresenting the point since it uses World Web Mercator projection (EPSG:3857)" 并且 "viewing the same point/polygon using WGS84 with QGIS" ...显示点在多边形内。

所以我的问题是:如何更改 Cesium 中使用的地图投影(如果可能,也在 geojson.io 中),以便该点正确显示在多边形内?

我不确定 geojson.io 或 Cesium 将如何处理不同的坐标系,但您可以在 GeoJSON 中指定一个 CRS 元素,指示要素点使用的坐标系。这被添加为您的功能集合下的成员。例如:

{
    {
    "type": "FeatureCollection",
    "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
    },
    ...the rest of your structure...
}

但是就像我说的,地图显示软件会关注您指定的 CRS 并将其用于投影坐标。如果它不支持你的坐标系,那么你需要选择其他地图显示软件或将坐标转换为支持的坐标系。