Correct the positions for the boxes
This commit is contained in:
parent
3578d2faae
commit
7cb4600c15
|
@ -23,6 +23,14 @@ class CesiumjsTileset:
|
|||
except pyproj.exceptions.CRSError as err:
|
||||
raise pyproj.exceptions.CRSError from err
|
||||
self._to_gps = Transformer.from_crs(input_reference, pyproj.CRS('EPSG:4326'))
|
||||
city_upper_corner = [
|
||||
self._city.upper_corner[0] - self._city.lower_corner[0],
|
||||
self._city.upper_corner[1] - self._city.lower_corner[1],
|
||||
self._city.upper_corner[2] - self._city.lower_corner[2]
|
||||
]
|
||||
city_lower_corner = [0, 0, 0]
|
||||
|
||||
print('root')
|
||||
self._tile_set = {
|
||||
'asset': {
|
||||
'version': '1.1',
|
||||
|
@ -75,7 +83,7 @@ class CesiumjsTileset:
|
|||
'geometricError': 240,
|
||||
'root': {
|
||||
'boundingVolume': {
|
||||
'box': CesiumjsTileset._box_values(self._city.upper_corner, self._city.lower_corner)
|
||||
'box': CesiumjsTileset._box_values(city_upper_corner, city_lower_corner)
|
||||
},
|
||||
'geometricError': 70,
|
||||
'refine': 'ADD',
|
||||
|
@ -87,10 +95,13 @@ class CesiumjsTileset:
|
|||
|
||||
@staticmethod
|
||||
def _box_values(upper_corner, lower_corner):
|
||||
|
||||
x = (upper_corner[0] - lower_corner[0]) / 2
|
||||
x_center = ((upper_corner[0] - lower_corner[0]) / 2) + lower_corner[0]
|
||||
y = (upper_corner[1] - lower_corner[1]) / 2
|
||||
y_center = ((upper_corner[1] - lower_corner[1]) / 2) + lower_corner[1]
|
||||
z = (upper_corner[2] - lower_corner[2]) / 2
|
||||
return [x, y, z, x, 0, 0, 0, y, 0, 0, 0, z]
|
||||
return [x_center, y_center, z, x, 0, 0, 0, y, 0, 0, 0, z]
|
||||
|
||||
def _ground_coordinates(self, coordinates):
|
||||
ground_coordinates = []
|
||||
|
@ -104,10 +115,15 @@ class CesiumjsTileset:
|
|||
for building in self._city.buildings:
|
||||
upper_corner = [-math.inf, -math.inf, 0]
|
||||
lower_corner = [math.inf, math.inf, 0]
|
||||
|
||||
lower_corner_coordinates = lower_corner
|
||||
for surface in building.grounds: # todo: maybe we should add the terrain?
|
||||
coordinates = self._ground_coordinates(surface.solid_polygon.coordinates)
|
||||
lower_corner = [min([c[0] for c in coordinates]), min([c[1] for c in coordinates]), 0]
|
||||
lower_corner_coordinates = [
|
||||
min([c[0] for c in surface.solid_polygon.coordinates]),
|
||||
min([c[1] for c in surface.solid_polygon.coordinates]),
|
||||
0
|
||||
]
|
||||
upper_corner = [max([c[0] for c in coordinates]), max([c[1] for c in coordinates]), building.max_height]
|
||||
|
||||
tile = {
|
||||
|
@ -119,7 +135,7 @@ class CesiumjsTileset:
|
|||
'class': 'building',
|
||||
'properties': {
|
||||
'name': building.name,
|
||||
'position': self._to_gps.transform(lower_corner[0], lower_corner[1]),
|
||||
'position': self._to_gps.transform(lower_corner_coordinates[0], lower_corner_coordinates[1]),
|
||||
'aliases': building.aliases,
|
||||
'volume': building.volume,
|
||||
'floor_area': building.floor_area,
|
||||
|
|
|
@ -41,10 +41,13 @@ class Glb:
|
|||
subprocess.run([
|
||||
self._obj2gtl,
|
||||
'-i', f'{self._path}/{building.name}.obj',
|
||||
'-o', f'{glb}',
|
||||
'-b',
|
||||
'--normalTexture', f'{self._path}/{building.name}.mtl'
|
||||
'-o', f'{glb}',
|
||||
'--triangleWindingOrderSanitization',
|
||||
'--inputUpAxis', 'Y',
|
||||
'--outputUpAxis', 'Y'
|
||||
])
|
||||
|
||||
os.unlink(f'{self._path}/{building.name}.obj')
|
||||
os.unlink(f'{self._path}/{building.name}.mtl')
|
||||
except (subprocess.SubprocessError, subprocess.TimeoutExpired, subprocess.CalledProcessError) as err:
|
||||
|
|
Loading…
Reference in New Issue
Block a user