File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 3
3
4
4
from kmm .positions .positions import Positions
5
5
6
-
7
6
tm = projections .make_transverse_mercator ("SWEREF_99_TM" )
8
7
9
8
@@ -12,16 +11,17 @@ def geodetic(positions: Positions):
12
11
if len (dataframe ) == 0 :
13
12
dataframe = dataframe .assign (longitude = [], latitude = [])
14
13
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
+ )
19
20
dataframe = dataframe .assign (longitude = longitude , latitude = latitude )
20
21
return positions .replace (dataframe = dataframe )
21
22
22
23
23
24
def test_geodetic ():
24
-
25
25
positions = Positions .from_path ("tests/ascending_B.kmm2" )
26
26
df = geodetic (positions ).dataframe
27
27
assert ((df ["latitude" ] < 68 ) & (df ["latitude" ] > 55 )).all ()
Original file line number Diff line number Diff line change
1
+ from pathlib import Path
2
+
1
3
import numpy as np
2
4
import pandas as pd
3
- from pathlib import Path
4
5
from pydantic import validate_arguments
5
6
6
7
@@ -22,8 +23,8 @@ def read_kmm(path: Path):
22
23
"3?" ,
23
24
"4?" ,
24
25
"5?" ,
25
- "sweref99_tm_x " ,
26
- "sweref99_tm_y " ,
26
+ "northing " ,
27
+ "easting " ,
27
28
"8?" ,
28
29
"9?" ,
29
30
],
@@ -32,8 +33,8 @@ def read_kmm(path: Path):
32
33
kilometer = np .int32 ,
33
34
meter = np .int32 ,
34
35
track_lane = str ,
35
- sweref99_tm_x = np .float32 ,
36
- sweref99_tm_y = np .float32 ,
36
+ northing = np .float32 ,
37
+ easting = np .float32 ,
37
38
),
38
39
)
39
40
except Exception as e :
Original file line number Diff line number Diff line change 19
19
"2?" ,
20
20
"3?" ,
21
21
"4?" ,
22
- "sweref99_tm_x " ,
23
- "sweref99_tm_y " ,
22
+ "northing " ,
23
+ "easting " ,
24
24
"contact_wire_material" ,
25
25
"rail_model" ,
26
26
"sliper_model" ,
40
40
kilometer = np .int32 ,
41
41
meter = np .int32 ,
42
42
track_lane = str ,
43
- sweref99_tm_x = np .float32 ,
44
- sweref99_tm_y = np .float32 ,
43
+ northing = np .float32 ,
44
+ easting = np .float32 ,
45
45
)
46
46
47
47
48
48
@validate_arguments
49
49
def read_kmm2 (path : Path ):
50
-
51
50
skiprows = [
52
51
index
53
52
for index , line in enumerate (path .read_text (encoding = "latin1" ).splitlines ())
You can’t perform that action at this time.
0 commit comments