2323
2424DONOR_CLASS_LIST = [2 , 9 ]
2525RECIPIENT_CLASS_LIST = [2 , 3 , 9 , 17 ]
26- VIRTUAL_CLASS_TRANSLATION = {2 : 69 , 9 : 70 }
26+ DONOR_CLASS_TRANSLATION = {2 : 69 , 9 : 70 }
2727POINT_1 = {"x" : 1 , "y" : 2 , "z" : 3 , c .CLASSIFICATION_STR : 4 }
2828POINT_2 = {"x" : 5 , "y" : 6 , "z" : 7 , c .CLASSIFICATION_STR : 8 }
2929NEW_COLUMN = "virtual_column"
@@ -145,7 +145,7 @@ def test_get_complementary_points(donor_info_path, recipient_path, x, y, expecte
145145 overrides = [
146146 f"DONOR_CLASS_LIST={ DONOR_CLASS_LIST } " ,
147147 f"RECIPIENT_CLASS_LIST={ RECIPIENT_CLASS_LIST } " ,
148- f"+VIRTUAL_CLASS_TRANSLATION= { VIRTUAL_CLASS_TRANSLATION } " ,
148+ f"+DONOR_CLASS_TRANSLATION= { DONOR_CLASS_TRANSLATION } " ,
149149 "DONOR_USE_SYNTHETIC_POINTS=true" ,
150150 ],
151151 )
@@ -199,7 +199,7 @@ def test_get_complementary_points_2_more_fields(tmp_path_factory):
199199 overrides = [
200200 f"DONOR_CLASS_LIST={ DONOR_CLASS_LIST } " ,
201201 f"RECIPIENT_CLASS_LIST={ RECIPIENT_CLASS_LIST } " ,
202- f"+VIRTUAL_CLASS_TRANSLATION= { VIRTUAL_CLASS_TRANSLATION } " ,
202+ f"+DONOR_CLASS_TRANSLATION= { DONOR_CLASS_TRANSLATION } " ,
203203 "DONOR_USE_SYNTHETIC_POINTS=true" ,
204204 ],
205205 )
@@ -233,6 +233,9 @@ def test_append_points(tmp_path_factory):
233233 tmp_file_dir = tmp_path_factory .mktemp ("data" )
234234 tmp_file_name = "result.laz"
235235
236+ donor_class_list = [4 , 8 ]
237+ donor_class_translation = {4 : 44 , 8 : 88 }
238+
236239 with initialize (version_base = "1.2" , config_path = "../configs" ):
237240 config = compose (
238241 config_name = "configs_patchwork.yaml" ,
@@ -241,6 +244,8 @@ def test_append_points(tmp_path_factory):
241244 f"filepath.RECIPIENT_NAME={ RECIPIENT_TEST_NAME } " ,
242245 f"filepath.OUTPUT_DIR={ tmp_file_dir } " ,
243246 f"filepath.OUTPUT_NAME={ tmp_file_name } " ,
247+ f"DONOR_CLASS_LIST={ donor_class_list } " ,
248+ f"+DONOR_CLASS_TRANSLATION={ donor_class_translation } " ,
244249 ],
245250 )
246251
@@ -266,6 +271,12 @@ def test_append_points(tmp_path_factory):
266271 for point in las_recipient .points [:10 ]: # only 10 points, otherwise it takes too long
267272 assert point in las_output .points
268273
274+ # Original class of the first added points is 4, turned to 44 by DONOR_CLASS_TRANSLATION
275+ assert las_output .points [- 2 ][c .CLASSIFICATION_STR ] == 44
276+
277+ # Original class of the second added points is 8, turned to 88 by DONOR_CLASS_TRANSLATION
278+ assert las_output .points [- 1 ][c .CLASSIFICATION_STR ] == 88
279+
269280 # add 1 point
270281 extra_points = pd .DataFrame (
271282 data = [
@@ -282,7 +293,7 @@ def test_append_points(tmp_path_factory):
282293 extra_points = pd .DataFrame (data = {"x" : [], "y" : [], "z" : [], c .CLASSIFICATION_STR : []})
283294 append_points (config , extra_points )
284295
285- # assert a point has been added
296+ # assert no point has been added
286297 point_count = get_point_count (recipient_file_path )
287298 assert get_point_count (output_file ) == point_count
288299
@@ -369,7 +380,7 @@ def test_patchwork_default(tmp_path_factory, recipient_path, expected_nb_added_p
369380 f"filepath.OUTPUT_INDICES_MAP_NAME={ tmp_output_indices_map_name } " ,
370381 f"DONOR_CLASS_LIST={ DONOR_CLASS_LIST } " ,
371382 f"RECIPIENT_CLASS_LIST={ RECIPIENT_CLASS_LIST } " ,
372- f"+VIRTUAL_CLASS_TRANSLATION= { VIRTUAL_CLASS_TRANSLATION } " ,
383+ f"+DONOR_CLASS_TRANSLATION= { DONOR_CLASS_TRANSLATION } " ,
373384 "DONOR_USE_SYNTHETIC_POINTS=true" ,
374385 "NEW_COLUMN=null" ,
375386 ],
@@ -429,6 +440,7 @@ def test_patchwork_with_origin(tmp_path_factory, recipient_path, donor_use_synth
429440 tmp_file_dir = tmp_path_factory .mktemp ("data" )
430441 tmp_output_las_name = "result_patchwork.laz"
431442 tmp_output_indices_map_name = "result_patchwork_indices.tif"
443+ donor_class_translation = {2 : 2 , 9 : 9 }
432444
433445 with initialize (version_base = "1.2" , config_path = "../configs" ):
434446 config = compose (
@@ -443,6 +455,7 @@ def test_patchwork_with_origin(tmp_path_factory, recipient_path, donor_use_synth
443455 f"filepath.OUTPUT_INDICES_MAP_DIR={ tmp_file_dir } " ,
444456 f"filepath.OUTPUT_INDICES_MAP_NAME={ tmp_output_indices_map_name } " ,
445457 f"DONOR_CLASS_LIST={ DONOR_CLASS_LIST } " ,
458+ f"+DONOR_CLASS_TRANSLATION={ donor_class_translation } " ,
446459 f"RECIPIENT_CLASS_LIST={ RECIPIENT_CLASS_LIST } " ,
447460 f"DONOR_USE_SYNTHETIC_POINTS={ donor_use_synthetic_points } " ,
448461 "NEW_COLUMN='Origin'" ,
@@ -508,6 +521,7 @@ def test_patchwork_with_mount_points(tmp_path_factory, input_shp_path, recipient
508521 tmp_file_dir = tmp_path_factory .mktemp ("data" )
509522 tmp_output_las_name = "result_patchwork.laz"
510523 tmp_output_indices_map_name = "result_patchwork_indices.tif"
524+ donor_class_translation = {2 : 11 , 9 : 11 }
511525
512526 with initialize (version_base = "1.2" , config_path = "configs" ): # Use configs dir from test directory
513527 config = compose (
@@ -522,6 +536,7 @@ def test_patchwork_with_mount_points(tmp_path_factory, input_shp_path, recipient
522536 f"filepath.OUTPUT_INDICES_MAP_DIR={ tmp_file_dir } " ,
523537 f"filepath.OUTPUT_INDICES_MAP_NAME={ tmp_output_indices_map_name } " ,
524538 f"DONOR_CLASS_LIST={ DONOR_CLASS_LIST } " ,
539+ f"+DONOR_CLASS_TRANSLATION={ donor_class_translation } " ,
525540 f"RECIPIENT_CLASS_LIST={ RECIPIENT_CLASS_LIST } " ,
526541 "NEW_COLUMN='Origin'" ,
527542 ],
@@ -543,3 +558,6 @@ def test_patchwork_with_mount_points(tmp_path_factory, input_shp_path, recipient
543558 assert len (output_points ) == len (recipient_points ) + expected_nb_added_points
544559 assert np .sum (output_points .Origin == 0 ) == len (recipient_points )
545560 assert np .sum (output_points .Origin == 1 ) == expected_nb_added_points
561+
562+ assert np .all (output_points .classification [output_points .Origin == 1 ] == 11 )
563+ assert not np .any (output_points .classification [output_points .Origin == 0 ] == 11 )
0 commit comments