Skip to content

Unexpected elevation output when using line-chunk / line-slice-along #3007

@russellporter

Description

@russellporter

When given a line with two points at different elevations, lineSliceAlong and lineChunk output new points with an arbitrary elevation of one of the endpoints.

I'd expect 2D output as was the old behavior, or if the computation is performed in 3D space, an interpolated elevation.

The change seems to be an unintended side effect of #2852.

Example:

  const line = {
    type: 'Feature',
    geometry: {
      type: 'LineString',
      coordinates: [
        [0, 0, 0],        // start, elevation=0
        [0, 0.0009, 100], // ~100m, elevation=100
      ],
    },
  };

  const sliced = turf.lineSliceAlong(line, 0, 50, { units: 'meters' });
  console.log('New endpoint:', sliced.geometry.coordinates[1]); // midpoint is at 100m elevation

https://jsfiddle.net/67aex0jc/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions