我的应用程序使用JQuery读取GeoJSON文件中的每个线串:
$.getJSON("testROUTES.geojson", function (dat) {
$.each(dat.features, function (key, val) {
var line = val.geometry.coordinates
console.log(line)
console.log(line[0])
});
});
如何重新排列var line
中的坐标,以便坐标使用Jquery读取[45,-122]
而不是[-122,45]
?
答案 0 :(得分:4)
您可以使用map
val.geometry.coordinates = val.geometry.coordinates.map((coords) => {
return [coords[1], coords[0]]
});
答案 1 :(得分:4)
您可以尝试使用JavaScript的Array.prototype.reverse方法。
if (LOD1 == high)
if (LOD1 == LODneighbor)
get all vertices
else
if (neighbor at right)
get all top vertices
get second row except right most
get thrid row
....
else if (neighbor at up)
get alternate top vertices
get whole second row
....
else if ...
if (LOD == medium)
if (neighbor at right)
get 1, 2, 4
else if (neighbor at up)
get 1, 4, 6
else if ...
答案 2 :(得分:0)
有趣的ES6方式是,
[line[0], line[1]] = [line[1], line[0]]