/**
* Removes redundant coordinates from any GeoJSON Geometry.
*
* @name cleanCoords
* @param {Geometry|Feature} geojson Feature or Geometry
* @param {boolean} [mutate=false] allows GeoJSON input to be mutated
* @returns {Geometry|Feature} the cleaned input Feature/Geometry
* @example
* var line = turf.lineString([[0, 0], [0, 2], [0, 5], [0, 8], [0, 8], [0, 10]]);
* var multiPoint = turf.multiPoint([[0, 0], [0, 0], [2, 2]]);
*
* turf.cleanCoords(line).geometry.coordinates;
* //= [[0, 0], [0, 10]]
*
* turf.cleanCoords(multiPoint).geometry.coordinates;
* //= [[0, 0], [2, 2]]
*/
module.exports = function (geojson, mutate) {
Don't know if these coordinates are actually redundant (as in useless), but in some cases are definitely in the way, e.g. #869 or the new segmentEach/segmentReduce.
We can have this as a module, handling the feature, or as a helpers function, simply returning the cleaned coordinates array.
Looking forward for any suggestion.
Love it! Exactly what we need!
Great! @DenisCarriere I'll work on the code in the weekend as well, for now was just a proposal to make sure it was acceptable
I was going to propose the exact same thing at one point, sounds like a good module to help improve those boolean modules.
My only comment @stebogit would be in relation to the name, im not sure that clean-coords is the best. My reading is that the module removes redundant vertices, I'd perhaps name it something more along those lines. IMHO cleaning implies other things might be done like trimming precision or removing coords outside a valid a range.
Implemented with #875