|
8 | 8 | import flask |
9 | 9 | import werkzeug |
10 | 10 | import zipfile |
| 11 | +import opengeode as og |
11 | 12 | import opengeode_io as og_io |
12 | 13 | import opengeode_geosciences as og_geosciences |
13 | 14 | import opengeode_geosciencesio as og_geosciencesio |
@@ -264,25 +265,27 @@ def texture_coordinates() -> flask.Response: |
264 | 265 | return flask.make_response({"texture_coordinates": texture_coordinates}, 200) |
265 | 266 |
|
266 | 267 |
|
267 | | -def attributes_metadata(manager: Any) -> dict[str, Any]: |
268 | | - metadata: dict[str, Any] = {} |
| 268 | +def attributes_metadata(manager: og.AttributeManager) -> dict[str, list[float]]: |
| 269 | + metadata: dict[str, list[float]] = {} |
269 | 270 | for name in manager.attribute_names(): |
270 | 271 | attribute = manager.find_generic_attribute(name) |
271 | 272 | if not attribute.is_genericable(): |
272 | | - metadata[name] = [-1, -1] |
| 273 | + metadata[name] = [-1.0, -1.0] |
273 | 274 | continue |
274 | 275 | min_value = None |
275 | 276 | max_value = None |
276 | 277 | nb_items = attribute.nb_items() |
277 | 278 | for i in range(nb_items): |
278 | 279 | generic_value = attribute.generic_value(i) |
279 | | - if not isinstance(generic_value, (int, float)): |
280 | | - continue |
281 | 280 | if min_value is None or generic_value < min_value: |
282 | 281 | min_value = generic_value |
283 | 282 | if max_value is None or generic_value > max_value: |
284 | 283 | max_value = generic_value |
285 | | - metadata[name] = [min_value, max_value] if min_value is not None else [-1, -1] |
| 284 | + metadata[name] = ( |
| 285 | + [min_value, max_value] |
| 286 | + if min_value is not None and max_value is not None |
| 287 | + else [-1.0, -1.0] |
| 288 | + ) |
286 | 289 | return metadata |
287 | 290 |
|
288 | 291 |
|
@@ -364,11 +367,11 @@ def polyhedron_attribute_names() -> flask.Response: |
364 | 367 | geode_object = geode_functions.load_geode_object(params.id) |
365 | 368 | if not isinstance(geode_object, GeodeSolidMesh3D): |
366 | 369 | flask.abort(400, f"{params.id} is not a GeodeSolidMesh") |
367 | | - attributemanager = geode_object.polyhedron_attribute_manager() |
| 370 | + attribute_manager = geode_object.polyhedron_attribute_manager() |
368 | 371 | return flask.make_response( |
369 | 372 | { |
370 | | - "polyhedron_attribute_names": attributemanager.attribute_names(), |
371 | | - "polyhedron_attribute_metadata": attributes_metadata(attributemanager), |
| 373 | + "polyhedron_attribute_names": attribute_manager.attribute_names(), |
| 374 | + "polyhedron_attribute_metadata": attributes_metadata(attribute_manager), |
372 | 375 | }, |
373 | 376 | 200, |
374 | 377 | ) |
|
0 commit comments