@@ -212,8 +212,11 @@ def test_build_pmtiles_creates_correct_shapes_index(self):
212212 shapes_path = os .path .join (temp_dir , "shapes.txt" )
213213 with open (shapes_path , "w" , encoding = "utf-8" ) as f :
214214 f .write ("shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence\n " )
215- f .write ("s1,45.0,-73.0,1\n " )
216- f .write ("s1,45.1,-73.1,2\n " )
215+ # Also test the reordering of shapes lines. In the test file we put sequence number 10 before 8
216+ # It also tests the reordering works fine if there are gaps in the sequence numbers
217+ f .write ("s1,45.1,-73.1,10\n " )
218+ f .write ("s1,45.0,-73.0,8\n " )
219+ # f.write("s1,45.1,-73.1,2\n")
217220 f .write ("s2,46.0,-74.0,1\n " )
218221
219222 index = self .builder ._create_shapes_index ()
@@ -225,7 +228,12 @@ def test_build_pmtiles_creates_correct_shapes_index(self):
225228 self .assertIn ("s2" , index .coordinates_arrays )
226229 self .assertEqual (len (index .coordinates_arrays ["s1" ]), 3 )
227230 self .assertEqual (len (index .coordinates_arrays ["s1" ][0 ]), 2 )
228-
231+ self .assertEqual (len (index .coordinates_arrays ["s2" ][0 ]), 1 )
232+ # Assert that sequence numbers for s1 are sorted
233+ self .assertListEqual (list (index .coordinates_arrays ["s1" ][2 ]), [8 , 10 ])
234+ # Assert that lon and lat for s1 are reordered to match sequence
235+ self .assertListEqual (list (index .coordinates_arrays ["s1" ][0 ]), [- 73.0 , - 73.1 ])
236+ self .assertListEqual (list (index .coordinates_arrays ["s1" ][1 ]), [45.0 , 45.1 ])
229237 self .assertEqual (len (index .coordinates_arrays ["s2" ][0 ]), 1 )
230238
231239 def test_create_routes_geojson (self ):
0 commit comments