Skip to content

Commit

Permalink
CurveProjection now holds the projected coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristramg committed Jul 10, 2024
1 parent 952d107 commit 3f71f95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/curves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ impl Curve for PlanarLineStringCurve {
match self.geom.line_locate_point(&point) {
Some(location) => {
let distance_along_curve = location * self.length + self.start_offset;
let projected_coords = self
.geom
.line_interpolate_point(location)
.ok_or(CurveError::InvalidGeometry)?;

let begin = self.geom.coords().next().unwrap();
let end = self.geom.coords().next_back().unwrap();
Expand Down Expand Up @@ -545,6 +549,9 @@ pub struct CurveProjection {
/// The distance is `positive` if the [`Point`] is located on the left of the [`Curve`]
/// and `negative` if the [`Point`] is on the right.
pub offset: f64,

/// The projected position on the curve
pub projected_coords: Point,
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/lrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::cmp::Ordering;
use geo::orient::Direction;
use thiserror::Error;

use crate::curves::{Curve, CurveError, CurveProjection};
use crate::curves::{Curve, CurveError};
use crate::lrm_scale::{
Anchor, CurvePosition, LrmScale, LrmScaleError, LrmScaleMeasure, ScalePosition,
};
Expand Down

0 comments on commit 3f71f95

Please sign in to comment.