You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I looked at the line/polygon intersection code, and it appears to fall back on a coordinate-based bounding box. However, for spherical coordinates, that will not work.
The minimum example is:
use geo::Contains;
use geo::Distance;
use geo::Bearing;
use geo::Destination;
use geo::Intersects;
use geo::Haversine;
use geo::point;
use geo::Polygon;
fn main() {
let eu = point!(x: 1.0, y: 45.0);
let in_pacific = point!(x:179.0, y: 45.0);
let line = geo::Line::new(eu, in_pacific);
let poly_exterior = geo::LineString::from(vec![
point!(x: 89.0, y: 44.0),
point!(x: 89.0, y: 46.0),
point!(x: 91.0, y: 46.0),
point!(x: 91.0, y: 44.0),
point!(x: 89.0, y: 44.0),
]);
let poly = Polygon::new(
poly_exterior,
vec![],
);
println!("Line intersects polygon: {}", line.intersects(&poly));
use geo::Length;
let length = line.length::<geo::Haversine>();
println!("Length of line: {}", length);
let bearing = Haversine::bearing(eu, in_pacific);
let distance = Haversine::distance(eu, in_pacific);
let midpoint = Haversine::destination(eu, bearing, distance / 2.0);
println!("Midpoint of line: {:?}", midpoint);
println!("Midpoint in polygon? {}", poly.contains(&midpoint));
//let why_not = Haversine::intersects(&line, &poly);
}
Output:
Line intersects polygon: true
Length of line: 10005616.697776927
Midpoint of line: Point(Coord { x: 90.00000000000023, y: 89.00015227392285 })
Midpoint in polygon? false
The text was updated successfully, but these errors were encountered:
geo doesn't support any intersection calculations for spherical geometries, and does not itself provide any spherical geometry types (see the documentation for the geometry primitives for details of their semantics).
Point-distance and some related measures are provided for metric spaces other than Euclidean: see the metric spaces module docs.
I looked at the line/polygon intersection code, and it appears to fall back on a coordinate-based bounding box. However, for spherical coordinates, that will not work.
The minimum example is:
Output:
The text was updated successfully, but these errors were encountered: