66from django .test import TestCase
77
88from geotrek .altimetry .helpers import AltimetryHelper
9+ from geotrek .common .tests .utils import LineStringInBounds
910from geotrek .core .models import Path , Topology
1011from geotrek .core .tests .factories import TopologyFactory
1112
@@ -338,7 +339,7 @@ def setUpTestData(cls):
338339 # Create a simple fake DEM
339340 with connection .cursor () as cur :
340341 cur .execute (
341- "INSERT INTO altimetry_dem (rast) VALUES (ST_MakeEmptyRaster(100, 125, 0, 125 , 25, -25, 0, 0, %s))" ,
342+ "INSERT INTO altimetry_dem (rast) VALUES (ST_MakeEmptyRaster(100, 125, 489353.59, 6587677.2 , 25, -25, 0, 0, %s))" ,
342343 [settings .SRID ],
343344 )
344345 cur .execute ("UPDATE altimetry_dem SET rast = ST_AddBand(rast, '16BSI')" )
@@ -356,17 +357,17 @@ def setUpTestData(cls):
356357 [x + 1 , y + 1 , demvalues [y ][x ]],
357358 )
358359 cls .path = Path .objects .create (
359- geom = LineString ((1 , 101 ), (81 , 101 ), (81 , 99 ))
360+ geom = LineStringInBounds ((1 , 101 ), (81 , 101 ), (81 , 99 ))
360361 )
361362
362363 def test_2dlength_is_preserved (self ):
363- self .assertEqual (self .path .geom_3d .length , self .path .geom .length )
364+ self .assertAlmostEqual (self .path .geom .length , self .path .geom_3d .length )
364365
365366 def test_3dlength (self ):
366367 # before smoothing: (1 101 0, 21 101 0, 41 101 0, 61 101 3, 81 101 5, 81 99 15)
367368 # after smoothing: (1 101 0, 21 101 0, 41 101 0, 61 101 1, 81 101 3, 81 99 9)
368369 # length: 20 + 20 + (20 ** 2 + 1) ** .5 + (20 ** 2 + 2 ** 2) ** .5 + (2 ** 2 + 6 ** 2) ** .5
369- self .assertEqual (round (self .path .length , 9 ), 83.127128724 )
370+ self .assertEqual (round (self .path .length , 9 ), 83.203851919 )
370371
371372
372373@skipIf (not settings .TREKKING_TOPOLOGY_ENABLED , "Test with dynamic segmentation only" )
0 commit comments