@@ -70,25 +70,24 @@ def __init__(self):
7070 self .file_srid : Optional [int ] = None
7171
7272 def tema_code_to_method (self , code : str ) -> Optional [str ]:
73-
7473 if not code or code not in self .tema_codes_mapping .keys ():
7574 return None
7675
7776 return self .tema_codes_mapping [code ].name
7877
7978 def map_line_to_coordinate_block (self , line : str , result_srid : int , file_srid : Optional [int ]) -> Location :
80- resolved_location = Location ()
8179 template_coordinate_block : str = "-05 PPPPPPPPPP KKKKKKKK XXXXXXXX.XXX YYYYYYY.YYY ZZZZ.ZZZ Bk MMMMMMM"
8280 parsed_line = line [0 : len (template_coordinate_block )]
8381
84- resolved_location .name = parsed_line [4 :15 ].strip ()
85- resolved_location .srid = result_srid
86- resolved_location .point_easting = float (parsed_line [24 :37 ].strip ())
87- resolved_location .point_northing = float (parsed_line [37 :49 ].strip ())
88- resolved_location .point_z = float (parsed_line [49 :58 ].strip ()) if parsed_line [49 :58 ].strip () else None
89- new_method = self .tema_code_to_method (parsed_line [15 :24 ].strip ())
90- if resolved_location .methods is not None :
91- resolved_location .methods += [new_method ] if new_method is not None else []
82+ resolved_location = Location (
83+ name = parsed_line [4 :15 ].strip (),
84+ srid = result_srid ,
85+ point_easting = float (parsed_line [24 :37 ].strip ()),
86+ point_northing = float (parsed_line [37 :49 ].strip ()),
87+ point_z = float (parsed_line [49 :58 ].strip ()) if parsed_line [49 :58 ].strip () else None ,
88+ )
89+ if new_method := self .tema_code_to_method (parsed_line [15 :24 ].strip ()):
90+ resolved_location .methods .append (new_method )
9291
9392 return resolved_location
9493
0 commit comments