Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript
https://turfjs.org/
MIT License
9.33k stars 943 forks source link

⚠️ Convert @turf/meta indexes callback params to Objects #1099

Closed DenisCarriere closed 1 week ago

DenisCarriere commented 6 years ago

Convert @turf/meta indexes callback params to Objects

The NEXT major release we should re-organize the index callbacks using an Object.

⚠️ This should only be done next MAJOR release v6.0 (not scheduled anytime soon)

Background: These indexes have been added to retrace the exact feature/geometry position of the provided GeoJSON.

Before

coordEach(geojson, (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) => {
  //=currentCoord
  //=coordIndex
  //=featureIndex
  //=multiFeatureIndex
  //=geometryIndex
});

Proposed

Something like this =>

coordEach(geojson, (currentCoord, indexes) => {
  //=currentCoord
  //=indexes.coordIndex
  //=indexes.featureIndex
  //=indexes.multiFeatureIndex
  //=indexes.geometryIndex
});

Which allows to do some cool deconstructing like this =>

coordEach(geojson, (currentCoord, {geometryIndex}) => {
  //=currentCoord
  //=geometryIndex
})

This would allow us to retrieve any index without "guessing" the parameter position.

DenisCarriere commented 6 years ago

@rowanwins Looks like someone had the same idea 👍 https://github.com/Turfjs/turf/issues/1168#issuecomment-350585174

tmcw commented 6 years ago

👎 I'm a hesitant -1 here.

smallsaucepan commented 1 week ago

Will close this and #1168 as "not planned". Hasn't been any chatter for some time and suspect this change is no longer on the radar.