diff --git a/python/src/lib.rs b/python/src/lib.rs index f2600d5..c85739e 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -4,8 +4,8 @@ use std::path::PathBuf; use liblrs::lrs::LrmHandle; +use liblrs::lrs::{LrsBase, Properties}; use liblrs::lrs_ext::*; -use liblrs::{builder::Properties, lrs::LrsBase}; use pyo3::{exceptions::PyTypeError, prelude::*}; /// Holds the whole Linear Referencing System. diff --git a/src/builder.rs b/src/builder.rs index be85506..dcbcc48 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -9,32 +9,11 @@ use geo::{Coord, Distance}; use crate::curves::{Curve, CurveError, CurveProjection, SphericalLineStringCurve}; +use crate::lrs::Properties; use crate::lrs_ext::ExtLrs; use crate::lrs_generated::{self, *}; use crate::osm_helpers::sort_edges; - -/// A key-value `HashMap` to add metadata to the objects. -pub type Properties = std::collections::HashMap; - -#[macro_export] -/// Build a properties map: -/// `properties!("source" => "openstreetmap", "license" => "ODbL")`. -macro_rules! properties { - ($($k:expr => $v:expr),* $(,)?) => {{ - core::convert::From::from([$(($k.to_owned(), $v.to_owned()),)*]) - }}; -} - -/// Builds a [`Properties`] from a FlatBuffer vector of Property -/// -/// Implementation note: as [`Properties`] is just an alias, we cannot `impl` for it (e.g. Into) -pub fn from_fb(properties: Option>>) -> Properties { - properties - .unwrap_or_default() - .iter() - .map(|property| (property.key().to_string(), property.value().to_string())) - .collect() -} +use crate::properties; /// The linear position of an [`Anchor`] doesn’t always match the measured distance. /// For example if a road was transformed into a bypass, resulting in a longer road, diff --git a/src/lrm_scale.rs b/src/lrm_scale.rs index fcda73a..998ac18 100644 --- a/src/lrm_scale.rs +++ b/src/lrm_scale.rs @@ -4,7 +4,7 @@ use geo::Point; use thiserror::Error; -use crate::builder::Properties; +use crate::lrs::Properties; /// Measurement along the `Curve`. Typically in meters. pub type CurvePosition = f64; diff --git a/src/lrs.rs b/src/lrs.rs index 0ba683c..954ba82 100644 --- a/src/lrs.rs +++ b/src/lrs.rs @@ -8,10 +8,10 @@ extern crate flatbuffers; use std::cmp::Ordering; +use flatbuffers::{ForwardsUOffset, Vector}; use geo::orient::Direction; use thiserror::Error; -use crate::builder::{from_fb, Properties}; use crate::curves::{Curve, CurveError}; use crate::lrm_scale::{ Anchor, CurvePosition, LrmScale, LrmScaleError, LrmScaleMeasure, ScalePosition, @@ -620,6 +620,29 @@ impl Lrs { } } +/// A key-value `HashMap` to add metadata to the objects. +pub type Properties = std::collections::HashMap; + +#[macro_export] +/// Build a properties map: +/// `properties!("source" => "openstreetmap", "licence" => "ODbL")`. +macro_rules! properties { + ($($k:expr => $v:expr),* $(,)?) => {{ + core::convert::From::from([$(($k.to_owned(), $v.to_owned()),)*]) + }}; +} + +/// Builds a [`Properties`] from a FlatBuffer vector of Property +/// +/// Implementation note: as [`Properties`] is just an alias, we cannot `impl` for it (e.g. Into) +pub fn from_fb(properties: Option>>) -> Properties { + properties + .unwrap_or_default() + .iter() + .map(|property| (property.key().to_string(), property.value().to_string())) + .collect() +} + #[cfg(test)] mod tests { use approx::assert_relative_eq; diff --git a/src/lrs_ext.rs b/src/lrs_ext.rs index cd696f4..ace0028 100644 --- a/src/lrs_ext.rs +++ b/src/lrs_ext.rs @@ -3,10 +3,10 @@ use geo::{Coord, Point}; -use crate::builder::Properties; use crate::curves::{Curve, SphericalLineStringCurve}; use crate::lrm_scale::Anchor; use crate::lrm_scale::LrmScaleMeasure; +use crate::lrs::Properties; use crate::lrs::{self, TraversalPosition}; use crate::lrs::{LrsBase, LrsError};