Skip to content

Commit de360ff

Browse files
vertical time uom
1 parent f1d4066 commit de360ff

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

energyml-utils/src/energyml/utils/data/crs.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ class CrsInfo:
106106

107107
vertical_unknown: Optional[str] = None
108108
"""Free-text vertical CRS descriptor."""
109+
110+
time_uom: Optional[str] = None
111+
"""Unit of measure for time coordinates (e.g. ``"s"``, ``"min"``, ``"h"``)."""
112+
109113

110114
# ------------------------------------------------------------------
111115
# Rotation / azimuth
@@ -443,9 +447,10 @@ def _from_abstract_local3dcrs(
443447

444448
# --- Vertical UOM (length or time) ------------------------------------
445449
vertical_uom: Optional[str] = _uom_to_str(get_object_attribute_no_verif(crs_obj, "vertical_uom"))
450+
time_uom = _uom_to_str(getattr(crs_obj, "time_uom", None))
446451
if vertical_uom is None:
447452
# time_uom only present on LocalTime3dCrs
448-
vertical_uom = _uom_to_str(getattr(crs_obj, "time_uom", None))
453+
vertical_uom = time_uom
449454

450455
# --- Axis order --------------------------------------------------------
451456
axis_order_raw = get_object_attribute_no_verif(crs_obj, "projected_axis_order")
@@ -494,6 +499,7 @@ def _from_abstract_local3dcrs(
494499
projected_unknown=projected_details.get("unknown"),
495500
vertical_epsg_code=vertical_details.get("epsg_code"),
496501
vertical_uom=vertical_uom,
502+
time_uom=time_uom,
497503
z_increasing_downward=z_increasing_downward,
498504
vertical_wkt=vertical_details.get("wkt"),
499505
vertical_unknown=vertical_details.get("unknown"),
@@ -621,6 +627,11 @@ def _from_local_engineering_compound_crs(
621627
vert_axis_uom_raw = get_object_attribute(crs_obj, "vertical_axis.uom")
622628
if vert_axis_uom_raw is not None:
623629
vert_axis_uom = _uom_to_str(vert_axis_uom_raw)
630+
631+
is_time = get_object_attribute(crs_obj, "vertical_axis.is_time")
632+
time_uom = None
633+
if is_time is not None and str(is_time).lower() in ("true", "1", "yes"):
634+
time_uom = vert_axis_uom
624635
vert_axis_dir_raw = get_object_attribute(crs_obj, "vertical_axis.direction")
625636
if vert_axis_dir_raw is not None:
626637
d = str(vert_axis_dir_raw)
@@ -693,6 +704,7 @@ def _from_local_engineering_compound_crs(
693704
# when the resolved CRS carries an explicit direction (not the None sentinel).
694705
vertical_epsg_code=vert_info.vertical_epsg_code if vert_info else None,
695706
vertical_uom=(vert_info.vertical_uom if vert_info else None) or vert_axis_uom,
707+
time_uom=time_uom,
696708
z_increasing_downward=(
697709
vert_info.z_increasing_downward
698710
if vert_info and vert_details_raw is not None and vert_details_raw.get("z_increasing_downward") is not None

energyml-utils/src/energyml/utils/data/representation_context.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from energyml.utils.epc_utils import extract_uuid_and_version_from_obj_path, get_property_kind_by_title, get_property_kind_uuid_from_property_object
1313
from energyml.utils.introspection import get_obj_uri, get_obj_uuid, get_object_attribute, is_enum, search_attribute_matching_name
1414
from energyml.utils.data.helper import RgbaColor, ScalarRenderingInfo, read_graphical_rendering_info
15+
from energyml.utils.data.crs import extract_crs_info
1516

1617
NO_KIND = "NO_KIND"
1718

@@ -149,7 +150,7 @@ def _collect_crs(self):
149150
crs_uuid = getattr(crs, "uuid", None)
150151
if crs_uuid is not None and crs_uuid not in crs_uuids:
151152
crs_uuids.add(crs_uuid)
152-
self.crs_infos.append(CrsInfo.from_crs_object(crs, self.workspace))
153+
self.crs_infos.append(extract_crs_info(crs, self.workspace))
153154
else:
154155
logging.warning(f"CRS {get_obj_uri(crs_ref)} not found in workspace")
155156

@@ -230,6 +231,11 @@ def projected_uom(self) -> Optional[str]:
230231
@property
231232
def vertical_uom(self) -> Optional[str]:
232233
"""Return the vertical unit of measure (e.g. "m") if available from CRS info, or None."""
234+
if self.vertical_is_time:
235+
# For time-based representations, return the time unit of measure if available
236+
for ci in self.crs_infos:
237+
if ci.time_uom is not None:
238+
return ci.time_uom
233239
for ci in self.crs_infos:
234240
if ci.vertical_uom is not None:
235241
return ci.vertical_uom

0 commit comments

Comments
 (0)