Rework coordReduce Meta
See original GitHub issueI’m trying to use @turf/meta
coordReduce and it doesn’t seem to have the same flow & expected output as Array.reduce().
Issues:
- Missing Index
- Missing Array
- Number of iterations are different (first set of coordinates should be excluded)
Using Array.reduce()
var line = lineString([[126, -11], [129, -21], [135, -31]]);
var coordinates = line.geometry.coordinates;
coordinates.reduce(function (previous, current, index, array) {
console.log(previous, current, index, array);
return current;
});
Output
[ 126, -11 ] [ 129, -21 ] 1 [ [ 126, -11 ], [ 129, -21 ], [ 135, -31 ] ]
[ 129, -21 ] [ 135, -31 ] 2 [ [ 126, -11 ], [ 129, -21 ], [ 135, -31 ] ]
Using Turf Meta coordReduce()
var line = lineString([[126, -11], [129, -21], [135, -31]]);
coordReduce(line, function (previous, current, index, array) {
console.log(previous, current, index, array);
return current;
});
Output
undefined [ 126, -11 ] undefined undefined
[ 126, -11 ] [ 129, -21 ] undefined undefined
[ 129, -21 ] [ 135, -31 ] undefined undefined
CC: @tmcw
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Riot Reworks the entire Game! - (Meta Breaking Patch)
Valorant: Riot Reworks the entire Game - ( Meta Changing Patch)➡️ https://www.twitch.tv/dittozkul➡️ Wanna join our games?
Read more >turf meta module - Npms.io
2 results for coordReduce. @turf/meta(6.5.0). Q. P. M. 73. turf meta module. local_offerfunctional, programming, turfjs, geojson, meta, flattenEach, ...
Read more >red-contrib-turf-module (node) - Node-RED Library
This is a complete rework of the node-red-contrib-turf node. ... For turf modules with callback functions (e.g.: coord-reduce) only msg , flow ,...
Read more >League of Legends' high-damage meta finally being ... - Dexerto
Back in December, 2021, Riot promised that changes were coming to balance out defense and offense in Season 12, and Patch 12.10 is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yep!
index
and at least trying to implement the special case of Array.reduce sounds good.@tmcw OK FINALLY… I’ve got BOTH examples working. We were both right, you can now use
coordReduce
in both scenarios we mentioned above:previous & current coordinates (my example)
output
memo calculation (your example)
output
Final JSDocs