Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function length(geojson: Feature | FeatureCollection | GeometryCollection, options: {
units?: Units
} = {}): number {
// Calculate distance from 2-vertex line segements
return segmentReduce(geojson, function (previousValue, segment) {
var coords = segment.geometry.coordinates;
return previousValue + distance(coords[0], coords[1], options);
}, 0);
}
function getLengthOfLineString(line: Feature, isPlanar: boolean) {
if (isPlanar) {
return segmentReduce(line, (previousValue?: number, segment?: Feature): number => {
const coords = segment.geometry.coordinates; // the signatrue of segmentReduce has problem ?
return previousValue + euclideanDistance(coords);
}, 0);
} else {
return length(line, {
units: "meters",
});
}
}
function getLengthOfLineString(line, isPlanar) {
if (isPlanar) {
return meta_1.segmentReduce(line, function (previousValue, segment) {
var coords = segment.geometry.coordinates; // the signatrue of segmentReduce has problem ?
return previousValue + euclideanDistance(coords);
}, 0);
}
else {
return length_1.default(line, {
units: 'meters',
});
}
}
/**