javascript - 带有马丁内斯交集的传单:无效的 LatLng 对象:(-8.39,37.08,-8.39,37.08)
问题描述
我有一张传单地图,我在其中添加了一些由(docs)函数FeatureCollection
生成的多边形。现在我正在尝试将这些多边形与代表一个国家/地区相交,以便 Voronoi 多边形仅在所述国家/地区内显示。对于我正在使用martinez的十字路口。voronoi
turfjs
MultiPolygon
Voronoi 多边形:
var voronoiPolygons = turf.voronoi(poll1); //Creating the Polygons
voronoiPolygons.features.map((f, i) => {
f.properties = poll1.features[i].properties; //Adding the original properties to the new Polygons
});
与国家边界的交汇处:
voronoiPolygons.features.forEach(trimBorder);
function trimBorder(value,index,array){
//Intersection using Martinez, returns set of coordinates
let newPolygon = martinez.intersection(value.geometry.coordinates, borderPT.geometry.coordinates);
//Change the feature type to MultiPolygon if the intersection generates a MultiPolygon
voronoiPolygons.features[index].geometry.coordinates = newPolygon;
if (newPolygon.length > 1) voronoiPolygons.features[index].geometry.type = "MultiPolygon";
}
但是,当我运行它时,我收到以下错误:
Uncaught Error: Invalid LatLng object: (-8.395214820999854,37.08713944100005, -8.395575540353551,37.08710300941793)
at new D (LatLng.js:32)
at We (GeoJSON.js:235)
at He (GeoJSON.js:248)
at He (GeoJSON.js:247)
at De (GeoJSON.js:203)
at i.addData (GeoJSON.js:117)
at i.addData (GeoJSON.js:107)
at initialize (GeoJSON.js:92)
at new i (Class.js:22)
at Object.Ke (GeoJSON.js:439)
据我了解,该对象中不应有两组坐标。这是什么原因造成的?
解决方案
推荐阅读
- android - 附近的 Google Play 服务注册失败,出现 TOO_MANY_PENDING_INTENTS
- sql - 每个项目编号的值总和?
- json - 未定义的 Json 反应
- angular - 如何检查集合是否存在于firestore中?
- tensorflow - 相当于张量流优化器的 Keras
- javascript - 微调器图标不可见
- javascript - JS 未在 localhost 中加载
- node.js - wolfram alpha api node.js
- hibernate - 无法在java中的休眠条件中使用休眠组
- python - 如何将pandas dataframe进行groupby操作后得到的数据结构转换为dataframe?