diff --git a/hub/helpers/geometry_helper.py b/hub/helpers/geometry_helper.py index 912105d4..b61e3b78 100644 --- a/hub/helpers/geometry_helper.py +++ b/hub/helpers/geometry_helper.py @@ -59,14 +59,14 @@ class GeometryHelper: @staticmethod def coordinate_to_map_point(coordinate, city): - return MapPoint((city.upper_corner[0] - coordinate[0] / 1), (city.upper_corner[1] - coordinate[1] / 1)) + return MapPoint(((city.upper_corner[0] - coordinate[0]) * 0.5), ((city.upper_corner[1] - coordinate[1]) * 0.5)) @staticmethod def city_mapping(city, building_names=None): if building_names is None: building_names = [b.name for b in city.buildings] - x = int((city.upper_corner[0] - city.lower_corner[0]) / 1) - y = int((city.upper_corner[1] - city.lower_corner[1]) / 1) + x = int((city.upper_corner[0] - city.lower_corner[0]) * 0.5) + 1 + y = int((city.upper_corner[1] - city.lower_corner[1]) * 0.5) + 1 city_map = [['' for _ in range(y + 1)] for _ in range(x + 1)] img = Image.new('RGB', (x + 1, y + 1), "black") # create a new black image city_image = img.load() # create the pixel map @@ -83,11 +83,11 @@ class GeometryHelper: distance = GeometryHelper.distance_between_points(coordinate, next_coordinate) if distance == 0: continue - delta_x = (coordinate[0] - next_coordinate[0]) / distance - delta_y = (coordinate[1] - next_coordinate[1]) / distance - for i in range(0, int(distance)): - x = MapPoint(point.x + (delta_x * i), point.y + (delta_y * i)).x - y = MapPoint(point.x + (delta_x * i), point.y + (delta_y * i)).y + delta_x = (coordinate[0] - next_coordinate[0]) / (distance / 0.5) + delta_y = (coordinate[1] - next_coordinate[1]) / (distance / 0.5) + for k in range(0, int(distance)): + x = MapPoint(point.x + (delta_x * k), point.y + (delta_y * k)).x + y = MapPoint(point.x + (delta_x * k), point.y + (delta_y * k)).y if city_map[x][y] == '': city_map[x][y] = building.name city_image[x, y] = (100, 0, 0) diff --git a/hub/imports/geometry/geojson.py b/hub/imports/geometry/geojson.py index 21f27b27..d8ef97f4 100644 --- a/hub/imports/geometry/geojson.py +++ b/hub/imports/geometry/geojson.py @@ -64,7 +64,7 @@ class Geojson: for zone, surface_coordinates in enumerate(surfaces_coordinates): points = GeometryHelper.points_from_string(GeometryHelper.remove_last_point_from_string(surface_coordinates)) polygon = Polygon(points) - surfaces.append(Surface(polygon, polygon)) + surfaces.append(Surface(polygon, polygon, surface_type=cte.GROUND)) buildings.append(Building(f'{name}_zone_{zone}', surfaces, year_of_construction, function)) return buildings diff --git a/hub/unittests/test_geometry_factory.py b/hub/unittests/test_geometry_factory.py index 1c8ef5bb..5ca0e272 100644 --- a/hub/unittests/test_geometry_factory.py +++ b/hub/unittests/test_geometry_factory.py @@ -142,7 +142,7 @@ class TestGeometryFactory(TestCase): city = self._get_city(file, 'geojson', height_field='citygml_me', year_of_construction_field='ANNEE_CONS', - function_field='LIBELLE_UT') + function_field='CODE_UTILI') hub.exports.exports_factory.ExportsFactory('obj', city, self._output_path).export() self.assertEqual(207, len(city.buildings), 'wrong number of buildings') @@ -155,7 +155,6 @@ class TestGeometryFactory(TestCase): start = datetime.datetime.now() file = 'concordia.geojson' city = self._get_city(file, 'geojson', - height_field='citygml_me', year_of_construction_field='ANNEE_CONS', function_field='LIBELLE_UT') city_end = datetime.datetime.now()