Skip to content

Refactor/geometry wkt modules#71

Merged
chuckwondo merged 4 commits into
mainfrom
refactor/geometry-wkt-modules
Jul 17, 2026
Merged

Refactor/geometry wkt modules#71
chuckwondo merged 4 commits into
mainfrom
refactor/geometry-wkt-modules

Conversation

@chuckwondo

Copy link
Copy Markdown
Contributor

Groundwork for #65, which adds MULTIPOINT as a third WKT grammar. Rather than grow factory.py to a fourth parser, move parsing out first.

  • geometry.py takes Position and Polygon out of input.py, which was carrying both the geometry a coverage is built over and the variants pairing it with data.
  • wkt.py takes the parsers out of factory.py, which also confines a future shapely decision to one module.
  • The parsers return an InvalidCoords value rather than raising BadRequestError. Unusable coords is an ordinary outcome of serving a request, not an exceptional one, so wkt.py imports nothing but geometry, and a route cannot reach a geometry without handling the refusal.
  • Fixes a test helper that was silently skipping all twelve per-domainType schema rules: a Grid domain missing its mandatory y axis validated clean.

No behavior change: every error response keeps its status and its wording.

Stacked on #60; retarget to main once that merges.

Base automatically changed from feat/56-area-polygon-endpoint to main July 17, 2026 10:26
The CoverageJSON schema is written for JSON Schema draft-07 and files
all twelve of its per-domainType rules (the axes each domain requires,
and their shapes) under `domainBase.dependencies`.

The wrapper schema built for a named definition did not say which JSON
Schema version it was written for, so jsonschema inferred one and picked
the newest, 2020-12. Draft 2019-09 had split `dependencies` into
`dependentSchemas` and `dependentRequired`, reserving the old name for
compatibility but no longer asserting on it, so 2020-12 read
`dependencies` as an unknown keyword and ignored it.

Every domain therefore passed regardless of its domainType: a Grid
domain missing its mandatory `y` axis validated clean. Copy the root's
`$schema` onto the wrapper so both are checked against the same version.
input.py carried two concerns: the geometry a coverage is built over, and
the variants pairing that geometry with the data read across it. Move
Position and Polygon to a module of their own, verbatim, so each has one
job and the layering is explicit: geometry depends on nothing, while
input and the request parser both build on it.
A third grammar is coming, and the parsers had outgrown factory.py: two
regexes, three functions, and their doctests sat among the routes and
the sizing helpers. Move them out. The two parsers become the module's
public surface; the regexes and the shared vertex parser stay private,
below it.

Rename _parse_ring to _parse_xy_pairs. It reads a comma-separated list
of "x y" pairs, which is a polygon ring only because a polygon is what
asks for one; a MULTIPOINT body is the same grammar.

Behavior is unchanged. The parsers still raise BadRequestError, which
leaves the module importing titiler; the next commit makes them return
the failure instead.
The parsers raised BadRequestError, so wkt.py imported titiler to report
a malformed query string. Return an InvalidCoords value instead:
unusable coords is an ordinary outcome of serving a request, not an
exceptional one. wkt.py now imports nothing but geometry, and a route
cannot reach a geometry without checking for the refusal, since mypy
rejects the union otherwise. Every 400 keeps its wording.

Name it InvalidCoords, not InvalidWkt: most refusals are of well-formed
WKT, such as a 3-D POINT Z, so the input is unusable as coords rather
than invalid WKT. Also repair seven test names the previous commit's
rename mangled.
@chuckwondo
chuckwondo force-pushed the refactor/geometry-wkt-modules branch from ce43dee to e4c62f2 Compare July 17, 2026 10:34
@chuckwondo
chuckwondo merged commit 2ef477f into main Jul 17, 2026
12 checks passed
@chuckwondo
chuckwondo deleted the refactor/geometry-wkt-modules branch July 17, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants