Refactor/geometry wkt modules#71
Merged
Merged
Conversation
emmanuelmathot
approved these changes
Jul 17, 2026
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
force-pushed
the
refactor/geometry-wkt-modules
branch
from
July 17, 2026 10:34
ce43dee to
e4c62f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groundwork for #65, which adds
MULTIPOINTas a third WKT grammar. Rather than growfactory.pyto a fourth parser, move parsing out first.geometry.pytakesPositionandPolygonout ofinput.py, which was carrying both the geometry a coverage is built over and the variants pairing it with data.wkt.pytakes the parsers out offactory.py, which also confines a future shapely decision to one module.InvalidCoordsvalue rather than raisingBadRequestError. Unusablecoordsis an ordinary outcome of serving a request, not an exceptional one, sowkt.pyimports nothing butgeometry, and a route cannot reach a geometry without handling the refusal.domainTypeschema rules: a Grid domain missing its mandatoryyaxis validated clean.No behavior change: every error response keeps its status and its wording.
Stacked on #60; retarget to
mainonce that merges.