Pydantic Models for MicroJSON and GeoJSON
Introduction
This document describes the Pydantic models used for GeoJSON and MicroJSON objects. These models leverage Python's type hinting and Pydantic's validation mechanisms, making it robust and efficient to work with complex GeoJSON and MicroJSON objects.
Models
MicroJSON and GeoJSON models, defined manually using pydantic.
GeoJSON
Bases: RootModel
The root object of a GeoJSON file
Source code in src/microjson/model.py
170 171 172 173 | |
MicroFeature
Bases: Feature
A MicroJSON feature, which is a GeoJSON feature with additional metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Optional[GeometryType]
|
Extended geometry supporting 3D types |
required |
multiscale
|
Optional[Multiscale]
|
The coordinate system of the feature |
required |
ref
|
Optional[Union[StrictStr, StrictInt]]
|
A reference to the parent feature |
required |
parentId
|
Optional[Union[StrictStr, StrictInt]]
|
A reference to the parent feature |
required |
featureClass
|
Optional[str]
|
The class of the feature |
required |
Source code in src/microjson/model.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
MicroFeatureCollection
Bases: FeatureCollection
A MicroJSON feature collection, which is a GeoJSON feature collection with additional metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
List[MicroFeature]
|
Features with extended 3D geometry support |
required |
properties
|
Optional[Props]
|
The properties of the feature collection |
required |
id
|
Optional[Union[StrictStr, StrictInt]]
|
The ID of the feature coll. |
required |
Source code in src/microjson/model.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
MicroJSON
Bases: RootModel
The root object of a MicroJSON file
Source code in src/microjson/model.py
225 226 227 228 | |
OntologyTerm
Bases: BaseModel
A reference to a formal ontology term.
Attributes:
| Name | Type | Description |
|---|---|---|
uri |
str
|
Full URI of the ontology term (e.g. "http://purl.obolibrary.org/obo/CL_0000598"). |
label |
Optional[str]
|
Human-readable label (e.g. "pyramidal neuron"). |
description |
Optional[str]
|
Optional longer description of the term. |
Source code in src/microjson/model.py
130 131 132 133 134 135 136 137 138 139 140 | |
PolyhedralSurface
Bases: BaseModel
A closed surface mesh consisting of polygonal faces (ISO 19107).
Each face has the same structure as a Polygon: a list of linear rings, where each ring is a list of 3D positions.
Source code in src/microjson/model.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
TIN
Bases: BaseModel
A Triangulated Irregular Network — triangle mesh surface (ISO 19107).
Each face must be a single closed ring of exactly 4 positions (3 vertices + repeated first vertex).
Source code in src/microjson/model.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
Vocabulary
Bases: BaseModel
Maps property values to formal ontology terms.
Attributes:
| Name | Type | Description |
|---|---|---|
namespace |
Optional[str]
|
Common URI prefix for the ontology (e.g. "http://purl.obolibrary.org/obo/CL_"). |
description |
Optional[str]
|
Optional description of this vocabulary. |
terms |
Dict[str, OntologyTerm]
|
Mapping from property values to ontology terms. |
Source code in src/microjson/model.py
143 144 145 146 147 148 149 150 151 152 153 | |
Base Objects
Geometry Types
Uses geojson-pydantic models for GeoJSON geometry types, included here for reference. Please refer to the geojson-pydantic documentation for more information.
Point
Represents a GeoJSON Point object.
MultiPoint
Represents a GeoJSON MultiPoint object.
LineString
Represents a GeoJSON LineString object.
MultiLineString
Represents a GeoJSON MultiLineString object.
Polygon
Represents a GeoJSON Polygon object.
MultiPolygon
Represents a GeoJSON MultiPolygon object.
Compound Objects
GeometryCollection
A collection of multiple geometries. From geojson-pydantic, included here for reference.
Feature
Represents a GeoJSON feature object, from geojson-pydantic, included here for reference.
FeatureCollection
Represents a GeoJSON feature collection, from geojson-pydantic, included here for reference.
GeoJSON
The root object of a GeoJSON file.
Bases: RootModel
The root object of a GeoJSON file
Source code in src/microjson/model.py
170 171 172 173 | |
MicroJSON Extended Models
MicroFeature
A MicroJSON feature, which is an extension of a GeoJSON feature.
Bases: Feature
A MicroJSON feature, which is a GeoJSON feature with additional metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Optional[GeometryType]
|
Extended geometry supporting 3D types |
required |
multiscale
|
Optional[Multiscale]
|
The coordinate system of the feature |
required |
ref
|
Optional[Union[StrictStr, StrictInt]]
|
A reference to the parent feature |
required |
parentId
|
Optional[Union[StrictStr, StrictInt]]
|
A reference to the parent feature |
required |
featureClass
|
Optional[str]
|
The class of the feature |
required |
Source code in src/microjson/model.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
MicroFeatureCollection
A MicroJSON feature collection, which is an extension of a GeoJSON feature collection.
Bases: FeatureCollection
A MicroJSON feature collection, which is a GeoJSON feature collection with additional metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
List[MicroFeature]
|
Features with extended 3D geometry support |
required |
properties
|
Optional[Props]
|
The properties of the feature collection |
required |
id
|
Optional[Union[StrictStr, StrictInt]]
|
The ID of the feature coll. |
required |
Source code in src/microjson/model.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
MicroJSON
The root object of a MicroJSON file.