|
| 1 | +# overture-schema-extensions |
| 2 | + |
| 3 | +Overture Maps schema extensions with additional feature properties like operating hours. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This package provides a simple extension model that contains just an ID and operating hours information. Unlike full Overture features, this model doesn't require geometry, version, theme, or other standard feature fields, making it perfect for datasets that only need to associate operating hours with IDs. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +### ExtendedFeature |
| 12 | + |
| 13 | +A simple model with just two fields: |
| 14 | + |
| 15 | +**Fields:** |
| 16 | + |
| 17 | +- `id`: Unique identifier (required, inherited from the `Identified` mixin) |
| 18 | +- `operating_hours`: Operating hours specification (optional) |
| 19 | + |
| 20 | +### OperatingHours |
| 21 | + |
| 22 | +A structured model for operating hours information: |
| 23 | + |
| 24 | +- `primary`: Primary operating hours (required string, e.g., `"Mo-Fr 09:00-17:00; Sa 10:00-14:00"`) |
| 25 | + |
| 26 | +## Installation |
| 27 | + |
| 28 | +This package is part of the Overture Maps schema workspace. Install it using: |
| 29 | + |
| 30 | +```bash |
| 31 | +uv pip install overture-schema-extensions |
| 32 | +``` |
| 33 | + |
| 34 | +Or include it in your project dependencies: |
| 35 | + |
| 36 | +```toml |
| 37 | +[project] |
| 38 | +dependencies = [ |
| 39 | + "overture-schema-extensions", |
| 40 | +] |
| 41 | +``` |
| 42 | + |
| 43 | +## Usage |
| 44 | + |
| 45 | +### Basic Example |
| 46 | + |
| 47 | +```python |
| 48 | +from overture.schema.extensions import ExtendedFeature, OperatingHours |
| 49 | + |
| 50 | +# Create a simple feature with just ID and operating hours |
| 51 | +feature = ExtendedFeature( |
| 52 | + id="example-123", |
| 53 | + operating_hours=OperatingHours( |
| 54 | + primary="Mo-Fr 09:00-17:00; Sa 10:00-14:00" |
| 55 | + ) |
| 56 | +) |
| 57 | + |
| 58 | +# You can also create a feature with just an ID |
| 59 | +minimal_feature = ExtendedFeature(id="example-456") |
| 60 | +``` |
| 61 | + |
| 62 | +### JSON Schema Generation |
| 63 | + |
| 64 | +Generate JSON Schema for validation: |
| 65 | + |
| 66 | +```python |
| 67 | +import json |
| 68 | +from overture.schema.extensions import ExtendedFeature |
| 69 | + |
| 70 | +schema = ExtendedFeature.model_json_schema() |
| 71 | +print(json.dumps(schema, indent=2)) |
| 72 | +``` |
| 73 | + |
| 74 | +### Validation |
| 75 | + |
| 76 | +The models use Pydantic for automatic validation: |
| 77 | + |
| 78 | +```python |
| 79 | +from overture.schema.extensions import ExtendedFeature |
| 80 | + |
| 81 | +# This will raise validation errors if required fields are missing |
| 82 | +# or if field values don't match constraints |
| 83 | +try: |
| 84 | + feature = ExtendedFeature( |
| 85 | + id="test", |
| 86 | + operating_hours=OperatingHours(primary="Mo-Fr 09:00-17:00") |
| 87 | + ) |
| 88 | + print("Valid feature!") |
| 89 | +except ValueError as e: |
| 90 | + print(f"Validation error: {e}") |
| 91 | +``` |
| 92 | + |
| 93 | +## Development |
| 94 | + |
| 95 | +### Running Tests |
| 96 | + |
| 97 | +```bash |
| 98 | +uv run pytest packages/overture-schema-extensions/ |
| 99 | +``` |
| 100 | + |
| 101 | +### Type Checking |
| 102 | + |
| 103 | +The package includes a `py.typed` marker for full type hint support: |
| 104 | + |
| 105 | +```bash |
| 106 | +mypy src/overture/schema/extensions/ |
| 107 | +``` |
| 108 | + |
| 109 | +## Use Cases |
| 110 | + |
| 111 | +This package is ideal for: |
| 112 | + |
| 113 | +- **Lightweight datasets**: When you only need to track operating hours by ID, without full geospatial features |
| 114 | +- **Operating hours updates**: Maintaining a separate dataset of operating hours that can be joined with full feature data |
| 115 | +- **Simple extensions**: Demonstrating how to create minimal Pydantic models that reuse Overture's ID system |
| 116 | + |
| 117 | +## Schema Patterns |
| 118 | + |
| 119 | +This package follows the Overture Maps Pydantic schema conventions: |
| 120 | + |
| 121 | +- Uses `@no_extra_fields` decorator for strict validation |
| 122 | +- Follows the `OvertureFeature[ThemeT, TypeT]` generic pattern |
| 123 | +- Uses `Annotated` types with `Field()` for descriptions and constraints |
| 124 | +- All optional fields default to `None` (never non-None defaults) |
| 125 | +- Numeric types use specific primitives (`int32`, `float64`, etc.) |
| 126 | + |
| 127 | +For more information on schema patterns, see the [Pydantic Guide](../../PYDANTIC_GUIDE.md). |
| 128 | + |
| 129 | +## License |
| 130 | + |
| 131 | +MIT License - See LICENSE file for details. |
| 132 | + |
| 133 | +## Related Packages |
| 134 | + |
| 135 | +- `overture-schema-core`: Base classes and common structures |
| 136 | +- `overture-schema-system`: Primitives, constraints, and validation |
| 137 | +- `overture-schema-places-theme`: Places features (inspiration for operating hours) |
| 138 | +- `overture-schema-buildings-theme`: Buildings features |
| 139 | + |
| 140 | +## Contributing |
| 141 | + |
| 142 | +This package demonstrates how to create simple extensions to the Overture Maps schema: |
| 143 | + |
| 144 | +1. Inherit from `Identified` to get the `id` field (instead of full `OvertureFeature`) |
| 145 | +2. Add custom fields with proper annotations and descriptions |
| 146 | +3. Create supporting models with `@no_extra_fields` decorator |
| 147 | +4. Register your feature in `pyproject.toml` entry points |
| 148 | + |
| 149 | +This approach lets you create lightweight models that don't require all the standard Overture feature fields like geometry, version, theme, and type. |
0 commit comments