Skip to content

Commit

Permalink
fix: handle case where all segments were skipped (close #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbourianes-kalisio committed Jul 5, 2023
1 parent 2a8ee32 commit f2bf9fe
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/elevation.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ async function elevation(geojson, query) {
totalDistance += length
})

if (allSegments.length === 0) {
// All segments were skipped
return turf_featureCollection([])
}

if (!skipFirstPoint) {
// Maybe extend last segment's maxx to sample past the endpoint
const lastSegment = allSegments[allSegments.length - 1]
Expand Down

0 comments on commit f2bf9fe

Please sign in to comment.