forked from s_ranjbar/city_retrofit
Neighbours mapping completed.
This commit is contained in:
parent
a8d0d0e6ba
commit
48fbeb488f
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user