def test_elevation_svg_output(self): geom = LineString((1.5, 2.5, 8), (2.5, 2.5, 10), srid=settings.SRID) profile = AltimetryHelper.elevation_profile(geom) svg = AltimetryHelper.profile_svg(profile) self.assertIn('Generated with pygal', svg) self.assertIn(settings.ALTIMETRIC_PROFILE_BACKGROUND, svg) self.assertIn(settings.ALTIMETRIC_PROFILE_COLOR, svg)
def test_elevation_altimetry_limits(self): geom = LineString((1.5, 2.5, 8), (2.5, 2.5, 10), srid=settings.SRID) profile = AltimetryHelper.elevation_profile(geom) limits = AltimetryHelper.altimetry_limits(profile) self.assertEqual(limits[0], 1108) self.assertEqual(limits[1], -92)
def test_elevation_svg_output(self): geom = LineString((1.5, 2.5, 8), (2.5, 2.5, 10), srid=settings.SRID) profile = AltimetryHelper.elevation_profile(geom) language = translation.get_language() svg = AltimetryHelper.profile_svg(profile, language) self.assertIn('Generated with pygal'.encode(), svg) self.assertIn(settings.ALTIMETRIC_PROFILE_BACKGROUND.encode(), svg) self.assertIn(settings.ALTIMETRIC_PROFILE_COLOR.encode(), svg)
def test_elevation_profile_wrong_geom(self): geom = MultiLineString(LineString((1.5, 2.5, 8), (2.5, 2.5, 10)), LineString((2.5, 2.5, 6), (2.5, 0, 7)), srid=settings.SRID) profile = AltimetryHelper.elevation_profile(geom) self.assertEqual(len(profile), 4)
def test_resolution_step_depends_on_geometry_size(self): self.assertEqual(self.area['resolution']['step'], 25) geom = LineString((100, 370), (100100, 370), srid=settings.SRID) area = AltimetryHelper.elevation_area(geom) self.assertEqual(area['resolution']['step'], 866)
def test_area_has_nice_ratio_if_square_enough(self): geom = LineString((0, 0), (1000, 1000), srid=settings.SRID) area = AltimetryHelper.elevation_area(geom) self.assertEqual(area['size']['x'], 1300.0) self.assertEqual(area['size']['y'], 1300.0)
def setUp(self): self._fill_raster() self.geom = LineString((100, 370), (1100, 370), srid=settings.SRID) self.area = AltimetryHelper.elevation_area(self.geom)
def test_area_small_geom(self): geom = LineString((10, 10), (10, 5), srid=settings.SRID) area = AltimetryHelper.elevation_area(geom) extent = area['extent'] self.assertEqual(extent['altitudes']['max'], 30) self.assertEqual(extent['altitudes']['min'], 30)
def test_elevation_profile_point(self): geom = Point(1.5, 2.5, 8, srid=settings.SRID) profile = AltimetryHelper.elevation_profile(geom) self.assertEqual(profile, [[0, 1.5, 2.5, 8.0]])