Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/overture-schema-codegen/docs/walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ time, captures their `__doc__` attributes, then deletes the instances:
class _DocstringProbeEnum(Enum):
pass


_ENUM_DEFAULT_DOCSTRING = _DocstringProbeEnum.__doc__
del _DocstringProbeEnum
```
Expand Down
3 changes: 3 additions & 0 deletions packages/overture-schema-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Every Overture feature type inherits from `OvertureFeature`, which extends `syst
from typing import Literal
from overture.schema.common import OvertureFeature


class Park(OvertureFeature[Literal["places"], Literal["park"]]):
area_hectares: float | None = None
```
Expand All @@ -29,6 +30,7 @@ from pydantic import BaseModel
from overture.schema.common.scoping import Scope, scoped
from overture.schema.system.numeric import float32


@scoped(Scope.GEOMETRIC_RANGE, Scope.TEMPORAL)
class SpeedLimit(BaseModel):
max_speed: float32
Expand Down Expand Up @@ -65,6 +67,7 @@ from typing import Literal
from overture.schema.common import OvertureFeature
from overture.schema.common.names import Named


class Lake(OvertureFeature[Literal["base"], Literal["water"]], Named):
pass # inherits names: Names | None from Named
```
Expand Down
19 changes: 17 additions & 2 deletions packages/overture-schema-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ from overture.schema.system.feature import Feature
from overture.schema.system.geometric import Geometry
from overture.schema.system.numeric import float32


class Mountain(Feature):
name: str
max_elevation: float32


m = Mountain(
geometry=Geometry.from_wkt("POINT(86.9252 27.9888)"),
name="Mount Everest",
Expand All @@ -36,6 +38,7 @@ Using `int` and `float` in a Pydantic model produces valid Python but loses info
from pydantic import BaseModel
from overture.schema.system.numeric import uint8, float32


class Building(BaseModel):
height: float32 | None = None
num_floors: uint8 | None = None
Expand All @@ -48,7 +51,11 @@ Integer types: `uint8`, `uint16`, `uint32`, `int8`, `int16`, `int32`, `int64`. F
`Geometry` and `BBox` wrap Shapely and GeoJSON-compatible geometry and bounding box values so they can participate in a Pydantic model as fields, with `GeometryType` and `GeometryTypeConstraint` available to restrict a `Geometry` field to specific geometry types:

```python
from overture.schema.system.geometric import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.system.geometric import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)
```

Types: `Geometry`, `BBox`, `GeometryType`, `GeometryTypeConstraint`.
Expand All @@ -70,13 +77,17 @@ Annotations for Pydantic fields that enforce domain rules beyond what the type a
```python
from typing import Annotated
from pydantic import BaseModel, Field
from overture.schema.system.field_constraint import UniqueItemsConstraint, PatternConstraint
from overture.schema.system.field_constraint import (
UniqueItemsConstraint,
PatternConstraint,
)

OsmIdConstraint = PatternConstraint(
pattern=r"^[nwr]\d+$",
error_message="invalid OSM ID format: {value}. Must be n123, w123, or r123.",
)


class MyModel(BaseModel):
osm_id: Annotated[str, OsmIdConstraint]
tags: Annotated[list[str], UniqueItemsConstraint()] = Field(min_length=1)
Expand All @@ -92,6 +103,7 @@ Class-level decorators for cross-field validation -- relationships between field
from pydantic import BaseModel
from overture.schema.system.model_constraint import require_any_of


@require_any_of("email", "phone")
class Contact(BaseModel):
email: str | None = None
Expand All @@ -114,9 +126,11 @@ Foreign-key-style annotations that describe relationships between models. These
from typing import Annotated
from overture.schema.system.ref import Id, Identified, Reference, Relationship


class Park(Identified):
pass


class ParkBench(Identified):
park_id: Annotated[Id, Reference(Relationship.BELONGS_TO, Park)]
```
Expand Down Expand Up @@ -180,6 +194,7 @@ from pydantic import BaseModel
from overture.schema.system.discovery import ModelKey
from overture.schema.system.feature import Feature


def feature_provider(
types: Iterable[type[BaseModel]],
key: ModelKey,
Expand Down
7 changes: 1 addition & 6 deletions packages/overture-schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,22 @@ geojson_output = building.model_dump(mode="json")
from overture.schema import (
# Addresses theme
Address,

# Base theme
Bathymetry,
Infrastructure,
Land,
LandCover,
LandUse,
Water,

# Buildings theme
Building,
BuildingPart,

# Divisions theme
Division,
DivisionArea,
DivisionBoundary,

# Places theme
Place,

# Transportation theme
Connector,
Segment,
Expand All @@ -72,7 +67,7 @@ from overture.schema import parse, discover_models, json_schema
from overture.schema import Building

# Parse any Overture feature (auto-discovers all registered models)
validated_feature = parse(feature_data, mode="json") # Parses GeoJSON format
validated_feature = parse(feature_data, mode="json") # Parses GeoJSON format
validated_feature = parse(feature_data, mode="python") # Parses flat format

# Discover all registered models programmatically
Expand Down
44 changes: 22 additions & 22 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading