How to use the @turf/meta.segmentReduce function in @turf/meta

To help you get started, we’ve selected a few @turf/meta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Turfjs / turf / packages / turf-length / index.ts View on Github external
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);
}
github Turfjs / turf / packages / turf-directional-mean / index.ts View on Github external
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",
        });
    }
}
github Turfjs / turf / packages / turf-directional-mean / index.js View on Github external
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',
        });
    }
}
/**