Rect

Struct Rect 

Source
pub struct Rect<T = f64>
where T: CoordNum,
{ /* private fields */ }
Expand description

An axis-aligned bounded 2D rectangle whose area is defined by minimum and maximum Coords.

The constructors and setters ensure the maximum Coord is greater than or equal to the minimum. Thus, a Rects width, height, and area is guaranteed to be greater than or equal to zero.

Note. While Rect implements MapCoords and RotatePoint algorithmic traits, the usage is expected to maintain the axis alignment. In particular, only rotation by integer multiples of 90 degrees, will preserve the original shape. In other cases, the min, and max points are rotated or transformed, and a new rectangle is created (with coordinate swaps to ensure min < max).

§Examples

use geo_types::{coord, Rect};

let rect = Rect::new(
    coord! { x: 0., y: 4.},
    coord! { x: 3., y: 10.},
);

assert_eq!(3., rect.width());
assert_eq!(6., rect.height());
assert_eq!(
    coord! { x: 1.5, y: 7. },
    rect.center()
);

Implementations§

Source§

impl<T> Rect<T>
where T: CoordNum,

Source

pub fn new<C>(c1: C, c2: C) -> Rect<T>
where C: Into<Coord<T>>,

Creates a new rectangle from two corner coordinates.

Coords are stored and returned (by iterators) in CCW order

§Examples
use geo_types::{coord, Rect};

let rect = Rect::new(
    coord! { x: 10., y: 20. },
    coord! { x: 30., y: 10. }
);
assert_eq!(rect.min(), coord! { x: 10., y: 10. });
assert_eq!(rect.max(), coord! { x: 30., y: 20. });
Source

pub fn try_new<C>(c1: C, c2: C) -> Result<Rect<T>, InvalidRectCoordinatesError>
where C: Into<Coord<T>>,

👎Deprecated since 0.6.2: Use Rect::new instead, since Rect::try_new will never Error
Source

pub fn min(self) -> Coord<T>

Returns the minimum Coord of the Rect.

§Examples
use geo_types::{coord, Rect};

let rect = Rect::new(
    coord! { x: 5., y: 5. },
    coord! { x: 15., y: 15. },
);

assert_eq!(rect.min(), coord! { x: 5., y: 5. });
Examples found in repository?
examples/advanced_spatial.rs (line 158)
14fn main() -> Result<(), Box<dyn std::error::Error>> {
15    println!("=== Advanced Spatial Operations Demo ===\n");
16
17    // Create an in-memory database
18    let mut db = Spatio::memory()?;
19
20    // ========================================
21    // 1. Distance Calculations
22    // ========================================
23    println!("1. Distance Calculations");
24    println!("{}", "=".repeat(50));
25
26    let new_york = Point::new(-74.0060, 40.7128);
27    let los_angeles = Point::new(-118.2437, 34.0522);
28    let london = Point::new(-0.1278, 51.5074);
29
30    // Calculate distances using different metrics
31    let dist_haversine = distance_between(&new_york, &los_angeles, DistanceMetric::Haversine);
32    let dist_geodesic = distance_between(&new_york, &los_angeles, DistanceMetric::Geodesic);
33    let dist_rhumb = distance_between(&new_york, &los_angeles, DistanceMetric::Rhumb);
34
35    println!("NYC to LA:");
36    println!("  Haversine:  {:.2} km", dist_haversine / 1000.0);
37    println!("  Geodesic:   {:.2} km", dist_geodesic / 1000.0);
38    println!("  Rhumb:      {:.2} km", dist_rhumb / 1000.0);
39
40    // Using the database method
41    let db_distance = db.distance_between(&new_york, &london, DistanceMetric::Haversine)?;
42    println!("\nNYC to London: {:.2} km", db_distance / 1000.0);
43
44    // ========================================
45    // 2. K-Nearest-Neighbors (KNN)
46    // ========================================
47    println!("\n2. K-Nearest-Neighbors Query");
48    println!("{}", "=".repeat(50));
49
50    // Insert major cities
51    let cities = vec![
52        (Point::new(-74.0060, 40.7128), "New York", "USA"),
53        (Point::new(-118.2437, 34.0522), "Los Angeles", "USA"),
54        (Point::new(-87.6298, 41.8781), "Chicago", "USA"),
55        (Point::new(-95.3698, 29.7604), "Houston", "USA"),
56        (Point::new(-75.1652, 39.9526), "Philadelphia", "USA"),
57        (Point::new(-122.4194, 37.7749), "San Francisco", "USA"),
58        (Point::new(-0.1278, 51.5074), "London", "UK"),
59        (Point::new(2.3522, 48.8566), "Paris", "France"),
60        (Point::new(139.6917, 35.6895), "Tokyo", "Japan"),
61    ];
62
63    for (point, name, country) in &cities {
64        let data = format!("{},{}", name, country);
65        db.insert_point("world_cities", point, data.as_bytes(), None)?;
66    }
67
68    // Find 3 nearest cities to a query point (somewhere in New Jersey)
69    let query_point = Point::new(-74.1719, 40.7357);
70    let nearest = db.knn(
71        "world_cities",
72        &query_point,
73        3,
74        500_000.0, // Search within 500km
75        DistanceMetric::Haversine,
76    )?;
77
78    println!("3 nearest cities to query point:");
79    for (i, (_point, data, distance)) in nearest.iter().enumerate() {
80        let city_info = String::from_utf8_lossy(data);
81        println!(
82            "  {}. {} ({:.2} km away)",
83            i + 1,
84            city_info,
85            distance / 1000.0
86        );
87    }
88
89    // ========================================
90    // 3. Polygon Queries
91    // ========================================
92    println!("\n3. Polygon Queries");
93    println!("{}", "=".repeat(50));
94
95    // Define a polygon covering parts of the eastern US
96    use geo::polygon;
97    let east_coast_polygon = polygon![
98        (x: -80.0, y: 35.0),  // South
99        (x: -70.0, y: 35.0),  // Southeast
100        (x: -70.0, y: 45.0),  // Northeast
101        (x: -80.0, y: 45.0),  // Northwest
102        (x: -80.0, y: 35.0),  // Close the polygon
103    ];
104    let east_coast_polygon: Polygon = east_coast_polygon.into();
105
106    let cities_in_polygon = db.query_within_polygon("world_cities", &east_coast_polygon, 100)?;
107
108    println!("Cities within East Coast polygon:");
109    for (point, data) in &cities_in_polygon {
110        let city_info = String::from_utf8_lossy(data);
111        println!("  - {} at ({:.4}, {:.4})", city_info, point.x(), point.y());
112    }
113
114    // ========================================
115    // 4. Bounding Box Operations
116    // ========================================
117    println!("\n4. Bounding Box Operations");
118    println!("{}", "=".repeat(50));
119
120    // Create a bounding box around the New York area
121    let ny_bbox = bounding_box(-74.5, 40.5, -73.5, 41.0)?;
122    println!("NY Area Bounding Box: {:?}", ny_bbox);
123
124    // Find cities in bounding box
125    let cities_in_bbox = db.find_within_bounds("world_cities", 40.5, -74.5, 41.0, -73.5, 100)?;
126    println!("\nCities in NY area bounding box:");
127    for (_point, data) in &cities_in_bbox {
128        let city_info = String::from_utf8_lossy(data);
129        println!("  - {}", city_info);
130    }
131
132    // ========================================
133    // 5. Convex Hull
134    // ========================================
135    println!("\n5. Convex Hull Calculation");
136    println!("{}", "=".repeat(50));
137
138    // Get all city points
139    let city_points: Vec<Point> = cities.iter().map(|(p, _, _)| *p).collect();
140
141    // Calculate convex hull
142    if let Some(hull) = convex_hull(&city_points) {
143        println!("Convex hull of all cities:");
144        println!("  Exterior points: {}", hull.exterior().0.len() - 1);
145        for coord in hull.exterior().0.iter().take(5) {
146            println!("    ({:.4}, {:.4})", coord.x, coord.y);
147        }
148    }
149
150    // ========================================
151    // 6. Bounding Rectangle
152    // ========================================
153    println!("\n6. Bounding Rectangle");
154    println!("{}", "=".repeat(50));
155
156    if let Some(bbox) = bounding_rect_for_points(&city_points) {
157        println!("Bounding rectangle of all cities:");
158        println!("  Min: ({:.4}, {:.4})", bbox.min().x, bbox.min().y);
159        println!("  Max: ({:.4}, {:.4})", bbox.max().x, bbox.max().y);
160        println!("  Width:  {:.2}°", bbox.max().x - bbox.min().x);
161        println!("  Height: {:.2}°", bbox.max().y - bbox.min().y);
162    }
163
164    // ========================================
165    // 7. Advanced Radius Queries
166    // ========================================
167    println!("\n7. Advanced Radius Queries");
168    println!("{}", "=".repeat(50));
169
170    // Count cities within 1000km of NYC
171    let count = db.count_within_radius("world_cities", &new_york, 1_000_000.0)?;
172    println!("Cities within 1000km of NYC: {}", count);
173
174    // Check if any cities exist within 100km
175    let has_nearby = db.intersects_radius("world_cities", &new_york, 100_000.0)?;
176    println!("Has cities within 100km of NYC: {}", has_nearby);
177
178    // Query with radius
179    let nearby = db.query_within_radius("world_cities", &new_york, 200_000.0, 10)?;
180    println!("\nCities within 200km of NYC:");
181    for (point, data, _distance) in &nearby {
182        let city_info = String::from_utf8_lossy(data);
183        let dist = distance_between(&new_york, point, DistanceMetric::Haversine);
184        println!("  - {} ({:.2} km)", city_info, dist / 1000.0);
185    }
186
187    // ========================================
188    // 8. Spatial Analytics
189    // ========================================
190    println!("\n8. Spatial Analytics");
191    println!("{}", "=".repeat(50));
192
193    // Find the two most distant cities (brute force)
194    let mut max_distance = 0.0;
195    let mut furthest_pair = ("", "");
196
197    for (i, (p1, n1, _)) in cities.iter().enumerate() {
198        for (p2, n2, _) in cities.iter().skip(i + 1) {
199            let dist = distance_between(p1, p2, DistanceMetric::Geodesic);
200            if dist > max_distance {
201                max_distance = dist;
202                furthest_pair = (n1, n2);
203            }
204        }
205    }
206
207    println!(
208        "Most distant city pair: {} ↔ {}",
209        furthest_pair.0, furthest_pair.1
210    );
211    println!("Distance: {:.2} km", max_distance / 1000.0);
212
213    // Calculate average distance between all US cities
214    let us_cities: Vec<_> = cities
215        .iter()
216        .filter(|(_, _, country)| *country == "USA")
217        .collect();
218
219    if us_cities.len() > 1 {
220        let mut total_distance = 0.0;
221        let mut count = 0;
222
223        for (i, (p1, _, _)) in us_cities.iter().enumerate() {
224            for (p2, _, _) in us_cities.iter().skip(i + 1) {
225                total_distance += distance_between(p1, p2, DistanceMetric::Haversine);
226                count += 1;
227            }
228        }
229
230        let avg_distance = total_distance / count as f64;
231        println!(
232            "\nAverage distance between US cities: {:.2} km",
233            avg_distance / 1000.0
234        );
235    }
236
237    // ========================================
238    // Summary
239    // ========================================
240    println!("\n{}", "=".repeat(50));
241    println!("Summary:");
242    println!("  - Demonstrated multiple distance metrics");
243    println!("  - Performed K-nearest-neighbor searches");
244    println!("  - Queried points within polygons");
245    println!("  - Used bounding box operations");
246    println!("  - Calculated convex hulls");
247    println!("  - Performed spatial analytics");
248    println!("\nAll spatial operations leverage the geo crate!");
249
250    Ok(())
251}
Source

pub fn set_min<C>(&mut self, min: C)
where C: Into<Coord<T>>,

Set the Rect’s minimum coordinate.

§Panics

Panics if min’s x/y is greater than the maximum coordinate’s x/y.

Source

pub fn max(self) -> Coord<T>

Returns the maximum Coord of the Rect.

§Examples
use geo_types::{coord, Rect};

let rect = Rect::new(
    coord! { x: 5., y: 5. },
    coord! { x: 15., y: 15. },
);

assert_eq!(rect.max(), coord! { x: 15., y: 15. });
Examples found in repository?
examples/advanced_spatial.rs (line 159)
14fn main() -> Result<(), Box<dyn std::error::Error>> {
15    println!("=== Advanced Spatial Operations Demo ===\n");
16
17    // Create an in-memory database
18    let mut db = Spatio::memory()?;
19
20    // ========================================
21    // 1. Distance Calculations
22    // ========================================
23    println!("1. Distance Calculations");
24    println!("{}", "=".repeat(50));
25
26    let new_york = Point::new(-74.0060, 40.7128);
27    let los_angeles = Point::new(-118.2437, 34.0522);
28    let london = Point::new(-0.1278, 51.5074);
29
30    // Calculate distances using different metrics
31    let dist_haversine = distance_between(&new_york, &los_angeles, DistanceMetric::Haversine);
32    let dist_geodesic = distance_between(&new_york, &los_angeles, DistanceMetric::Geodesic);
33    let dist_rhumb = distance_between(&new_york, &los_angeles, DistanceMetric::Rhumb);
34
35    println!("NYC to LA:");
36    println!("  Haversine:  {:.2} km", dist_haversine / 1000.0);
37    println!("  Geodesic:   {:.2} km", dist_geodesic / 1000.0);
38    println!("  Rhumb:      {:.2} km", dist_rhumb / 1000.0);
39
40    // Using the database method
41    let db_distance = db.distance_between(&new_york, &london, DistanceMetric::Haversine)?;
42    println!("\nNYC to London: {:.2} km", db_distance / 1000.0);
43
44    // ========================================
45    // 2. K-Nearest-Neighbors (KNN)
46    // ========================================
47    println!("\n2. K-Nearest-Neighbors Query");
48    println!("{}", "=".repeat(50));
49
50    // Insert major cities
51    let cities = vec![
52        (Point::new(-74.0060, 40.7128), "New York", "USA"),
53        (Point::new(-118.2437, 34.0522), "Los Angeles", "USA"),
54        (Point::new(-87.6298, 41.8781), "Chicago", "USA"),
55        (Point::new(-95.3698, 29.7604), "Houston", "USA"),
56        (Point::new(-75.1652, 39.9526), "Philadelphia", "USA"),
57        (Point::new(-122.4194, 37.7749), "San Francisco", "USA"),
58        (Point::new(-0.1278, 51.5074), "London", "UK"),
59        (Point::new(2.3522, 48.8566), "Paris", "France"),
60        (Point::new(139.6917, 35.6895), "Tokyo", "Japan"),
61    ];
62
63    for (point, name, country) in &cities {
64        let data = format!("{},{}", name, country);
65        db.insert_point("world_cities", point, data.as_bytes(), None)?;
66    }
67
68    // Find 3 nearest cities to a query point (somewhere in New Jersey)
69    let query_point = Point::new(-74.1719, 40.7357);
70    let nearest = db.knn(
71        "world_cities",
72        &query_point,
73        3,
74        500_000.0, // Search within 500km
75        DistanceMetric::Haversine,
76    )?;
77
78    println!("3 nearest cities to query point:");
79    for (i, (_point, data, distance)) in nearest.iter().enumerate() {
80        let city_info = String::from_utf8_lossy(data);
81        println!(
82            "  {}. {} ({:.2} km away)",
83            i + 1,
84            city_info,
85            distance / 1000.0
86        );
87    }
88
89    // ========================================
90    // 3. Polygon Queries
91    // ========================================
92    println!("\n3. Polygon Queries");
93    println!("{}", "=".repeat(50));
94
95    // Define a polygon covering parts of the eastern US
96    use geo::polygon;
97    let east_coast_polygon = polygon![
98        (x: -80.0, y: 35.0),  // South
99        (x: -70.0, y: 35.0),  // Southeast
100        (x: -70.0, y: 45.0),  // Northeast
101        (x: -80.0, y: 45.0),  // Northwest
102        (x: -80.0, y: 35.0),  // Close the polygon
103    ];
104    let east_coast_polygon: Polygon = east_coast_polygon.into();
105
106    let cities_in_polygon = db.query_within_polygon("world_cities", &east_coast_polygon, 100)?;
107
108    println!("Cities within East Coast polygon:");
109    for (point, data) in &cities_in_polygon {
110        let city_info = String::from_utf8_lossy(data);
111        println!("  - {} at ({:.4}, {:.4})", city_info, point.x(), point.y());
112    }
113
114    // ========================================
115    // 4. Bounding Box Operations
116    // ========================================
117    println!("\n4. Bounding Box Operations");
118    println!("{}", "=".repeat(50));
119
120    // Create a bounding box around the New York area
121    let ny_bbox = bounding_box(-74.5, 40.5, -73.5, 41.0)?;
122    println!("NY Area Bounding Box: {:?}", ny_bbox);
123
124    // Find cities in bounding box
125    let cities_in_bbox = db.find_within_bounds("world_cities", 40.5, -74.5, 41.0, -73.5, 100)?;
126    println!("\nCities in NY area bounding box:");
127    for (_point, data) in &cities_in_bbox {
128        let city_info = String::from_utf8_lossy(data);
129        println!("  - {}", city_info);
130    }
131
132    // ========================================
133    // 5. Convex Hull
134    // ========================================
135    println!("\n5. Convex Hull Calculation");
136    println!("{}", "=".repeat(50));
137
138    // Get all city points
139    let city_points: Vec<Point> = cities.iter().map(|(p, _, _)| *p).collect();
140
141    // Calculate convex hull
142    if let Some(hull) = convex_hull(&city_points) {
143        println!("Convex hull of all cities:");
144        println!("  Exterior points: {}", hull.exterior().0.len() - 1);
145        for coord in hull.exterior().0.iter().take(5) {
146            println!("    ({:.4}, {:.4})", coord.x, coord.y);
147        }
148    }
149
150    // ========================================
151    // 6. Bounding Rectangle
152    // ========================================
153    println!("\n6. Bounding Rectangle");
154    println!("{}", "=".repeat(50));
155
156    if let Some(bbox) = bounding_rect_for_points(&city_points) {
157        println!("Bounding rectangle of all cities:");
158        println!("  Min: ({:.4}, {:.4})", bbox.min().x, bbox.min().y);
159        println!("  Max: ({:.4}, {:.4})", bbox.max().x, bbox.max().y);
160        println!("  Width:  {:.2}°", bbox.max().x - bbox.min().x);
161        println!("  Height: {:.2}°", bbox.max().y - bbox.min().y);
162    }
163
164    // ========================================
165    // 7. Advanced Radius Queries
166    // ========================================
167    println!("\n7. Advanced Radius Queries");
168    println!("{}", "=".repeat(50));
169
170    // Count cities within 1000km of NYC
171    let count = db.count_within_radius("world_cities", &new_york, 1_000_000.0)?;
172    println!("Cities within 1000km of NYC: {}", count);
173
174    // Check if any cities exist within 100km
175    let has_nearby = db.intersects_radius("world_cities", &new_york, 100_000.0)?;
176    println!("Has cities within 100km of NYC: {}", has_nearby);
177
178    // Query with radius
179    let nearby = db.query_within_radius("world_cities", &new_york, 200_000.0, 10)?;
180    println!("\nCities within 200km of NYC:");
181    for (point, data, _distance) in &nearby {
182        let city_info = String::from_utf8_lossy(data);
183        let dist = distance_between(&new_york, point, DistanceMetric::Haversine);
184        println!("  - {} ({:.2} km)", city_info, dist / 1000.0);
185    }
186
187    // ========================================
188    // 8. Spatial Analytics
189    // ========================================
190    println!("\n8. Spatial Analytics");
191    println!("{}", "=".repeat(50));
192
193    // Find the two most distant cities (brute force)
194    let mut max_distance = 0.0;
195    let mut furthest_pair = ("", "");
196
197    for (i, (p1, n1, _)) in cities.iter().enumerate() {
198        for (p2, n2, _) in cities.iter().skip(i + 1) {
199            let dist = distance_between(p1, p2, DistanceMetric::Geodesic);
200            if dist > max_distance {
201                max_distance = dist;
202                furthest_pair = (n1, n2);
203            }
204        }
205    }
206
207    println!(
208        "Most distant city pair: {} ↔ {}",
209        furthest_pair.0, furthest_pair.1
210    );
211    println!("Distance: {:.2} km", max_distance / 1000.0);
212
213    // Calculate average distance between all US cities
214    let us_cities: Vec<_> = cities
215        .iter()
216        .filter(|(_, _, country)| *country == "USA")
217        .collect();
218
219    if us_cities.len() > 1 {
220        let mut total_distance = 0.0;
221        let mut count = 0;
222
223        for (i, (p1, _, _)) in us_cities.iter().enumerate() {
224            for (p2, _, _) in us_cities.iter().skip(i + 1) {
225                total_distance += distance_between(p1, p2, DistanceMetric::Haversine);
226                count += 1;
227            }
228        }
229
230        let avg_distance = total_distance / count as f64;
231        println!(
232            "\nAverage distance between US cities: {:.2} km",
233            avg_distance / 1000.0
234        );
235    }
236
237    // ========================================
238    // Summary
239    // ========================================
240    println!("\n{}", "=".repeat(50));
241    println!("Summary:");
242    println!("  - Demonstrated multiple distance metrics");
243    println!("  - Performed K-nearest-neighbor searches");
244    println!("  - Queried points within polygons");
245    println!("  - Used bounding box operations");
246    println!("  - Calculated convex hulls");
247    println!("  - Performed spatial analytics");
248    println!("\nAll spatial operations leverage the geo crate!");
249
250    Ok(())
251}
Source

pub fn set_max<C>(&mut self, max: C)
where C: Into<Coord<T>>,

Set the Rect’s maximum coordinate.

§Panics

Panics if max’s x/y is less than the minimum coordinate’s x/y.

Source

pub fn width(self) -> T

Returns the width of the Rect.

§Examples
use geo_types::{coord, Rect};

let rect = Rect::new(
    coord! { x: 5., y: 5. },
    coord! { x: 15., y: 15. },
);

assert_eq!(rect.width(), 10.);
Source

pub fn height(self) -> T

Returns the height of the Rect.

§Examples
use geo_types::{coord, Rect};

let rect = Rect::new(
    coord! { x: 5., y: 5. },
    coord! { x: 15., y: 15. },
);

assert_eq!(rect.height(), 10.);
Source

pub fn to_polygon(self) -> Polygon<T>

Create a Polygon from the Rect.

§Examples
use geo_types::{coord, Rect, polygon};

let rect = Rect::new(
    coord! { x: 0., y: 0. },
    coord! { x: 1., y: 2. },
);

// Output is CCW
assert_eq!(
    rect.to_polygon(),
    polygon![
        (x: 1., y: 0.),
        (x: 1., y: 2.),
        (x: 0., y: 2.),
        (x: 0., y: 0.),
        (x: 1., y: 0.),
    ],
);
Source

pub fn to_lines(&self) -> [Line<T>; 4]

Source

pub fn split_x(self) -> [Rect<T>; 2]

Split a rectangle into two rectangles along the X-axis with equal widths.

§Examples
let rect = geo_types::Rect::new(
    geo_types::coord! { x: 0., y: 0. },
    geo_types::coord! { x: 4., y: 4. },
);

let [rect1, rect2] = rect.split_x();

assert_eq!(
    geo_types::Rect::new(
        geo_types::coord! { x: 0., y: 0. },
        geo_types::coord! { x: 2., y: 4. },
    ),
    rect1,
);
assert_eq!(
    geo_types::Rect::new(
        geo_types::coord! { x: 2., y: 0. },
        geo_types::coord! { x: 4., y: 4. },
    ),
    rect2,
);
Source

pub fn split_y(self) -> [Rect<T>; 2]

Split a rectangle into two rectangles along the Y-axis with equal heights.

§Examples
let rect = geo_types::Rect::new(
    geo_types::coord! { x: 0., y: 0. },
    geo_types::coord! { x: 4., y: 4. },
);

let [rect1, rect2] = rect.split_y();

assert_eq!(
    geo_types::Rect::new(
        geo_types::coord! { x: 0., y: 0. },
        geo_types::coord! { x: 4., y: 2. },
    ),
    rect1,
);
assert_eq!(
    geo_types::Rect::new(
        geo_types::coord! { x: 0., y: 2. },
        geo_types::coord! { x: 4., y: 4. },
    ),
    rect2,
);
Source§

impl<T> Rect<T>
where T: CoordFloat,

Source

pub fn center(self) -> Coord<T>

Returns the center Coord of the Rect.

§Examples
use geo_types::{coord, Rect};

let rect = Rect::new(
    coord! { x: 5., y: 5. },
    coord! { x: 15., y: 15. },
);

assert_eq!(rect.center(), coord! { x: 10., y: 10. });

Trait Implementations§

Source§

impl<T> AbsDiffEq for Rect<T>
where T: CoordNum + AbsDiffEq<Epsilon = T>,

Source§

fn abs_diff_eq( &self, other: &Rect<T>, epsilon: <Rect<T> as AbsDiffEq>::Epsilon, ) -> bool

Equality assertion with an absolute limit.

§Examples
use geo_types::{point, Rect};

let a = Rect::new((0.0, 0.0), (10.0, 10.0));
let b = Rect::new((0.0, 0.0), (10.01, 10.0));

approx::abs_diff_eq!(a, b, epsilon=0.1);
approx::abs_diff_ne!(a, b, epsilon=0.001);
Source§

type Epsilon = T

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> <Rect<T> as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl<T> Area<T> for Rect<T>
where T: CoordNum,

Because a Rect has no winding order, the area will always be positive.

Source§

fn signed_area(&self) -> T

Source§

fn unsigned_area(&self) -> T

Source§

impl<T> BoundingRect<T> for Rect<T>
where T: CoordNum,

Source§

type Output = Rect<T>

Source§

fn bounding_rect(&self) -> <Rect<T> as BoundingRect<T>>::Output

Return the bounding rectangle of a geometry Read more
Source§

impl<F> Buffer for Rect<F>
where F: BoolOpsNum + 'static,

Source§

type Scalar = F

Source§

fn buffer_with_style( &self, style: BufferStyle<<Rect<F> as Buffer>::Scalar>, ) -> MultiPolygon<<Rect<F> as Buffer>::Scalar>

Create a new geometry whose boundary is offset the specified distance from the input using the specific styling options where lines intersect (line joins) and end (end caps). For default (rounded) styling, see buffer. Read more
Source§

fn buffer(&self, distance: Self::Scalar) -> MultiPolygon<Self::Scalar>

Create a new geometry whose boundary is offset the specified distance from the input. Read more
Source§

impl<T> Centroid for Rect<T>
where T: GeoFloat,

Source§

fn centroid(&self) -> <Rect<T> as Centroid>::Output

The Centroid of a Rect is the mean of its Points

§Examples
use geo::Centroid;
use geo::{Rect, point};

let rect = Rect::new(
  point!(x: 0.0f32, y: 0.0),
  point!(x: 1.0, y: 1.0),
);

assert_eq!(
    point!(x: 0.5, y: 0.5),
    rect.centroid(),
);
Source§

type Output = Point<T>

Source§

impl<T> ChamberlainDuquetteArea<T> for Rect<T>
where T: CoordFloat,

Source§

impl<T> Clone for Rect<T>
where T: Clone + CoordNum,

Source§

fn clone(&self) -> Rect<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F> ClosestPoint<F> for Rect<F>
where F: GeoFloat,

Source§

fn closest_point(&self, p: &Point<F>) -> Closest<F>

Find the closest point between self and p.
Source§

impl<T> Contains<Coord<T>> for Rect<T>
where T: CoordNum,

Source§

fn contains(&self, coord: &Coord<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<GeometryCollection<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, target: &GeometryCollection<T>) -> bool

Source§

impl<T> Contains<Line<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, target: &Line<T>) -> bool

Source§

impl<T> Contains<LineString<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, target: &LineString<T>) -> bool

Source§

impl<T> Contains<MultiLineString<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, target: &MultiLineString<T>) -> bool

Source§

impl<T> Contains<MultiPoint<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, target: &MultiPoint<T>) -> bool

Source§

impl<T> Contains<MultiPolygon<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, target: &MultiPolygon<T>) -> bool

Source§

impl<T> Contains<Point<T>> for Rect<T>
where T: CoordNum,

Source§

fn contains(&self, p: &Point<T>) -> bool

Source§

impl<T> Contains<Polygon<T>> for Rect<T>
where T: CoordFloat,

Source§

fn contains(&self, rhs: &Polygon<T>) -> bool

Source§

impl<T> Contains<Triangle<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, target: &Triangle<T>) -> bool

Source§

impl<T> Contains for Rect<T>
where T: CoordNum,

Source§

fn contains(&self, other: &Rect<T>) -> bool

Source§

impl<T> CoordinatePosition for Rect<T>
where T: GeoNum,

Source§

type Scalar = T

Source§

fn calculate_coordinate_position( &self, coord: &Coord<T>, is_inside: &mut bool, boundary_count: &mut usize, )

Source§

fn coordinate_position(&self, coord: &Coord<Self::Scalar>) -> CoordPos

Source§

impl<T> CoordsIter for Rect<T>
where T: CoordNum,

Source§

fn coords_iter(&self) -> <Rect<T> as CoordsIter>::Iter<'_>

Iterates over the coordinates in CCW order

Source§

fn coords_count(&self) -> usize

Return the number of coordinates in the Rect.

Note: Although a Rect is represented by two coordinates, it is spatially represented by four, so this method returns 4.

Source§

type Iter<'a> = Chain<Chain<Chain<Once<Coord<T>>, Once<Coord<T>>>, Once<Coord<T>>>, Once<Coord<T>>> where T: 'a

Source§

type ExteriorIter<'a> = <Rect<T> as CoordsIter>::Iter<'a> where T: 'a

Source§

type Scalar = T

Source§

fn exterior_coords_iter(&self) -> <Rect<T> as CoordsIter>::ExteriorIter<'_>

Iterate over all exterior coordinates of a geometry. Read more
Source§

impl<T> Debug for Rect<T>
where T: CoordNum,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<F> Densifiable<F> for Rect<F>

Source§

type Output = Polygon<F>

Source§

fn densify<MetricSpace>( &self, metric_space: &MetricSpace, max_segment_length: F, ) -> <Rect<F> as Densifiable<F>>::Output
where MetricSpace: Distance<F, Point<F>, Point<F>> + InterpolatePoint<F>,

Source§

impl<T> DensifyHaversine<T> for Rect<T>

Source§

type Output = Polygon<T>

👎Deprecated since 0.29.0: Please use the Haversine.densify(&line) via the Densify trait instead.
Source§

fn densify_haversine( &self, max_distance: T, ) -> <Rect<T> as DensifyHaversine<T>>::Output

👎Deprecated since 0.29.0: Please use the Haversine.densify(&line) via the Densify trait instead.
Source§

impl<'de, T> Deserialize<'de> for Rect<T>
where T: CoordNum + Deserialize<'de>,

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Rect<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> EuclideanDistance<T> for Rect<T>

Source§

fn euclidean_distance(&self, other: &Rect<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, Geometry<T>> for Rect<T>

Source§

fn euclidean_distance(&self, geom: &Geometry<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, GeometryCollection<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &GeometryCollection<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, Line<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &Line<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, LineString<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &LineString<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, MultiLineString<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &MultiLineString<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, MultiPoint<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &MultiPoint<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, MultiPolygon<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &MultiPolygon<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, Point<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &Point<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, Polygon<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &Polygon<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl<T> EuclideanDistance<T, Triangle<T>> for Rect<T>

Source§

fn euclidean_distance(&self, other: &Triangle<T>) -> T

👎Deprecated since 0.29.0: Please use the Euclidean.distance method from the Distance trait instead
Returns the distance between two geometries Read more
Source§

impl GeodesicArea<f64> for Rect

Source§

fn geodesic_perimeter(&self) -> f64

Determine the perimeter of a geometry on an ellipsoidal model of the earth. Read more
Source§

fn geodesic_area_signed(&self) -> f64

Determine the area of a geometry on an ellipsoidal model of the earth. Read more
Source§

fn geodesic_area_unsigned(&self) -> f64

Determine the area of a geometry on an ellipsoidal model of the earth. Supports very large geometries that cover a significant portion of the earth. Read more
Source§

fn geodesic_perimeter_area_signed(&self) -> (f64, f64)

Determine the perimeter and area of a geometry on an ellipsoidal model of the earth, all in one operation. Read more
Source§

fn geodesic_perimeter_area_unsigned(&self) -> (f64, f64)

Determine the perimeter and area of a geometry on an ellipsoidal model of the earth, all in one operation. Supports very large geometries that cover a significant portion of the earth. Read more
Source§

impl<C> HasDimensions for Rect<C>
where C: CoordNum,

Source§

fn is_empty(&self) -> bool

Some geometries, like a MultiPoint, can have zero coordinates - we call these empty. Read more
Source§

fn dimensions(&self) -> Dimensions

The dimensions of some geometries are fixed, e.g. a Point always has 0 dimensions. However for others, the dimensionality depends on the specific geometry instance - for example typical Rects are 2-dimensional, but it’s possible to create degenerate Rects which have either 1 or 0 dimensions. Read more
Source§

fn boundary_dimensions(&self) -> Dimensions

The dimensions of the Geometry’s boundary, as used by OGC-SFA. Read more
Source§

impl<T> Hash for Rect<T>
where T: Hash + CoordNum,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> HaversineClosestPoint<T> for Rect<T>

Source§

fn haversine_closest_point(&self, from: &Point<T>) -> Closest<T>

Source§

impl<T> InteriorPoint for Rect<T>
where T: GeoFloat,

Source§

type Output = Point<T>

Source§

fn interior_point(&self) -> <Rect<T> as InteriorPoint>::Output

Calculates a representative point inside the Geometry Read more
Source§

impl<T> Intersects<Coord<T>> for Rect<T>
where T: CoordNum,

Source§

fn intersects(&self, rhs: &Coord<T>) -> bool

Source§

impl<T> Intersects<Geometry<T>> for Rect<T>
where Geometry<T>: Intersects<Rect<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &Geometry<T>) -> bool

Source§

impl<T> Intersects<GeometryCollection<T>> for Rect<T>

Source§

impl<T> Intersects<Line<T>> for Rect<T>
where T: GeoNum,

Source§

fn intersects(&self, rhs: &Line<T>) -> bool

Source§

impl<T> Intersects<LineString<T>> for Rect<T>
where LineString<T>: Intersects<Rect<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &LineString<T>) -> bool

Source§

impl<T> Intersects<MultiLineString<T>> for Rect<T>

Source§

fn intersects(&self, rhs: &MultiLineString<T>) -> bool

Source§

impl<T> Intersects<MultiPoint<T>> for Rect<T>
where MultiPoint<T>: Intersects<Rect<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &MultiPoint<T>) -> bool

Source§

impl<T> Intersects<MultiPolygon<T>> for Rect<T>

Source§

fn intersects(&self, rhs: &MultiPolygon<T>) -> bool

Source§

impl<T> Intersects<Point<T>> for Rect<T>
where Point<T>: Intersects<Rect<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &Point<T>) -> bool

Source§

impl<T> Intersects<Polygon<T>> for Rect<T>
where Polygon<T>: Intersects<Rect<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &Polygon<T>) -> bool

Source§

impl<T> Intersects<Triangle<T>> for Rect<T>
where T: GeoNum,

Source§

fn intersects(&self, rhs: &Triangle<T>) -> bool

Source§

impl<T> Intersects for Rect<T>
where T: CoordNum,

Source§

fn intersects(&self, other: &Rect<T>) -> bool

Source§

impl<'a, T> LinesIter<'a> for Rect<T>
where T: CoordNum + 'a,

Source§

type Scalar = T

Source§

type Iter = <[Line<<Rect<T> as LinesIter<'a>>::Scalar>; 4] as IntoIterator>::IntoIter

Source§

fn lines_iter(&'a self) -> <Rect<T> as LinesIter<'a>>::Iter

Iterate over all exterior and (if any) interior lines of a geometry. Read more
Source§

impl<T, NT> MapCoords<T, NT> for Rect<T>
where T: CoordNum, NT: CoordNum,

Source§

type Output = Rect<NT>

Source§

fn map_coords( &self, func: impl Fn(Coord<T>) -> Coord<NT> + Copy, ) -> <Rect<T> as MapCoords<T, NT>>::Output

Apply a function to all the coordinates in a geometric object, returning a new object. Read more
Source§

fn try_map_coords<E>( &self, func: impl Fn(Coord<T>) -> Result<Coord<NT>, E>, ) -> Result<<Rect<T> as MapCoords<T, NT>>::Output, E>

Map a fallible function over all the coordinates in a geometry, returning a Result Read more
Source§

impl<T> MapCoordsInPlace<T> for Rect<T>
where T: CoordNum,

Source§

fn map_coords_in_place(&mut self, func: impl Fn(Coord<T>) -> Coord<T>)

Apply a function to all the coordinates in a geometric object, in place Read more
Source§

fn try_map_coords_in_place<E>( &mut self, func: impl Fn(Coord<T>) -> Result<Coord<T>, E>, ) -> Result<(), E>

Map a fallible function over all the coordinates in a geometry, in place, returning a Result. Read more
Source§

impl<T> PartialEq for Rect<T>
where T: PartialEq + CoordNum,

Source§

fn eq(&self, other: &Rect<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F> Relate<F> for Rect<F>
where F: GeoFloat,

Source§

fn geometry_graph(&self, arg_index: usize) -> GeometryGraph<'_, F>

Returns a noded topology graph for the geometry. Read more
Source§

fn relate(&self, other: &impl Relate<F>) -> IntersectionMatrix
where Self: Sized,

Source§

impl<T> RelativeEq for Rect<T>
where T: CoordNum + RelativeEq<Epsilon = T>,

Source§

fn relative_eq( &self, other: &Rect<T>, epsilon: <Rect<T> as AbsDiffEq>::Epsilon, max_relative: <Rect<T> as AbsDiffEq>::Epsilon, ) -> bool

Equality assertion within a relative limit.

§Examples
use geo_types::Rect;

let a = Rect::new((0.0, 0.0), (10.0, 10.0));
let b = Rect::new((0.0, 0.0), (10.01, 10.0));

approx::assert_relative_eq!(a, b, max_relative=0.1);
approx::assert_relative_ne!(a, b, max_relative=0.0001);
Source§

fn default_max_relative() -> <Rect<T> as AbsDiffEq>::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl<T> RemoveRepeatedPoints<T> for Rect<T>
where T: CoordNum,

Source§

fn remove_repeated_points(&self) -> Rect<T>

Create a new geometry with (consecutive) repeated points removed.
Source§

fn remove_repeated_points_mut(&mut self)

Remove (consecutive) repeated points inplace.
Source§

impl<T> Serialize for Rect<T>
where T: CoordNum + Serialize,

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> TryFrom<Geometry<T>> for Rect<T>
where T: CoordNum,

Convert a Geometry enum into its inner type.

Fails if the enum case does not match the type you are trying to convert it to.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<Rect<T>, <Rect<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T> UlpsEq for Rect<T>
where T: CoordNum + UlpsEq<Epsilon = T>,

Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_eq( &self, other: &Rect<T>, epsilon: <Rect<T> as AbsDiffEq>::Epsilon, max_ulps: u32, ) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.
Source§

impl<F> Validation for Rect<F>
where F: GeoFloat,

Source§

type Error = InvalidRect

Source§

fn visit_validation<T>( &self, handle_validation_error: Box<dyn FnMut(<Rect<F> as Validation>::Error) -> Result<(), T> + '_>, ) -> Result<(), T>

Visit the validation of the geometry. Read more
Source§

fn is_valid(&self) -> bool

Check if the geometry is valid.
Source§

fn validation_errors(&self) -> Vec<Self::Error>

Return the reason(s) of invalidity of the geometry. Read more
Source§

fn check_validation(&self) -> Result<(), Self::Error>

Return the first reason of invalidity of the geometry.
Source§

impl<T> Copy for Rect<T>
where T: Copy + CoordNum,

Source§

impl<T> Eq for Rect<T>
where T: Eq + CoordNum,

Source§

impl<T> StructuralPartialEq for Rect<T>
where T: CoordNum,

Auto Trait Implementations§

§

impl<T> Freeze for Rect<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Rect<T>
where T: RefUnwindSafe,

§

impl<T> Send for Rect<T>
where T: Send,

§

impl<T> Sync for Rect<T>
where T: Sync,

§

impl<T> Unpin for Rect<T>
where T: Unpin,

§

impl<T> UnwindSafe for Rect<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T, M> AffineOps<T> for M
where T: CoordNum, M: MapCoordsInPlace<T> + MapCoords<T, T, Output = M>,

Source§

fn affine_transform(&self, transform: &AffineTransform<T>) -> M

Apply transform immutably, outputting a new geometry.
Source§

fn affine_transform_mut(&mut self, transform: &AffineTransform<T>)

Apply transform to mutate self.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<G, T, U> Convert<T, U> for G
where T: CoordNum, U: CoordNum + From<T>, G: MapCoords<T, U>,

Source§

type Output = <G as MapCoords<T, U>>::Output

Source§

fn convert(&self) -> <G as Convert<T, U>>::Output

Source§

impl<'a, T, G> ConvexHull<'a, T> for G
where T: GeoNum, G: CoordsIter<Scalar = T>,

Source§

type Scalar = T

Source§

fn convex_hull(&'a self) -> Polygon<T>

Source§

impl<'a, T, G> Extremes<'a, T> for G
where G: CoordsIter<Scalar = T>, T: CoordNum,

Source§

fn extremes(&'a self) -> Option<Outcome<T>>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, G> HausdorffDistance<T> for G
where T: GeoFloat, G: CoordsIter<Scalar = T>,

Source§

fn hausdorff_distance<Rhs>(&self, rhs: &Rhs) -> T
where Rhs: CoordsIter<Scalar = T>,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, G> MinimumRotatedRect<T> for G
where T: CoordFloat + GeoFloat + GeoNum, G: CoordsIter<Scalar = T>,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<G, IP, IR, T> Rotate<T> for G
where T: CoordFloat, IP: Into<Option<Point<T>>>, IR: Into<Option<Rect<T>>>, G: Clone + Centroid<Output = IP> + BoundingRect<T, Output = IR> + AffineOps<T>,

Source§

fn rotate_around_centroid(&self, degrees: T) -> G

Rotate a geometry around its centroid by an angle, in degrees Read more
Source§

fn rotate_around_centroid_mut(&mut self, degrees: T)

Mutable version of Self::rotate_around_centroid
Source§

fn rotate_around_center(&self, degrees: T) -> G

Rotate a geometry around the center of its bounding box by an angle, in degrees. Read more
Source§

fn rotate_around_center_mut(&mut self, degrees: T)

Mutable version of Self::rotate_around_center
Source§

fn rotate_around_point(&self, degrees: T, point: Point<T>) -> G

Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more
Source§

fn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)

Mutable version of Self::rotate_around_point
Source§

impl<T, IR, G> Scale<T> for G
where T: CoordFloat, IR: Into<Option<Rect<T>>>, G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,

Source§

fn scale(&self, scale_factor: T) -> G

Scale a geometry from it’s bounding box center. Read more
Source§

fn scale_mut(&mut self, scale_factor: T)

Mutable version of scale
Source§

fn scale_xy(&self, x_factor: T, y_factor: T) -> G

Scale a geometry from it’s bounding box center, using different values for x_factor and y_factor to distort the geometry’s aspect ratio. Read more
Source§

fn scale_xy_mut(&mut self, x_factor: T, y_factor: T)

Mutable version of scale_xy.
Source§

fn scale_around_point( &self, x_factor: T, y_factor: T, origin: impl Into<Coord<T>>, ) -> G

Scale a geometry around a point of origin. Read more
Source§

fn scale_around_point_mut( &mut self, x_factor: T, y_factor: T, origin: impl Into<Coord<T>>, )

Mutable version of scale_around_point.
Source§

impl<T, IR, G> Skew<T> for G
where T: CoordFloat, IR: Into<Option<Rect<T>>>, G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,

Source§

fn skew(&self, degrees: T) -> G

An affine transformation which skews a geometry, sheared by a uniform angle along the x and y dimensions. Read more
Source§

fn skew_mut(&mut self, degrees: T)

Mutable version of skew.
Source§

fn skew_xy(&self, degrees_x: T, degrees_y: T) -> G

An affine transformation which skews a geometry, sheared by an angle along the x and y dimensions. Read more
Source§

fn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)

Mutable version of skew_xy.
Source§

fn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coord<T>>) -> G

An affine transformation which skews a geometry around a point of origin, sheared by an angle along the x and y dimensions. Read more
Source§

fn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coord<T>>)

Mutable version of skew_around_point.
Source§

impl<T, G> ToDegrees<T> for G
where T: CoordFloat, G: MapCoords<T, T, Output = G> + MapCoordsInPlace<T>,

Source§

fn to_degrees(&self) -> Self

Source§

fn to_degrees_in_place(&mut self)

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, G> ToRadians<T> for G
where T: CoordFloat, G: MapCoords<T, T, Output = G> + MapCoordsInPlace<T>,

Source§

fn to_radians(&self) -> Self

Source§

fn to_radians_in_place(&mut self)

Source§

impl<T, G> Translate<T> for G
where T: CoordNum, G: AffineOps<T>,

Source§

fn translate(&self, x_offset: T, y_offset: T) -> G

Translate a Geometry along its axes by the given offsets Read more
Source§

fn translate_mut(&mut self, x_offset: T, y_offset: T)

Translate a Geometry along its axes, but in place.
Source§

impl<'a, T, G> TriangulateDelaunay<'a, T> for G
where T: SpadeTriangulationFloat, G: TriangulationRequirementTrait<'a, T>,

Source§

fn unconstrained_triangulation( &'a self, ) -> Result<Vec<Triangle<T>>, TriangulationError>

returns a triangulation that’s solely based on the points of the geometric object Read more
Source§

fn constrained_outer_triangulation( &'a self, config: DelaunayTriangulationConfig<T>, ) -> Result<Vec<Triangle<T>>, TriangulationError>

returns triangulation that’s based on the points of the geometric object and also incorporates the lines of the input geometry Read more
Source§

fn constrained_triangulation( &'a self, config: DelaunayTriangulationConfig<T>, ) -> Result<Vec<Triangle<T>>, TriangulationError>

returns triangulation that’s based on the points of the geometric object and also incorporates the lines of the input geometry Read more
Source§

impl<'a, T, G> TriangulateSpade<'a, T> for G
where T: SpadeTriangulationFloat, G: TriangulationRequirementTrait<'a, T>,

Source§

fn unconstrained_triangulation( &'a self, ) -> Result<Vec<Triangle<T>>, TriangulationError>

👎Deprecated since 0.29.4: please use the triangulate_delaunay module instead
returns a triangulation that’s solely based on the points of the geometric object Read more
Source§

fn constrained_outer_triangulation( &'a self, config: SpadeTriangulationConfig<T>, ) -> Result<Vec<Triangle<T>>, TriangulationError>

👎Deprecated since 0.29.4: please use the triangulate_delaunay module instead
returns triangulation that’s based on the points of the geometric object and also incorporates the lines of the input geometry Read more
Source§

fn constrained_triangulation( &'a self, config: SpadeTriangulationConfig<T>, ) -> Result<Vec<Triangle<T>>, TriangulationError>

👎Deprecated since 0.29.4: please use the triangulate_delaunay module instead
returns triangulation that’s based on the points of the geometric object and also incorporates the lines of the input geometry Read more
Source§

impl<G, T, U> TryConvert<T, U> for G
where T: CoordNum, U: CoordNum + TryFrom<T>, G: MapCoords<T, U>,

Source§

type Output = Result<<G as MapCoords<T, U>>::Output, <U as TryFrom<T>>::Error>

Source§

fn try_convert(&self) -> <G as TryConvert<T, U>>::Output

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,