Struct geom::PolyLine[][src]

pub struct PolyLine {
    pts: Vec<Pt2D>,
    length: Distance,
}

Fields

pts: Vec<Pt2D>length: Distance

Implementations

Doesn’t check for duplicates. Use at your own risk.

First dedupes adjacent points

Like make_polygons, but make sure the points actually form a ring.

Glue together two polylines in order. The last point of self must be the same as the first point of other. This method handles removing unnecessary intermediate points if the extension happens to be at the same angle as the last line segment of self.

Like extend, but panics on failure.

Extends self by a single point. If the new point is close enough to the last, dedupes. Doesn’t clean up any intermediate points.

Like extend, but handles the last and first point not matching by inserting that point. Doesn’t clean up any intermediate points.

One or both args might be empty.

Returns the excess distance left over from the end

No excess leftover distance allowed.

Perpendicularly shifts the polyline to the right if positive or left if negative.

The resulting polygon is manually triangulated and may not have a valid outer Ring (but it usually does).

Don’t draw the dashes too close to the ends.

Fail if the length is too short.

If the length is too short, just give up and make the thick line

Also return the angle of the line where the hit was found

Panics if the pt is not on the polyline. Returns None if the point is the first point (meaning the slice is empty).

Returns None if the point is the last point.

Same as get_slice_ending_at, but returns None if the point isn’t on the polyline.

Same as get_slice_starting_at, but returns None if the point isn’t on the polyline.

If the current line is at least this long, return it. Otherwise, extend the end of it, following the angle of the last line.

Produces a GeoJSON linestring, optionally mapping the world-space points back to GPS.

Returns the point on the polyline closest to the query.

Returns the angle from the start to end of this polyline.

Walk along the PolyLine, starting buffer_ends from the start and ending buffer_ends before the end. Advance in increments of step_size. Returns the point and angle at each step.

Walk along the PolyLine, from start_buffer to length - end_buffer. Advance in increments of step_size. Returns the point and angle at each step.

use geom::{PolyLine, Pt2D, Distance};

let polyline = PolyLine::must_new(vec![
    Pt2D::new(0.0, 0.0),
    Pt2D::new(0.0, 10.0),
    Pt2D::new(10.0, 20.0),
]);

assert_eq!(
    polyline.interpolate_points(Distance::meters(20.0)).points(),
    &vec![
        Pt2D::new(0.0, 0.0),
        Pt2D::new(0.0, 10.0),
        Pt2D::new(10.0, 20.0),
    ]
);

assert_eq!(
    polyline.interpolate_points(Distance::meters(10.0)).points(),
    &vec![
        Pt2D::new(0.0, 0.0),
        Pt2D::new(0.0, 10.0),
        Pt2D::new(5.0, 15.0),
        Pt2D::new(10.0, 20.0),
    ]
);

An arbitrary placeholder value, when Option types aren’t worthwhile

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.