overture-schema 1.17.1.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: overture-schema
|
|
3
|
+
Version: 1.17.1.dev0
|
|
4
|
+
Summary: Complete Overture Maps schema collection with all themes and types
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Dist: overture-schema-theme-addresses>=0.1.1
|
|
7
|
+
Requires-Dist: overture-schema-theme-base>=0.1.1
|
|
8
|
+
Requires-Dist: overture-schema-theme-buildings>=0.1.1
|
|
9
|
+
Requires-Dist: overture-schema-theme-divisions>=0.1.1
|
|
10
|
+
Requires-Dist: overture-schema-theme-places>=0.1.1
|
|
11
|
+
Requires-Dist: overture-schema-theme-transportation>=0.1.1
|
|
12
|
+
Requires-Dist: overture-schema-validation>=0.1.1
|
|
13
|
+
Requires-Dist: overture-schema-cli>=0.1.1
|
|
14
|
+
Maintainer: Overture Maps Schema Working Group
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Project-URL: Homepage, https://overturemaps.org
|
|
17
|
+
Project-URL: Source, https://github.com/OvertureMaps/schema
|
|
18
|
+
Project-URL: Issues, https://github.com/OvertureMaps/schema/issues
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# overture-schema
|
|
22
|
+
|
|
23
|
+
Type-safe Python models for [Overture Maps Foundation](https://overturemaps.org/) data.
|
|
24
|
+
|
|
25
|
+
This package provides Pydantic models for validating and working with Overture Maps data, including buildings, places, addresses, transportation networks, and administrative boundaries.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install overture-schema
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`overture-schema` is a metapackage: it pulls in every theme package plus the
|
|
34
|
+
validation library and the CLI, and ships no code of its own. `overture.schema`
|
|
35
|
+
is a namespace root, so import from the theme and system packages rather than
|
|
36
|
+
from `overture.schema` directly.
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
Import models from the theme package that defines them:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from overture.schema.buildings import Building
|
|
44
|
+
from overture.schema.places import Place
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Tabular data, and GeoJSON for compatibility
|
|
48
|
+
|
|
49
|
+
Overture publishes data in one shape: flat and tabular -- the column layout of the
|
|
50
|
+
Parquet release, with `theme`, `type`, and `version` as top-level columns and
|
|
51
|
+
geometry as WKT. That is what **Python mode** (`model_validate`) reads.
|
|
52
|
+
|
|
53
|
+
The models also accept and emit GeoJSON, through **JSON mode**
|
|
54
|
+
(`model_validate_json`), so the schema works with tools that expect features
|
|
55
|
+
rather than rows. The generated JSON Schema describes that representation.
|
|
56
|
+
|
|
57
|
+
The modes are not interchangeable. Passing a GeoJSON dict to `model_validate`
|
|
58
|
+
reports `theme`/`version` missing and `type` set to `'Feature'`, because it is
|
|
59
|
+
reading GeoJSON keys as flat columns.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# Flat / tabular (Parquet-shaped) dict
|
|
63
|
+
building = Building.model_validate(feature_row)
|
|
64
|
+
|
|
65
|
+
# GeoJSON -- JSON mode, from a string or bytes
|
|
66
|
+
building = Building.model_validate_json(geojson_text)
|
|
67
|
+
|
|
68
|
+
# Serialize back to GeoJSON. by_alias=True is required: without it,
|
|
69
|
+
# aliased fields serialize under their Python names (`class_`, not
|
|
70
|
+
# `class`) and the output will not re-validate.
|
|
71
|
+
geojson_output = building.model_dump(mode="json", by_alias=True, exclude_none=True)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Available Models
|
|
75
|
+
|
|
76
|
+
Each model lives in its theme package. The metapackage installs all of them:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from overture.schema.addresses import Address
|
|
80
|
+
from overture.schema.base import (
|
|
81
|
+
Bathymetry,
|
|
82
|
+
Infrastructure,
|
|
83
|
+
Land,
|
|
84
|
+
LandCover,
|
|
85
|
+
LandUse,
|
|
86
|
+
Water,
|
|
87
|
+
)
|
|
88
|
+
from overture.schema.buildings import Building, BuildingPart
|
|
89
|
+
from overture.schema.divisions import Division, DivisionArea, DivisionBoundary
|
|
90
|
+
from overture.schema.places import Place
|
|
91
|
+
from overture.schema.transportation import Connector, Segment
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`Segment` is a discriminated union alias rather than a class, so it validates
|
|
95
|
+
through a `TypeAdapter`:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from pydantic import TypeAdapter
|
|
99
|
+
|
|
100
|
+
segments = TypeAdapter(Segment)
|
|
101
|
+
segment = segments.validate_json(geojson_text)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Validating without knowing the type
|
|
105
|
+
|
|
106
|
+
`overture-schema-validation` validates against the union of every installed
|
|
107
|
+
model, picking the right one from the data:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from overture.schema.validation import validate, validate_json
|
|
111
|
+
|
|
112
|
+
feature = validate(feature_row) # flat / tabular dict
|
|
113
|
+
feature = validate_json(geojson_text) # GeoJSON
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Discovering models programmatically
|
|
117
|
+
|
|
118
|
+
Discovery lives in `overture-schema-system`. `discover_models()` returns a dict
|
|
119
|
+
keyed by `ModelKey` -- entry point `name`, its `entry_point` value, and the set
|
|
120
|
+
of tags attached during discovery:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from overture.schema.system.discovery import discover_models, get_registered_model
|
|
124
|
+
|
|
125
|
+
all_models = discover_models()
|
|
126
|
+
# {
|
|
127
|
+
# ModelKey(name="building", entry_point="overture.schema.buildings:Building",
|
|
128
|
+
# tags=frozenset({"feature", "overture", "overture:theme=buildings"})): Building,
|
|
129
|
+
# ModelKey(name="place", entry_point="overture.schema.places:Place",
|
|
130
|
+
# tags=frozenset({"feature", "overture", "overture:theme=places"})): Place,
|
|
131
|
+
# ...
|
|
132
|
+
# }
|
|
133
|
+
|
|
134
|
+
building_model = get_registered_model("building") # None if not installed
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Generating JSON Schema
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from overture.schema.system.json_schema import json_schema
|
|
141
|
+
|
|
142
|
+
schema = json_schema(Building)
|
|
143
|
+
union_schema = json_schema(Building | Place) # emits an anyOf
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
See the [`overture-schema-system` README](../overture-schema-system/README.md)
|
|
147
|
+
for tag format, tag providers, and the discovery API in full.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# overture-schema
|
|
2
|
+
|
|
3
|
+
Type-safe Python models for [Overture Maps Foundation](https://overturemaps.org/) data.
|
|
4
|
+
|
|
5
|
+
This package provides Pydantic models for validating and working with Overture Maps data, including buildings, places, addresses, transportation networks, and administrative boundaries.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install overture-schema
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`overture-schema` is a metapackage: it pulls in every theme package plus the
|
|
14
|
+
validation library and the CLI, and ships no code of its own. `overture.schema`
|
|
15
|
+
is a namespace root, so import from the theme and system packages rather than
|
|
16
|
+
from `overture.schema` directly.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Import models from the theme package that defines them:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from overture.schema.buildings import Building
|
|
24
|
+
from overture.schema.places import Place
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Tabular data, and GeoJSON for compatibility
|
|
28
|
+
|
|
29
|
+
Overture publishes data in one shape: flat and tabular -- the column layout of the
|
|
30
|
+
Parquet release, with `theme`, `type`, and `version` as top-level columns and
|
|
31
|
+
geometry as WKT. That is what **Python mode** (`model_validate`) reads.
|
|
32
|
+
|
|
33
|
+
The models also accept and emit GeoJSON, through **JSON mode**
|
|
34
|
+
(`model_validate_json`), so the schema works with tools that expect features
|
|
35
|
+
rather than rows. The generated JSON Schema describes that representation.
|
|
36
|
+
|
|
37
|
+
The modes are not interchangeable. Passing a GeoJSON dict to `model_validate`
|
|
38
|
+
reports `theme`/`version` missing and `type` set to `'Feature'`, because it is
|
|
39
|
+
reading GeoJSON keys as flat columns.
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
# Flat / tabular (Parquet-shaped) dict
|
|
43
|
+
building = Building.model_validate(feature_row)
|
|
44
|
+
|
|
45
|
+
# GeoJSON -- JSON mode, from a string or bytes
|
|
46
|
+
building = Building.model_validate_json(geojson_text)
|
|
47
|
+
|
|
48
|
+
# Serialize back to GeoJSON. by_alias=True is required: without it,
|
|
49
|
+
# aliased fields serialize under their Python names (`class_`, not
|
|
50
|
+
# `class`) and the output will not re-validate.
|
|
51
|
+
geojson_output = building.model_dump(mode="json", by_alias=True, exclude_none=True)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Available Models
|
|
55
|
+
|
|
56
|
+
Each model lives in its theme package. The metapackage installs all of them:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from overture.schema.addresses import Address
|
|
60
|
+
from overture.schema.base import (
|
|
61
|
+
Bathymetry,
|
|
62
|
+
Infrastructure,
|
|
63
|
+
Land,
|
|
64
|
+
LandCover,
|
|
65
|
+
LandUse,
|
|
66
|
+
Water,
|
|
67
|
+
)
|
|
68
|
+
from overture.schema.buildings import Building, BuildingPart
|
|
69
|
+
from overture.schema.divisions import Division, DivisionArea, DivisionBoundary
|
|
70
|
+
from overture.schema.places import Place
|
|
71
|
+
from overture.schema.transportation import Connector, Segment
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`Segment` is a discriminated union alias rather than a class, so it validates
|
|
75
|
+
through a `TypeAdapter`:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from pydantic import TypeAdapter
|
|
79
|
+
|
|
80
|
+
segments = TypeAdapter(Segment)
|
|
81
|
+
segment = segments.validate_json(geojson_text)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Validating without knowing the type
|
|
85
|
+
|
|
86
|
+
`overture-schema-validation` validates against the union of every installed
|
|
87
|
+
model, picking the right one from the data:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from overture.schema.validation import validate, validate_json
|
|
91
|
+
|
|
92
|
+
feature = validate(feature_row) # flat / tabular dict
|
|
93
|
+
feature = validate_json(geojson_text) # GeoJSON
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Discovering models programmatically
|
|
97
|
+
|
|
98
|
+
Discovery lives in `overture-schema-system`. `discover_models()` returns a dict
|
|
99
|
+
keyed by `ModelKey` -- entry point `name`, its `entry_point` value, and the set
|
|
100
|
+
of tags attached during discovery:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from overture.schema.system.discovery import discover_models, get_registered_model
|
|
104
|
+
|
|
105
|
+
all_models = discover_models()
|
|
106
|
+
# {
|
|
107
|
+
# ModelKey(name="building", entry_point="overture.schema.buildings:Building",
|
|
108
|
+
# tags=frozenset({"feature", "overture", "overture:theme=buildings"})): Building,
|
|
109
|
+
# ModelKey(name="place", entry_point="overture.schema.places:Place",
|
|
110
|
+
# tags=frozenset({"feature", "overture", "overture:theme=places"})): Place,
|
|
111
|
+
# ...
|
|
112
|
+
# }
|
|
113
|
+
|
|
114
|
+
building_model = get_registered_model("building") # None if not installed
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Generating JSON Schema
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from overture.schema.system.json_schema import json_schema
|
|
121
|
+
|
|
122
|
+
schema = json_schema(Building)
|
|
123
|
+
union_schema = json_schema(Building | Place) # emits an anyOf
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
See the [`overture-schema-system` README](../overture-schema-system/README.md)
|
|
127
|
+
for tag format, tag providers, and the discovery API in full.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
dependencies = [
|
|
3
|
+
"overture-schema-theme-addresses>=0.1.1",
|
|
4
|
+
"overture-schema-theme-base>=0.1.1",
|
|
5
|
+
"overture-schema-theme-buildings>=0.1.1",
|
|
6
|
+
"overture-schema-theme-divisions>=0.1.1",
|
|
7
|
+
"overture-schema-theme-places>=0.1.1",
|
|
8
|
+
"overture-schema-theme-transportation>=0.1.1",
|
|
9
|
+
"overture-schema-validation>=0.1.1",
|
|
10
|
+
"overture-schema-cli>=0.1.1",
|
|
11
|
+
]
|
|
12
|
+
description = "Complete Overture Maps schema collection with all themes and types"
|
|
13
|
+
version = "1.17.1.dev0"
|
|
14
|
+
license = "MIT"
|
|
15
|
+
name = "overture-schema"
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
requires-python = ">=3.10"
|
|
18
|
+
|
|
19
|
+
[[project.maintainers]]
|
|
20
|
+
name = "Overture Maps Schema Working Group"
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://overturemaps.org"
|
|
24
|
+
Source = "https://github.com/OvertureMaps/schema"
|
|
25
|
+
Issues = "https://github.com/OvertureMaps/schema/issues"
|
|
26
|
+
|
|
27
|
+
[tool.uv.sources.overture-schema-cli]
|
|
28
|
+
workspace = true
|
|
29
|
+
|
|
30
|
+
[tool.uv.sources.overture-schema-theme-addresses]
|
|
31
|
+
workspace = true
|
|
32
|
+
|
|
33
|
+
[tool.uv.sources.overture-schema-theme-base]
|
|
34
|
+
workspace = true
|
|
35
|
+
|
|
36
|
+
[tool.uv.sources.overture-schema-theme-buildings]
|
|
37
|
+
workspace = true
|
|
38
|
+
|
|
39
|
+
[tool.uv.sources.overture-schema-theme-divisions]
|
|
40
|
+
workspace = true
|
|
41
|
+
|
|
42
|
+
[tool.uv.sources.overture-schema-theme-places]
|
|
43
|
+
workspace = true
|
|
44
|
+
|
|
45
|
+
[tool.uv.sources.overture-schema-theme-transportation]
|
|
46
|
+
workspace = true
|
|
47
|
+
|
|
48
|
+
[tool.uv.sources.overture-schema-validation]
|
|
49
|
+
workspace = true
|
|
50
|
+
|
|
51
|
+
[tool.uv.build-backend]
|
|
52
|
+
module-name = "overture.schema"
|
|
53
|
+
namespace = true
|
|
54
|
+
|
|
55
|
+
[build-system]
|
|
56
|
+
requires = ["uv_build>=0.11.32,<0.13"]
|
|
57
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
maintainers = [
|
|
3
|
+
{name = "Overture Maps Schema Working Group"},
|
|
4
|
+
]
|
|
5
|
+
dependencies = [
|
|
6
|
+
"overture-schema-theme-addresses>=0.1.1",
|
|
7
|
+
"overture-schema-theme-base>=0.1.1",
|
|
8
|
+
"overture-schema-theme-buildings>=0.1.1",
|
|
9
|
+
"overture-schema-theme-divisions>=0.1.1",
|
|
10
|
+
"overture-schema-theme-places>=0.1.1",
|
|
11
|
+
"overture-schema-theme-transportation>=0.1.1",
|
|
12
|
+
"overture-schema-validation>=0.1.1",
|
|
13
|
+
"overture-schema-cli>=0.1.1",
|
|
14
|
+
]
|
|
15
|
+
description = "Complete Overture Maps schema collection with all themes and types"
|
|
16
|
+
version = "1.17.1.dev0"
|
|
17
|
+
license = "MIT"
|
|
18
|
+
name = "overture-schema"
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
requires-python = ">=3.10"
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://overturemaps.org"
|
|
24
|
+
Source = "https://github.com/OvertureMaps/schema"
|
|
25
|
+
Issues = "https://github.com/OvertureMaps/schema/issues"
|
|
26
|
+
|
|
27
|
+
[tool.uv.sources]
|
|
28
|
+
overture-schema-cli = { workspace = true }
|
|
29
|
+
overture-schema-theme-addresses = { workspace = true }
|
|
30
|
+
overture-schema-theme-base = { workspace = true }
|
|
31
|
+
overture-schema-theme-buildings = { workspace = true }
|
|
32
|
+
overture-schema-theme-divisions = { workspace = true }
|
|
33
|
+
overture-schema-theme-places = { workspace = true }
|
|
34
|
+
overture-schema-theme-transportation = { workspace = true }
|
|
35
|
+
overture-schema-validation = { workspace = true }
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["uv_build>=0.11.32,<0.13"]
|
|
39
|
+
build-backend = "uv_build"
|
|
40
|
+
|
|
41
|
+
[tool.uv.build-backend]
|
|
42
|
+
module-name = "overture.schema"
|
|
43
|
+
namespace = true
|
|
File without changes
|