This commit is contained in:
Guille Gutierrez 2023-02-07 07:40:28 -05:00
parent aa4b7829e4
commit d91b6edfff

View File

@ -187,7 +187,77 @@ class EnergyAde:
return building_dic
def _lod1(self, building, building_dic, city):
raise NotImplementedError('Only lod 1 and 2 can be exported')
self._surface_members = []
boundaries = [{
'gml:Envelope': {
'@srsName': city.srs_name,
'@srsDimension': 3,
'gml:lowerCorner': ' '.join([str(e) for e in city.lower_corner]),
'gml:upperCorner': ' '.join([str(e) for e in city.upper_corner])
}}]
for surface in building.surfaces:
surface_member = {'@xlink:href': f'#PolyId{surface.name}'}
self._surface_members.append(surface_member)
if surface.type == 'Wall':
surface_type = 'bldg:WallSurface'
elif surface.type == 'Ground':
surface_type = 'bldg:GroundSurface'
else:
surface_type = 'bldg:RoofSurface'
surface_dic = {
surface_type: {
'@gml:id': f'GML_{uuid.uuid4()}',
'gml:name': f'{surface.name} ({surface.type})',
'gml:boundedBy': {
'gml:Envelope': {
'@srsName': city.srs_name,
'gml:lowerCorner': f'{surface.lower_corner[0]} {surface.lower_corner[1]}'
f' {surface.lower_corner[2]}',
'gml:upperCorner': f'{surface.upper_corner[0]} {surface.upper_corner[1]}'
f' {surface.upper_corner[2]}'
}
},
'bldg:lod1MultiSurface': {
'gml:MultiSurface': {
'@srsName': city.srs_name,
'@gml:id': f'GML_{uuid.uuid4()}',
'surfaceMember': {
'gml:Polygon': {
'@srsName': city.srs_name,
'@gml:id': f'PolyId{surface.name}',
'gml:exterior': {
'gml:LinearRing': {
'@gml:id': f'PolyId{surface.name}_0',
'gml:posList': {
'@srsDimension': '3',
'@count': len(surface.solid_polygon.coordinates) + 1,
'#text': f'{" ".join(map(str, surface.solid_polygon.points_list))} '
f'{" ".join(map(str, surface.solid_polygon.coordinates[0]))}'
}
}
}
}
}
}
}
}
}
boundaries.append(surface_dic)
building_dic['bldg:Building']['bldg:lod1Solid'] = {
'gml:Solid': {
'@gml:id': f'GML_{uuid.uuid4()}',
'gml:exterior': {
'gml:CompositeSurface': {
'@srsName': city.srs_name,
'@gml:id': f'GML_{uuid.uuid4()}',
'gml:surfaceMember': self._surface_members
}
}
}
}
building_dic['bldg:Building']['gml:boundedBy'] = boundaries
return building_dic
def _lod2(self, building, building_dic, city):
self._surface_members = []