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
27 28 29 30 |
|
MicroFeature
Bases: Feature
A MicroJSON feature, which is a GeoJSON feature with additional metadata
Parameters:
Name | Type | Description | Default |
---|---|---|---|
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
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
MicroFeatureCollection
Bases: FeatureCollection
A MicroJSON feature collection, which is a GeoJSON feature collection with additional metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
MicroJSON
Bases: RootModel
The root object of a MicroJSON file
Source code in src/microjson/model.py
75 76 77 78 79 80 |
|
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
27 28 29 30 |
|
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 |
---|---|---|---|
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
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
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 |
---|---|---|---|
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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
MicroJSON
The root object of a MicroJSON file.