Skip to content

Documentation / @interstellar-tools/maps / pathProfile

Function: pathProfile() ​

ts
function pathProfile(
  grid: GridInterface,
  path: readonly GridPositionInterface[]
): ProfilePointInterface[];

Defined in: terrain/profile.ts:131

The height profile along a path of straight legs, such as a rover's route: each leg's profile, the distance going on from leg to leg.

Notes

  • A corner is sampled once, at the end of the leg into it.
  • A leg of no length adds nothing: a point repeated is sampled once.

Parameters ​

ParameterTypeDescription
gridGridInterfaceElevation grid, heights in m.
pathreadonly GridPositionInterface[]The path's points, in grid coordinates (at least two, each on the grid).

Returns ​

ProfilePointInterface[]

The samples, from the start.

Throws ​

  • If a size, cell size or point is not finite.
  • If the grid's parts don't fit together, a point is off the grid, or the path has fewer than two points.

Example ​

ts
// East 20 m, then south 10 m, on a grid of 10 m cells
pathProfile(grid, [
  { row: 1, column: 0 },
  { row: 1, column: 2 },
  { row: 2, column: 2 }
]).map(({ distance }) => distance); // [0, 10, 20, 30]

See ​

profile