Thursday, 14 December 2017

Looping on GeoJSON to get maximum/minimum altitude


I need to create to create 2 function to return max and min Z/elevation/altitude values from LineString GeoJSON file.


i have created 2 function to get that before, but i was using MultiLineString GeoJSON file, but now i am using LineString.


this one of the 2 function:



    function minHPoint(arr, multi) {
var min = Infinity, len, tmpArr, minPoint;
if (multi) {
multiLen = arr.length;
}
else {
tmpArr = arr;
multiLen = 0;
};
while (multiLen--) {

if (multiLen >= 0) tmpArr = arr[multiLen];
len = tmpArr.length;
while (len--) {
if (tmpArr[len][2] < min) {
min = tmpArr[len][2];
minPoint = tmpArr[len];
}
}
}
return minPoint;

};

var coords = layer.feature.geometry.coordinates;
var minPoint = minHPoint(coords, (layer.feature.geometry.type == 'MultiLineString'));
minH = minPoint[2];
$('#Low-Point').html("Low point: "+Math.round(minH)+" Meters");


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...