Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include feature(Sub)Index in coordEach/Reduce (@turf/meta) #872

Merged
merged 2 commits into from
Jul 31, 2017

Conversation

DenisCarriere
Copy link
Member

@DenisCarriere DenisCarriere commented Jul 27, 2017

Include feature(Sub)Index in coordEach/Reduce

Implements Issue: #867

featureSubIndex can be a bit abstract when dealing with complex Geometries such as MutliPolygon, but for a simple LineString it is pretty useful knowing the exact coordinate position.

const features = turf.featureCollection([
    turf.lineString([[0, 0], [1, 1]]), // index 0
    turf.multiPoint([[4, 4], [0, 0]]), // index 1
    turf.point([3, 3]),                // index 2
    turf.lineString([[2, 2], [1, 1]])  // index 3
]);

turf.coordEach(features, (coord, coordIndex, featureIndex, featureSubIndex) => {
    // coordIndex      => 0, 1, 2, 3, 4, 5, 6
    // featureIndex    => 0, 0, 1, 1, 2, 3, 3
    // featureSubIndex => 0, 1, 0, 1, 0, 0, 1
})

@DenisCarriere DenisCarriere added this to the 4.6.0 milestone Jul 27, 2017
@DenisCarriere DenisCarriere self-assigned this Jul 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant