from context import measprocess as mpc import unittest import geopandas as gpd from shapely.geometry import Point, LineString class TestOSMAPI(unittest.TestCase): def setUp(self): self._coords = [ (48.201914, 16.363859), (48.194170, 16.385466) ] self._measurement_coords_not_set = gpd.GeoSeries( (Point(lon, lat) for lat, lon in self._coords) ) self._measurement_coords_set = gpd.GeoSeries( (Point(lon, lat) for lat, lon in self._coords) ).set_crs("EPSG:4326") def test_basic_API(self): street_series = mpc.geospatial.get_geoseries_streets( self._measurement_coords_set ) blockage_series = mpc.geospatial.get_geoseries_blockages( self._measurement_coords_set ) self.assertTrue( "EPSG:4326" == street_series.crs ) self.assertTrue( "EPSG:4326" == blockage_series.crs ) def test_raise_error_if_crs_not_set(self): with self.assertRaises(ValueError): mpc.geospatial.get_geoseries_blockages( self._measurement_coords_not_set ) mpc.geospatial.get_geoseries_streets( self._measurement_coords_not_set ) def test_output_coordinates_streets(self): street_series = mpc.geospatial.get_geoseries_streets( self._measurement_coords_set ) street_series = street_series.to_crs("EPSG:31287") projected = self._measurement_coords_set.to_crs("EPSG:31287") self.assertTrue( street_series.distance(projected[0]).mean() < 1000 ) def test_output_coordinates_blockages(self): blockage_series = mpc.geospatial.get_geoseries_blockages( self._measurement_coords_set ) blockage_series = blockage_series.to_crs("EPSG:31287") projected = self._measurement_coords_set.to_crs("EPSG:31287") self.assertTrue( blockage_series.distance(projected[0]).mean() < 1000 ) if __name__ == '__main__': unittest.main()