How to use the @turf/meta.coordReduce 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-polygonize / lib / Graph.js View on Github external
flattenEach(geoJson, feature => {
            featureOf(feature, 'LineString', 'Graph::fromGeoJson');
            // When a LineString if formed by many segments, split them
            coordReduce(feature, (prev, cur) => {
                if (prev) {
                    const start = graph.getNode(prev),
                        end = graph.getNode(cur);

                    graph.addEdge(start, end);
                }
                return cur;
            });
        });
github Turfjs / turf / packages / turf-polygonize / lib / polygonize.js View on Github external
flattenEach(geoJson, function (feature) {
        featureOf(feature, 'LineString', 'Graph::fromGeoJson');
        // When a LineString if formed by many segments, split them
        coordReduce(feature, function (prev, cur) {
            if (prev) {
                var start = graph.getNode(prev),
                    end = graph.getNode(cur);

                graph.addEdge(start, end);
            }
            return cur;
        });
    });