Skip to content

[@turf/line-slice-along] Fix offset distance equal to line length#2030

Merged
mfedderly merged 2 commits intoTurfjs:masterfrom
EricPKerr:fix-turf-line-slice-along
Feb 14, 2021
Merged

[@turf/line-slice-along] Fix offset distance equal to line length#2030
mfedderly merged 2 commits intoTurfjs:masterfrom
EricPKerr:fix-turf-line-slice-along

Conversation

@EricPKerr
Copy link
Copy Markdown
Contributor

@EricPKerr EricPKerr commented Feb 10, 2021

@turf/line-slice-along currently returns an invalid GeoJSON LineString if you pass in an offset that is equal to the line length.

The end of the module returns:

return lineString(coords[coords.length - 1]);

Which results in:

{
  type: 'Feature',
  properties: {},
  geometry: { type: 'LineString', coordinates: [ lon, lat ] }
}

This is a Point and not a valid LineString geometry (list of coordinates). The modification here returns the last point as a valid LineString geometry.

Copy link
Copy Markdown
Collaborator

@mfedderly mfedderly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants