Skip to content

Commit a11751f

Browse files
first
1 parent 1724b46 commit a11751f

File tree

10 files changed

+1416
-0
lines changed

10 files changed

+1416
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[project]
2+
dependencies = [
3+
"overture-schema-core",
4+
"overture-schema-places-theme",
5+
"pydantic>=2.0",
6+
]
7+
description = "Overture Maps places extended with operating hours support"
8+
dynamic = ["version"]
9+
license = "MIT"
10+
name = "overture-schema-extensions"
11+
readme = "README.md"
12+
requires-python = ">=3.10"
13+
14+
[tool.uv.sources]
15+
overture-schema-core = { workspace = true }
16+
overture-schema-places-theme = { workspace = true }
17+
18+
[build-system]
19+
build-backend = "hatchling.build"
20+
requires = ["hatchling"]
21+
22+
[tool.hatch.version]
23+
path = "src/overture/schema/extensions/__about__.py"
24+
25+
[tool.hatch.build.targets.wheel]
26+
packages = ["src/overture"]
27+
28+
[project.entry-points."overture.models"]
29+
"extensions.entity_with_operating_hours" = "overture.schema.extensions:EntityWithOperatingHours"
30+
"extensions.place_with_operating_hours" = "overture.schema.extensions:PlaceWithOperatingHours"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Overture namespace package."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Overture schema namespace package."""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Version information for overture-schema-extensions."""
2+
3+
__version__ = "0.1.0"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Overture schema extensions package."""
2+
3+
from .models import (
4+
DayOfWeek,
5+
EntityWithOperatingHours,
6+
HourSet,
7+
HourSetStatus,
8+
OperatingHours,
9+
PlaceWithOperatingHours,
10+
Rule,
11+
)
12+
13+
__all__ = [
14+
"DayOfWeek",
15+
"EntityWithOperatingHours",
16+
"HourSet",
17+
"HourSetStatus",
18+
"OperatingHours",
19+
"PlaceWithOperatingHours",
20+
"Rule",
21+
]

0 commit comments

Comments
 (0)