Skip to content

Commit 84549ba

Browse files
Merge pull request #1 from geopython/v32-improvements
Improvements to v3.2 parsing
2 parents 447e125 + acc698c commit 84549ba

File tree

5 files changed

+1131
-80
lines changed

5 files changed

+1131
-80
lines changed

pygml/basics.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
# ------------------------------------------------------------------------------
2727

2828

29-
from typing import Callable, List
29+
from typing import Callable
3030

31-
# Definition of a coordinate list
32-
Coordinate = List[float]
33-
Coordinates = List[Coordinate]
31+
from .types import Coordinates, Coordinate
3432

3533

3634
def _make_number_parser(decimal: str) -> Callable[[str], float]:

pygml/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from .pre_v32 import parse_pre_v32
3333
from .v32 import parse_v32
3434
from .v33 import parse_v33_ce
35-
from .geometry import Geometry
35+
from .types import Geometry
3636

3737

3838
def parse(source: Union[etree._Element, str]) -> Geometry:

pygml/geometry.py renamed to pygml/types.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,30 @@
2727

2828

2929
from dataclasses import dataclass
30+
from typing import List, Optional, Tuple, Union
31+
32+
try:
33+
from typing import TypedDict
34+
35+
class GeomDict(TypedDict, total=True):
36+
type: str
37+
coordinates: Union[Tuple, List]
38+
crs: Optional[dict]
39+
40+
except ImportError:
41+
GeomDict = dict
42+
43+
# Definition of a coordinate list
44+
Coordinate = List[float]
45+
Coordinates = List[Coordinate]
3046

3147

3248
@dataclass(frozen=True)
3349
class Geometry:
3450
""" Simple container class to hold a geometry and expose it via the
3551
`__geo_interface__`
3652
"""
37-
geometry: dict
53+
geometry: GeomDict
3854

3955
@property
4056
def __geo_interface__(self):

0 commit comments

Comments
 (0)