Change Log¶
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
Note: Minor version 0.X.0
update might break the API, It's recommended to pin geojson-pydantic to minor version: geojson-pydantic>=0.6,<0.7
1.1.2 - 2024-10-22¶
- relax
bbox
validation and allow antimeridian crossing bboxes
1.1.1 - 2024-08-29¶
- add python 3.12 support
- switch to
flit-core
for packaging build backend
1.1.0 - 2024-05-10¶
Added¶
- Add Position2D and Position3D of type NamedTuple (author @impocode, developmentseed/geojson-pydantic!161)
1.0.2 - 2024-01-16¶
Fixed¶
- Temporary workaround for surfacing model attributes in FastAPI application (author @markus-work, developmentseed/geojson-pydantic!153)
1.0.1 - 2023-10-04¶
Fixed¶
- Model serialization when using include/exclude (ref: developmentseed/geojson-pydantic!148)
1.0.0 - 2023-07-24¶
Fixed¶
- reduce validation error message verbosity when discriminating Geometry types
- MultiPoint WKT now includes parentheses around each Point
Added¶
- more tests for
GeometryCollection
warnings
Changed¶
-
update pydantic requirement to
~=2.0
-
update pydantic
FeatureCollection
generic model to allow named features in the generated schemas.# before FeatureCollection[Geometry, Properties] # now FeatureCollection[Feature[Geometry, Properties]]
-
raise
ValueError
ingeometries.parse_geometry_obj
instead ofValidationError
# before parse_geometry_obj({"type": "This type", "obviously": "doesn't exist"}) >> ValidationError # now parse_geometry_obj({"type": "This type", "obviously": "doesn't exist"}) >> ValueError("Unknown type: This type")
-
update JSON serializer to exclude null
bbox
andid
# before Point(type="Point", coordinates=[0, 0]).json() >> '{"type":"Point","coordinates":[0.0,0.0],"bbox":null}' # now Point(type="Point", coordinates=[0, 0]).model_dump_json() >> '{"type":"Point","coordinates":[0.0,0.0]}'
-
delete
geojson_pydantic.geo_interface.GeoInterfaceMixin
and replaced bygeojson_pydantic.base._GeoJsonBase
class -
delete
geojson_pydantic.types.validate_bbox
0.6.3 - 2023-07-02¶
- limit pydantic requirement to
~=1.0
0.6.2 - 2023-05-16¶
Added¶
- Additional bbox validation (author @eseglem, developmentseed/geojson-pydantic!122)
0.6.1 - 2023-05-12¶
Fixed¶
- Fix issue with null bbox validation (author @bmschmidt, developmentseed/geojson-pydantic!119)
0.6.0 - 2023-05-09¶
No change since 0.6.0a0
[0.6.0a0] - 2023-04-04¶
Added¶
- Validate order of bounding box values. (author @moradology, developmentseed/geojson-pydantic!114)
-
Enforce required keys and avoid defaults. This aim to follow the geojson specification to the letter.
# Before Feature(geometry=Point(coordinates=(0,0))) # Now Feature( type="Feature", geometry=Point( type="Point", coordinates=(0,0) ), properties=None, )
-
Add has_z function to Geometries (author @eseglem, developmentseed/geojson-pydantic!103)
- Add optional bbox to geometries. (author @eseglem, developmentseed/geojson-pydantic!108)
- Add support for nested GeometryCollection and a corresponding warning. (author @eseglem, developmentseed/geojson-pydantic!111)
Changed¶
- Refactor and simplify WKT construction (author @eseglem, developmentseed/geojson-pydantic!97)
- Support empty geometry coordinates (author @eseglem, developmentseed/geojson-pydantic!100)
- Refactored
__geo_interface__
to be a Mixin which returnsself.dict
(author @eseglem, developmentseed/geojson-pydantic!105) - GeometryCollection containing a single geometry or geometries of only one type will now produce a warning. (author @eseglem, developmentseed/geojson-pydantic!111)
Fixed¶
- Do not validates arbitrary dictionaries. Make
Type
a mandatory key for objects (author @vincentsarago, developmentseed/geojson-pydantic!94) - Add Geometry discriminator when parsing geometry objects (author @eseglem, developmentseed/geojson-pydantic!101)
- Mixed Dimensionality WKTs (make sure the coordinates are either all 2D or 3D) (author @eseglem, developmentseed/geojson-pydantic!107)
- Allow Feature's id to be either a String or a Number (author @vincentsarago, developmentseed/geojson-pydantic!91)
Removed¶
- Python 3.7 support (author @vincentsarago, developmentseed/geojson-pydantic!94)
- Unused
LinearRing
Model (author @eseglem, developmentseed/geojson-pydantic!106)
0.5.0 - 2022-12-16¶
Added¶
- python 3.11 support
Fixed¶
- Derive WKT type from Geometry's type instead of class name (author @eseglem, developmentseed/geojson-pydantic!81)
Changed¶
- Replace
NumType
withfloat
throughout (author @eseglem, developmentseed/geojson-pydantic!83) __geo_interface__
definition to not use pydanticBaseModel.dict()
method and better match the specification- Adjusted mypy configuration and updated type definitions to satisfy all rules (author @eseglem, developmentseed/geojson-pydantic!87)
- Updated pre-commit config to run mypy on the whole library instead of individual changed files.
- Defaults are more explicit. This keeps pyright from thinking they are required.
Removed¶
- Remove
validate
classmethods used to implicitly load json strings (author @eseglem, developmentseed/geojson-pydantic!88)
0.4.3 - 2022-07-18¶
Fixed¶
- The bbox key should not be in a
__geo_interface__
object if the bbox is None (author @yellowcap, developmentseed/geojson-pydantic!77)
0.4.2 - 2022-06-13¶
Added¶
GeometryCollection
as optional input to geometry field inFeature
(author @davidraleigh, developmentseed/geojson-pydantic!72)
0.4.1 - 2022-06-10¶
Added¶
-
Geometry
andGeometryCollection
validation from dict or string (author @Vikka, developmentseed/geojson-pydantic!69)Point.validate('{"coordinates": [1.0, 2.0], "type": "Point"}') >> Point(coordinates=(1.0, 2.0), type='Point')
-
Feature
andFeatureCollection
validation from dict or stringFeatureCollection.validate('{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"coordinates": [1.0, 2.0], "type": "Point"}}]}') >> FeatureCollection(type='FeatureCollection', features=[Feature(type='Feature', geometry=Point(coordinates=(1.0, 2.0), type='Point'), properties=None, id=None, bbox=None)], bbox=None)
0.4.0 - 2022-06-03¶
Added¶
-
.wkt
property for Geometry objectfrom geojson_pydantic.geometries import Point Point(coordinates=(1, 2)).wkt >> 'POINT (1.0 2.0)'
-
.exterior
and.interiors
properties forgeojson_pydantic.geometries.Polygon
object.from geojson_pydantic.geometries import Polygon polygon = Polygon( coordinates=[ [(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)], [(2, 2), (2, 4), (4, 4), (4, 2), (2, 2)], ] ) polygon.exterior >> [(0.0, 0.0), (0.0, 10.0), (10.0, 10.0), (10.0, 0.0), (0.0, 0.0)] list(polygon.interiors) >> [[(2.0, 2.0), (2.0, 4.0), (4.0, 4.0), (4.0, 2.0), (2.0, 2.0)]]
-
__geo_interface__
togeojson_pydantic.geometries.GeometryCollection
object __geo_interface__
togeojson_pydantic.feature.Feature
andgeojson_pydantic.feature.FeatureCollection
objectgeojson_pydantic.__all__
to declaring public objects (author @farridav, developmentseed/geojson-pydantic!52)
Changed¶
- switch to
pyproject.toml
- rename
geojson_pydantic.version
togeojson_pydantic.__version__
Fixed¶
- changelog compare links
0.3.4 - 2022-04-28¶
- Fix optional geometry and bbox fields on
Feature
; allowing users to pass inNone
or even omit either field (author @moradology, developmentseed/geojson-pydantic!56) - Fix
Polygon.from_bounds
to respect geojson specification and return counterclockwise linear ring (author @jmfee-usgs, developmentseed/geojson-pydantic!49)
0.3.3 - 2022-03-04¶
- Follow geojson specification and make feature geometry optional (author @yellowcap, developmentseed/geojson-pydantic!47)
from geojson_pydantic import Feature # Before feature = Feature(type="Feature", geometry=None, properties={}) >> ValidationError: 1 validation error for Feature geometry none is not an allowed value (type=type_error.none.not_allowed) # Now feature = Feature(type="Feature", geometry=None, properties={}) assert feature.geometry is None
0.3.2 - 2022-02-21¶
- fix
parse_geometry_obj
potential bug (author @geospatial-jeff, developmentseed/geojson-pydantic!45) - improve type definition (and validation) for geometry coordinate arrays (author @geospatial-jeff, developmentseed/geojson-pydantic!44)
0.3.1 - 2021-08-04¶
Added¶
Polygon.from_bounds
class method to create a Polygon geometry from a bounding box.from geojson_pydantic import Polygon print(Polygon.from_bounds((1, 2, 3, 4)).dict(exclude_none=True)) >> {'coordinates': [[(1.0, 2.0), (1.0, 4.0), (3.0, 4.0), (3.0, 2.0), (1.0, 2.0)]], 'type': 'Polygon'}
Fixed¶
- Added validation for Polygons with zero size.
0.3.0 - 2021-05-25¶
Added¶
-
Feature
andFeatureCollection
model generics to support custom geometry and/or properties validation (author @iwpnd, developmentseed/geojson-pydantic!29)from pydantic import BaseModel from geojson_pydantic.features import Feature from geojson_pydantic.geometries import Polygon class MyFeatureProperties(BaseModel): name: str value: int feature = Feature[Polygon, MyFeatureProperties]( **{ "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [13.38272,52.46385], [13.42786,52.46385], [13.42786,52.48445], [13.38272,52.48445], [13.38272,52.46385] ] ] }, "properties": { "name": "test", "value": 1 } } )
-
Top level export (developmentseed/geojson-pydantic!34)
# before from geojson_pydantic.features import Feature, FeatureCollection from geojson_pydantic.geometries import Polygon # now from geojson_pydantic import Feature, Polygon
Removed¶
- Drop python 3.6 support
- Renamed
utils.py
totypes.py
- Removed
Coordinate
type ingeojson_pydantic.features
(replaced byPosition
)
0.2.3 - 2021-05-05¶
Fixed¶
- incorrect version number set in
__init__.py
0.2.2 - 2020-12-29¶
Added¶
- Made collections iterable (#12)
- Added
parse_geometry_obj
function (#9)
0.2.1 - 2020-08-07¶
Although the type file was added in 0.2.0
it wasn't included in the distributed package. Use this version 0.2.1
for type annotations.
Fixed¶
- Correct package type information files
0.2.0 - 2020-08-06¶
Added¶
- Added documentation on locally running tests (#3)
- Publish type information (#6)
Changed¶
- Removed geojson dependency (#4)
Fixed¶
- Include MultiPoint as a valid geometry for a Feature (#1)
0.1.0 - 2020-05-21¶
Added¶
- Initial Release