ifc_lite_core/
georef_details.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5use super::GeoRefSource;
6
7/// The authored coordinate operation, independent of the compatible placement.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9#[non_exhaustive]
10pub enum CoordinateOperationKind {
11    /// `IfcMapConversion`, including its `Scaled` subtype.
12    MapConversion,
13    /// `IfcRigidOperation`, a pure translation into its target CRS.
14    RigidOperation,
15}
16
17/// Additional metadata returned by `GeoRefExtractor::extract_with_details`.
18///
19/// Kept separate so existing callers can still construct `GeoReference`
20/// exhaustively and match every `GeoRefSource` variant.
21#[derive(Debug, Clone, Default, PartialEq, Eq)]
22#[non_exhaustive]
23pub struct GeoReferenceDetails {
24    /// The parsed coordinate operation; absent for CRS-only and legacy data.
25    pub operation: Option<CoordinateOperationKind>,
26    /// Trimmed `IfcWellKnownText.WellKnownText` attached to the selected CRS.
27    /// When present, this is the authoritative definition, even without a name.
28    pub well_known_text: Option<String>,
29    /// Whether the CRS `MapUnit` was READ (its declared factor is the one its name means) or is a fallback nobody may
30    /// carry into a write: the METRE default of an unreadable unit, or a name whose declared factor disagrees (a survey
31    /// foot named FOOT). `None` when no MapUnit is authored. The TS twin's `mapUnitResolved`.
32    pub map_unit_resolved: Option<bool>,
33}
34
35impl GeoReferenceDetails {
36    /// Precise wire provenance, including rigid operations, or the base label.
37    pub fn source_label(&self, base: Option<GeoRefSource>) -> Option<&'static str> {
38        if self.operation == Some(CoordinateOperationKind::RigidOperation) {
39            Some("rigidOperation")
40        } else {
41            base.map(GeoRefSource::label)
42        }
43    }
44}