cj_geometry
Classes to handle the geometry of the CityJSON objects.
Classes:
| Name | Description |
|---|---|
CityJSONGeometries |
Class to handle a list of geometries and process them together. |
Geometry |
Base class for a CityJSON geometry object. |
MultiSurface |
|
CityJSONGeometries
Class to handle a list of geometries and process them together.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a handle for multiple geometry objects. |
get_geometry_cj |
Return all the geometries in CityJSON format, with deduplicated vertices. |
get_optimal_translate |
Compute the optimal translation for the list of geometries, computed as the average of all the unique vertices. |
get_vertices_cj |
Return all the deduplicated vertices in CityJSON format, scaled and translated according to the given arguments. |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
__init__(geometries)
Create a handle for multiple geometry objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometries
|
typing.Sequence[cj_helpers.cj_geometry.Geometry]
|
List of Geometry or subclasses to handle. |
required |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
215 216 217 218 219 220 221 222 223 224 225 | |
get_geometry_cj()
Return all the geometries in CityJSON format, with deduplicated vertices.
Returns:
| Type | Description |
|---|---|
list[dict[str, typing.Any]]
|
The list of all geometries |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
get_optimal_translate(scale)
Compute the optimal translation for the list of geometries, computed as the average of all the unique vertices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
numpy.typing.NDArray[numpy.float64]
|
Array of shape (3,) containing the scale used to store the vertices. Used to round the computed translation. |
required |
Returns:
| Type | Description |
|---|---|
numpy.typing.NDArray[numpy.float64]
|
Array of shape (3,) containing the computed translation. |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
get_vertices_cj(scale, translate)
Return all the deduplicated vertices in CityJSON format, scaled and translated according to the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
numpy.typing.NDArray[numpy.float64]
|
Array of shape (3,) containing the scale used to store the vertices. |
required |
translate
|
numpy.typing.NDArray[numpy.float64]
|
Array of shape (3,) containing the translation used to store the vertices. |
required |
Returns:
| Type | Description |
|---|---|
list[list[int]]
|
List of shape (N, 3) containing all the vertices coordinates. |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
Geometry
Bases: abc.ABC
Base class for a CityJSON geometry object.
Methods:
| Name | Description |
|---|---|
__init__ |
Base class for a CityJSON geometry object. |
to_cityjson_format |
Export the geometry to the expected CityJSON format. |
to_trimesh |
Export the geometry to a Trimesh |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
__init__(lod, type_str, vertices, boundaries)
Base class for a CityJSON geometry object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lod
|
int
|
Level of detail. |
required |
type_str
|
str
|
Type of geometry. |
required |
vertices
|
numpy.typing.NDArray[numpy.float64]
|
Array of vertices coordinates. |
required |
boundaries
|
list[typing.Any]
|
Array of indices referencing |
required |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
to_cityjson_format(replace_boundaries)
abstractmethod
Export the geometry to the expected CityJSON format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
replace_boundaries
|
list[typing.Any] | None
|
Whether to replace the current boundaries with new boundaries. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, typing.Any]
|
The CityJSON representation of this geometry. |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
to_trimesh()
abstractmethod
Export the geometry to a Trimesh
Returns:
| Type | Description |
|---|---|
trimesh.Trimesh
|
A Trimesh corresponding to this geometry. |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
106 107 108 109 110 111 112 113 114 115 116 | |
MultiSurface
Bases: cj_helpers.cj_geometry.Geometry
Methods:
| Name | Description |
|---|---|
__init__ |
MultiSurface geometry object. |
from_mesh |
Generate a MultiSurface from a Trimesh object, and set its lod. |
to_cityjson_format |
Export the geometry to the expected CityJSON format. |
to_trimesh |
Export the geometry to a Trimesh |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
__init__(lod, vertices, boundaries)
MultiSurface geometry object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lod
|
int
|
Level of detail. |
required |
vertices
|
numpy.typing.NDArray[numpy.float64]
|
Array of vertices coordinates. |
required |
boundaries
|
list[list[numpy.typing.NDArray[numpy.float64]]]
|
Array of indices referencing |
required |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
from_mesh(lod, mesh)
classmethod
Generate a MultiSurface from a Trimesh object, and set its lod.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lod
|
int
|
Level of detail. |
required |
mesh
|
trimesh.Trimesh
|
Trimesh to store as a MultiSurface. |
required |
Returns:
| Type | Description |
|---|---|
cj_helpers.cj_geometry.MultiSurface
|
The generated MultiSurface. |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
to_cityjson_format(replace_boundaries)
Export the geometry to the expected CityJSON format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
replace_boundaries
|
list[list[numpy.typing.NDArray[numpy.float64]]] | None
|
Whether to replace the current boundaries with new boundaries. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, typing.Any]
|
The CityJSON representation of this geometry. |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
to_trimesh()
Export the geometry to a Trimesh
Returns:
| Type | Description |
|---|---|
trimesh.Trimesh
|
A Trimesh corresponding to this geometry. |
Source code in python/src/data_pipeline/cj_helpers/cj_geometry.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |