Skip to content

Commit a5bc2e4

Browse files
fix: proper easting/northing notation
1 parent 644c442 commit a5bc2e4

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

kmm/positions/geodetic.py

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

44
from kmm.positions.positions import Positions
55

6-
76
tm = projections.make_transverse_mercator("SWEREF_99_TM")
87

98

@@ -12,16 +11,17 @@ def geodetic(positions: Positions):
1211
if len(dataframe) == 0:
1312
dataframe = dataframe.assign(longitude=[], latitude=[])
1413
else:
15-
latitude, longitude = zip(*[
16-
tm.grid_to_geodetic(coordinate.sweref99_tm_x, coordinate.sweref99_tm_y)
17-
for coordinate in dataframe[["sweref99_tm_x", "sweref99_tm_y"]].itertuples()
18-
])
14+
latitude, longitude = zip(
15+
*[
16+
tm.grid_to_geodetic(coordinate.northing, coordinate.easting)
17+
for coordinate in dataframe[["northing", "easting"]].itertuples()
18+
]
19+
)
1920
dataframe = dataframe.assign(longitude=longitude, latitude=latitude)
2021
return positions.replace(dataframe=dataframe)
2122

2223

2324
def test_geodetic():
24-
2525
positions = Positions.from_path("tests/ascending_B.kmm2")
2626
df = geodetic(positions).dataframe
2727
assert ((df["latitude"] < 68) & (df["latitude"] > 55)).all()

kmm/positions/read_kmm.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from pathlib import Path
2+
13
import numpy as np
24
import pandas as pd
3-
from pathlib import Path
45
from pydantic import validate_arguments
56

67

@@ -22,8 +23,8 @@ def read_kmm(path: Path):
2223
"3?",
2324
"4?",
2425
"5?",
25-
"sweref99_tm_x",
26-
"sweref99_tm_y",
26+
"northing",
27+
"easting",
2728
"8?",
2829
"9?",
2930
],
@@ -32,8 +33,8 @@ def read_kmm(path: Path):
3233
kilometer=np.int32,
3334
meter=np.int32,
3435
track_lane=str,
35-
sweref99_tm_x=np.float32,
36-
sweref99_tm_y=np.float32,
36+
northing=np.float32,
37+
easting=np.float32,
3738
),
3839
)
3940
except Exception as e:

kmm/positions/read_kmm2.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"2?",
2020
"3?",
2121
"4?",
22-
"sweref99_tm_x",
23-
"sweref99_tm_y",
22+
"northing",
23+
"easting",
2424
"contact_wire_material",
2525
"rail_model",
2626
"sliper_model",
@@ -40,14 +40,13 @@
4040
kilometer=np.int32,
4141
meter=np.int32,
4242
track_lane=str,
43-
sweref99_tm_x=np.float32,
44-
sweref99_tm_y=np.float32,
43+
northing=np.float32,
44+
easting=np.float32,
4545
)
4646

4747

4848
@validate_arguments
4949
def read_kmm2(path: Path):
50-
5150
skiprows = [
5251
index
5352
for index, line in enumerate(path.read_text(encoding="latin1").splitlines())

0 commit comments

Comments
 (0)