我对turfJS的with ()方法有一个问题。看来turfJS对我的坐标有问题。
var alongLine = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[-37.86902659740041, 144.6185302734375],
[-37.86902659740041, 145.57159423828125]
]
}
};
var newPoint = Turf.along(alongLine, 1, 'miles');
console.log('Walked 1 miles', newPoint);在代码运行之后,这是我得到的控制台日志:
Walked 1 miles { type: 'Feature',
geometry: {
type: 'Point',
coordinates: [ -37.86902659740041, 35.367001095372345 ] },
properties: {}
}你可以看到坐标是-37。和35。但是,当沿着这条线走1英里(也就是-37和145)时,我不明白为什么会有这么远的点(就像地球的一半那么远!)
在使用TurfJS文档中的测试坐标时,它似乎工作得很好,但我的坐标却是坏的。这怎么可能呢?
在下面的例子中,您可以找到文档:along.html
当使用它们的示例坐标时
[-77.031669, 38.878605],
[-77.029609, 38.881946],
...其结果是(即使只使用2分而使用的距离小于1英里:它总是返回的正确点):
Walked 1 miles { type: 'Feature',
geometry: {
type: 'Point',
coordinates: [ -77.02417351582903, 38.885335546214506 ] },
properties: {}
}发布于 2015-10-15 14:46:23
你的坐标对排列错了。GeoJSON期望坐标对的[longitude, latitude]排序。
以下是GeoJSON规范:http://geojson.org/geojson-spec.html
以下是坐标对排序的方便参考:http://www.macwright.org/lonlat/
下面是一个可以用来快速可视化您的GeoJSON的站点:http://geojson.io/
https://stackoverflow.com/questions/33151191
复制相似问题