[WIP] Add Bbox primitive directly to Feature next to geometry#485
[WIP] Add Bbox primitive directly to Feature next to geometry#485Jennings Anderson (jenningsanderson) wants to merge 3 commits intodevfrom
Conversation
🗺️ Schema reference docs preview is live!
Note ♻️ This preview updates automatically with each push to this PR. |
There was a problem hiding this comment.
Pull request overview
This PR updates the core OvertureFeature model to surface a bbox field alongside geometry.
Changes:
- Add a
bbox: BBoxfield toOvertureFeature. - Reformat imports and a
textwrap.dedent(...)call for theext_*JSON Schema description.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # this is an enum in the JSON Schema, but that prevents OvertureFeature from being extended | ||
| type: TypeT | ||
| geometry: Geometry | ||
| bbox: BBox |
There was a problem hiding this comment.
bbox is being overridden here as a required BBox, which changes the GeoJSON/Feature contract and conflicts with Feature.bbox being optional (packages/overture-schema-system/src/overture/schema/system/feature.py:198-205). This will also break existing construction/validation paths that omit bbox (e.g., GeoJSON without a bbox). If bbox is meant to remain optional, remove this override and inherit the field from Feature, or type it as Omitable[BBox] (or BBox | None with an appropriate default) and keep the Field description consistent with Feature.
| bbox: BBox |
| from overture.schema.system.primitive import BBox, Geometry | ||
| from overture.schema.system.ref import Id, Identified | ||
| from overture.schema.system.string import ( | ||
| CountryCodeAlpha2, | ||
| ) | ||
| from overture.schema.system.string import CountryCodeAlpha2 | ||
| from pydantic import BaseModel, ConfigDict, Field, GetJsonSchemaHandler, model_validator | ||
| from pydantic.json_schema import JsonSchemaValue |
There was a problem hiding this comment.
Import grouping/order here appears to violate the repo’s Ruff isort convention (third-party imports before first-party). In other core modules (e.g., packages/overture-schema-core/src/overture/schema/core/cartography.py:5-12), pydantic is imported before overture.*. Reorder these imports into stdlib / third-party / first-party blocks to avoid ruff (I001) failures.
|
Do we need to do this? My understanding is the CDP is now using the Pydantic version of the schema. I think we can be out of the business of updating the JSON Schema now? Given the shapeshifting nature of |
Sorry for the complete lack of context on this one — let me shed some light: As we move away from the I don't think we should alter the If defined in Pydantic, this would be accessible to the data pipeline validations and prevent future schema-related errors. Bonus: This also gives us an opportunity to define what makes a bounding box valuable across themes. Since it's primarily for data-filtering, does it makes sense to clamp it to some arbitrary precision? In many cases, it's probably the most-read column, which means going across the wire — maybe it doesn't need centimeter level precision? Does that impact query time? |
Because the aim is to keep the schema portable across data formats (including GeoJSON), the "primitive" |
Description
Testing the addition of
bboxdirectly into the Overture Feature to see how it propagates to the documentation....The
bboxprimitive is different from the GeoParquetbboxthat we create, so we'll need to re-think this — but great to see how a 1 line addition flows so nicely from schema to schema-docs!