Skip to content

Commit eabaabf

Browse files
committed
Use the new ngi-projector version 0.0.3 with new Projector.transform() method signature.
1 parent a7ddb4e commit eabaabf

File tree

6 files changed

+103
-16
lines changed

6 files changed

+103
-16
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ _2022-03-02_
55

66
Add
77

8+
- Use new ngi-projector version 0.0.3.
89
- Add transformations.
910
- Support for more methods. Complete list:
1011
- RO: 2251

poetry.lock

Lines changed: 95 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ secondary = true
2828
[tool.poetry.dependencies]
2929
python = "^3.9"
3030
pydantic = "^1.9.0"
31-
ngi-projector = "0.0.2.dev8131"
31+
ngi-projector = "^0.0.3"
3232

3333
[tool.poetry.dev-dependencies]
3434
black = "*"

src/ngi_kof_parser/parser.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
This is the parser service.
33
"""
4-
import logging
54
from io import BytesIO
65
from typing import List, Dict, Optional, Any
76
import struct
@@ -91,7 +90,7 @@ def __init__(self):
9190
self.adminblock_unpacker = self.get_struct_unpacker(self.admin_block_specification, self.istart, self.iwidth)
9291
self.field_adminblock_indices = range(len(self.admin_block_specification))
9392
self.useEastNorthOrderAsDefault = True
94-
self.file_srid = None
93+
self.file_srid: Optional[int] = None
9594

9695
def tema_code_to_method(self, code: str) -> Optional[str]:
9796

@@ -130,9 +129,6 @@ def parse(self, filepath_or_buffer: Any, result_srid: int, file_srid: Optional[i
130129
is not passed or is `None`, then the coordinate system specified in the KOF file is used. If neither
131130
`file_srid` nor any coordinate system is specified in the KOF file, then the coordinate system is assumed to be
132131
in the `result_srid` coordinate system and no transformations are done.
133-
134-
For now result_srid and file_srid must be equal and no transformations are done. This limitation will change in
135-
the future, when this package has the ability to do transformations.
136132
"""
137133
if self._is_file_like(filepath_or_buffer):
138134
f = filepath_or_buffer
@@ -164,9 +160,10 @@ def _read_kof(self, file: BytesIO, result_srid: int, file_srid: Optional[int]) -
164160
if not self.useEastNorthOrderAsDefault:
165161
line_data["x"], line_data["y"] = line_data["y"], line_data["x"]
166162

167-
if result_srid != self.file_srid:
168-
transformer = projector.get_transformer(f"{self.file_srid}-{result_srid}")
169-
line_data["x"], line_data["y"] = projector.transform(transformer, line_data["x"], line_data["y"])
163+
if self.file_srid and result_srid != self.file_srid:
164+
line_data["x"], line_data["y"] = projector.transform(
165+
self.file_srid, result_srid, line_data["x"], line_data["y"]
166+
)
170167

171168
locations[line_data["ID"]].point_easting = line_data["x"]
172169
locations[line_data["ID"]].point_northing = line_data["y"]

src/ngi_kof_parser/py.typed

Whitespace-only changes.

tests/test_parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_parse(self):
1515
assert location.srid
1616

1717
@pytest.mark.parametrize(
18-
"file_name, ex_e, ex_n, ex_z,kof_srid,proj_srid",
18+
"file_name, ex_e, ex_n, ex_z, kof_srid, proj_srid",
1919
[
2020
# No transformations
2121
("tests/data/UTM32_EN.kof", 594137.802, 6589107.923, 0.000, 25832, 25832),

0 commit comments

Comments
 (0)