Skip to content

Commit c36c7ac

Browse files
Merge pull request #115 from developmentseed/ignoreType
Ignore type
2 parents a383467 + 3d10fb6 commit c36c7ac

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [0.6.0] - TBD
8+
## [0.6.0a0] - 2023-04-04
99

1010
### Added
1111

@@ -29,14 +29,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2929

3030
- Add has_z function to Geometries (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/103)
3131
- Add optional bbox to geometries. (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/108)
32-
- Add support for nested GeometryCollection and a corresponding warning. (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/111)
32+
- Add support for nested GeometryCollection and a corresponding warning. (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/111)
3333

3434
### Changed
3535

3636
- Refactor and simplify WKT construction (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/97)
3737
- Support empty geometry coordinates (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/100)
3838
- Refactored `__geo_interface__` to be a Mixin which returns `self.dict` (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/105)
39-
- GeometryCollection containing a single geometry or geometries of only one type will now produce a warning. (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/111)
39+
- GeometryCollection containing a single geometry or geometries of only one type will now produce a warning. (author @eseglem, https://github.com/developmentseed/geojson-pydantic/pull/111)
4040

4141
### Fixed
4242

@@ -268,7 +268,8 @@ Although the type file was added in `0.2.0` it wasn't included in the distribute
268268
### Added
269269
- Initial Release
270270

271-
[unreleased]: https://github.com/developmentseed/geojson-pydantic/compare/0.5.0...HEAD
271+
[unreleased]: https://github.com/developmentseed/geojson-pydantic/compare/0.6.0a...HEAD
272+
[0.6.0a]: https://github.com/developmentseed/geojson-pydantic/compare/0.5.0...0.6.0a
272273
[0.5.0]: https://github.com/developmentseed/geojson-pydantic/compare/0.4.3...0.5.0
273274
[0.4.3]: https://github.com/developmentseed/geojson-pydantic/compare/0.4.2...0.4.3
274275
[0.4.2]: https://github.com/developmentseed/geojson-pydantic/compare/0.4.1...0.4.2

geojson_pydantic/geometries.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import abc
55
import warnings
6-
from typing import Any, Iterator, List, Literal, Optional, Protocol, Union
6+
from typing import Any, Iterator, List, Literal, Optional, Union
77

88
from pydantic import BaseModel, Field, ValidationError, validator
99
from pydantic.error_wrappers import ErrorWrapper
@@ -72,19 +72,17 @@ def _polygons_wkt_coordinates(
7272
)
7373

7474

75-
class _WktCallable(Protocol):
76-
def __call__(self, coordinates: Any, force_z: bool) -> str:
77-
...
78-
79-
8075
class _GeometryBase(BaseModel, abc.ABC, GeoInterfaceMixin):
8176
"""Base class for geometry models"""
8277

8378
type: str
8479
coordinates: Any
8580
bbox: Optional[BBox] = None
8681

87-
__wkt_coordinates__: _WktCallable
82+
@abc.abstractmethod
83+
def __wkt_coordinates__(self, coordinates: Any, force_z: bool) -> str:
84+
"""return WKT coordinates."""
85+
...
8886

8987
@property
9088
@abc.abstractmethod
@@ -116,7 +114,9 @@ class Point(_GeometryBase):
116114
type: Literal["Point"]
117115
coordinates: Position
118116

119-
__wkt_coordinates__ = staticmethod(_position_wkt_coordinates)
117+
def __wkt_coordinates__(self, coordinates: Any, force_z: bool) -> str:
118+
"""return WKT coordinates."""
119+
return _position_wkt_coordinates(coordinates, force_z)
120120

121121
@property
122122
def has_z(self) -> bool:
@@ -130,7 +130,9 @@ class MultiPoint(_GeometryBase):
130130
type: Literal["MultiPoint"]
131131
coordinates: MultiPointCoords
132132

133-
__wkt_coordinates__ = staticmethod(_position_list_wkt_coordinates)
133+
def __wkt_coordinates__(self, coordinates: Any, force_z: bool) -> str:
134+
"""return WKT coordinates."""
135+
return _position_list_wkt_coordinates(coordinates, force_z)
134136

135137
@property
136138
def has_z(self) -> bool:
@@ -144,7 +146,9 @@ class LineString(_GeometryBase):
144146
type: Literal["LineString"]
145147
coordinates: LineStringCoords
146148

147-
__wkt_coordinates__ = staticmethod(_position_list_wkt_coordinates)
149+
def __wkt_coordinates__(self, coordinates: Any, force_z: bool) -> str:
150+
"""return WKT coordinates."""
151+
return _position_list_wkt_coordinates(coordinates, force_z)
148152

149153
@property
150154
def has_z(self) -> bool:
@@ -158,7 +162,9 @@ class MultiLineString(_GeometryBase):
158162
type: Literal["MultiLineString"]
159163
coordinates: MultiLineStringCoords
160164

161-
__wkt_coordinates__ = staticmethod(_lines_wtk_coordinates)
165+
def __wkt_coordinates__(self, coordinates: Any, force_z: bool) -> str:
166+
"""return WKT coordinates."""
167+
return _lines_wtk_coordinates(coordinates, force_z)
162168

163169
@property
164170
def has_z(self) -> bool:
@@ -172,7 +178,9 @@ class Polygon(_GeometryBase):
172178
type: Literal["Polygon"]
173179
coordinates: PolygonCoords
174180

175-
__wkt_coordinates__ = staticmethod(_lines_wtk_coordinates)
181+
def __wkt_coordinates__(self, coordinates: Any, force_z: bool) -> str:
182+
"""return WKT coordinates."""
183+
return _lines_wtk_coordinates(coordinates, force_z)
176184

177185
@validator("coordinates")
178186
def check_closure(cls, coordinates: List) -> List:
@@ -218,7 +226,9 @@ class MultiPolygon(_GeometryBase):
218226
type: Literal["MultiPolygon"]
219227
coordinates: MultiPolygonCoords
220228

221-
__wkt_coordinates__ = staticmethod(_polygons_wkt_coordinates)
229+
def __wkt_coordinates__(self, coordinates: Any, force_z: bool) -> str:
230+
"""return WKT coordinates."""
231+
return _polygons_wkt_coordinates(coordinates, force_z)
222232

223233
@property
224234
def has_z(self) -> bool:

0 commit comments

Comments
 (0)