Skip to content

Feat/values at point for line and polygon - #268

Open
NtnHgr wants to merge 15 commits into
mainfrom
feat/valuesAtPoint-for-line-and-polygon
Open

NtnHgr wants to merge 15 commits into
mainfrom
feat/valuesAtPoint-for-line-and-polygon

Conversation

@NtnHgr

@NtnHgr NtnHgr commented Sep 28, 2026

Copy link
Copy Markdown

Description

Extends the valuesAtPoint endpoint of the GeospatialAnalyzer to accept LineString and Polygon input geometries in addition to Points.
Previously only the value at a single point was returned. Now the values of the underlying raster topics (e.g. ´hoehe_r` of DGM/DOM) can be queried along a line or within an area.

Changes

ValuesAtPointService.handleLogicalRequest now branches by geometry type:

  • Point: unchanged, returns a single value.
  • LineString: returns a profile.
    • The line is sampled at equal distances (LINE_SEGMENT_LENGTH_METERS, currently 10 m) using ST_LineInterpolatePoint. The first and last point of the line are always included, so the last interval can be shorter than the segment length.
    • The value of every sample point is looked up individually. Since a line can cross several raster tiles, the matching tile is searched per sample point. To keep this fast, the tiles intersecting the whole line are pre-filtered once (candidate_tiles).
    • Output: heights: { min, max, mean, points: [{ index, height }, ...] }. index is the position of the sample point along the line (not a distance in meters). mean is rounded to 2 decimal places.
  • Polygon: returns raster statistics in the new property heightStats.
    • The tiles intersecting the polygon are merged (ST_Union) and clipped to the polygon (ST_Clip, cropped to its bounding box). Pixels outside the polygon have no value and are not part of the statistics.
    • Output: heightStats: { count, min, max, sum, mean, stddev } (via ST_SummaryStats). sum and mean are rounded to 2, stddev to 3 decimal places.
    • If the polygon does not overlap the raster coverage, the statistics are empty (null) instead of causing an error.
  • All other geometry types are rejected with HTTP 400 and a descriptive message.

As before, one result feature is returned per raster source of the topic (DGM and DOM for hoehe_r).

The segment length (query of LineString) is not an API parameter. It can be changed in one place, the constant LINE_SEGMENT_LENGTH_METERS in general.constants.ts.

Testing

The implementation was tested locally with the PostGIS database.

  • Unit tests (values-at-point.service.spec.ts): the generated SQL for Point, LineString and Polygon, one sub-query per raster source, rejection of unsupported geometry types.
  • e2e tests (values-at-point.e2e-spec.ts):
    • LineString: response structure, min <= mean <= max, points sorted by index, rounding of mean.
    • Polygon: plausible statistics for both sources, rounding of sum/mean/stddev, only pixels inside the polygon are counted (a triangle covers about half the pixels of its bounding rectangle), polygon outside the raster coverage, unsupported geometry type.
    • Point: existing response structure is unchanged and contains neither heights nor heightStats.

Impact

The existing Point functionality remains unchanged.

@NtnHgr NtnHgr added the enhancement New feature or request label Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant