|
1 | 1 | """ |
2 | 2 | This is the parser service. |
3 | 3 | """ |
4 | | -import logging |
5 | 4 | from io import BytesIO |
6 | 5 | from typing import List, Dict, Optional, Any |
7 | 6 | import struct |
@@ -91,7 +90,7 @@ def __init__(self): |
91 | 90 | self.adminblock_unpacker = self.get_struct_unpacker(self.admin_block_specification, self.istart, self.iwidth) |
92 | 91 | self.field_adminblock_indices = range(len(self.admin_block_specification)) |
93 | 92 | self.useEastNorthOrderAsDefault = True |
94 | | - self.file_srid = None |
| 93 | + self.file_srid: Optional[int] = None |
95 | 94 |
|
96 | 95 | def tema_code_to_method(self, code: str) -> Optional[str]: |
97 | 96 |
|
@@ -130,9 +129,6 @@ def parse(self, filepath_or_buffer: Any, result_srid: int, file_srid: Optional[i |
130 | 129 | is not passed or is `None`, then the coordinate system specified in the KOF file is used. If neither |
131 | 130 | `file_srid` nor any coordinate system is specified in the KOF file, then the coordinate system is assumed to be |
132 | 131 | 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. |
136 | 132 | """ |
137 | 133 | if self._is_file_like(filepath_or_buffer): |
138 | 134 | f = filepath_or_buffer |
@@ -164,9 +160,10 @@ def _read_kof(self, file: BytesIO, result_srid: int, file_srid: Optional[int]) - |
164 | 160 | if not self.useEastNorthOrderAsDefault: |
165 | 161 | line_data["x"], line_data["y"] = line_data["y"], line_data["x"] |
166 | 162 |
|
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 | + ) |
170 | 167 |
|
171 | 168 | locations[line_data["ID"]].point_easting = line_data["x"] |
172 | 169 | locations[line_data["ID"]].point_northing = line_data["y"] |
|
0 commit comments