⚠️ Change coordIndex to last Coordinates Array reference
See original GitHub issueChange coordIndex
to last Coordinates Array reference
⚠️ Breaking change for next major release v6.0
Ref: https://github.com/Turfjs/turf/issues/1099 & https://github.com/Turfjs/turf/issues/1092#issuecomment-350579714
TurfJS v5.x coordEach
meta.coordEach(multiPolyWithHole, (coord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) => {
//=featureIndex
//=multiFeatureIndex
//=geometryIndex
//=coordIndex
});
TurfJS v6.x coordEach
meta.coordEach(multiPolyWithHole, (coord, indexes => {
//=indexes.featureIndex
//=indexes.multiFeatureIndex
//=indexes.geometryIndex
//=indexes.coordIndex
});
Index Breakdowns
MultiPolygon with Holes
// MultiPolygon with hole
// ======================
// FeatureIndex => 0
const multiPolyWithHole = multiPolygon([
// Polygon 1
// ---------
// MultiFeature Index => 0
[
// Outer Ring
// ----------
// Geometry Index => 0
// Coord Index => [0, 1, 2, 3, 4] (Major Release Change v6.x)
[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]
],
// Polygon 2 with Hole
// -------------------
// MultiFeature Index => 1
[
// Outer Ring
// ----------
// Geometry Index => 0
// Coord Index => [0, 1, 2, 3, 4] (Major Release Change v6.x)
[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
// Inner Ring
// ----------
// Geometry Index => 1
// Coord Index => [0, 1, 2, 3, 4] (Major Release Change v6.x)
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]
]
]);
Polygon with hole
// Polygon with Hole
// =================
// Feature Index => 0
const polyWithHole = polygon([
// Outer Ring
// ----------
// Geometry Index => 0
// Coord Index => [0, 1, 2, 3, 4] (Major Release Change v6.x)
[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
// Inner Ring
// ----------
// Geometry Index => 1
// Coord Index => [0, 1, 2, 3, 4] (Major Release Change v6.x)
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]
]);
FeatureCollection of LineStrings
// FeatureCollection of LineStrings
const line = lineStrings([
// LineString 1
// Feature Index => 0
// Geometry Index => 0
// Coord Index => [0, 1, 2, 3, 4] (Major Release Change v6.x)
[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
// LineString 2
// Feature Index => 1
// Geometry Index => 0
// Coord Index => [0, 1, 2, 3, 4] (Major Release Change v6.x)
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]
]);
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
️ Convert @turf/meta indexes callback params to Objects
DenisCarriere mentioned this issue on Dec 10, 2017. ⚠️ Change coordIndex to last Coordinates Array reference #1168.
Read more >Reference to the previous element in the array - in Javascript
I want to calculate the angular distance of 2 coordinates so that I can move a steering wheel. My data comes from a...
Read more >Reshaping and reorganizing data - Xarray
These methods allow you to reorganize your data by changing dimensions, array shape, order of values, or indexes. Reordering dimensions: To reorder ...
Read more >Digital Geometry Processing / Core Mesh Data Structures
A simple data structure to represent a polygon mesh is composed of two arrays; one array of floating point variables, which we name...
Read more >Arrays and References | Think Java | Trinket
This statement creates an array variable, a , and makes it refer to an array with four elements. ... So you can replace...
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
ah I see now, that’s clearer thanks!
Like #1099, I don’t think this is a good idea: it would degrade turf-meta performance just in order to make it ‘easier’ for core contributors. turf-meta is low-level code: it needs to be fast, not friendly.