stac-utils / stac-utils/pgstac

Topology exception when fetching tiles via titiler-pgstac

Open
#136 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PLpgSQL
Stars
223
Forks
57
PR merge metrics
No merged PRs in 30d

Description

I'm seeing this topology exception happening in the tile server sporadically, which is causing some dropped tiles for mosaics, e.g.:

https://planetarycomputer.microsoft.com/api/data/v1/mosaic/tiles/b1e9a2aabd78813d0d6ff72be8ab54b4/WebMercatorQuad/11/126/898@2x?collection=sentinel-2-l2a&assets=B04&assets=B03&assets=B02&nodata=0&color_formula=Gamma%20RGB%203.2%20Saturation%200.8%20Sigmoidal%20RGB%2025%200.35&tile_scale=2

{
"detail": "lwgeom_intersection_prec: GEOS Error: TopologyException: Input geom 1 is invalid: Self-intersection at or near point -157.1336 21.707504790000002 at -157.1336 21.707504790000002\nCONTEXT:  PL/pgSQL function geometrysearch(geometry,text,jsonb,integer,integer,interval,boolean,boolean) line 95 at assignment\nSQL function \"geojsonsearch\" statement 1"
}

That error was during the construction of this image, which is comprised of a set of tiles requested from titiler-pgstac:

pc-teams-background

The gray boxes are where 500's were thrown, including the one from the tile URL above.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failing tile request and tracing the PostgreSQL error through geometrysearch at line 95 and the geojsonsearch SQL function. Inspect how the tile query handles the invalid geometry reported in the error; done means the affected mosaic tile requests no longer sporadically return 500 errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.