Comments (6)
I'll be conservative and say out of bounds long should also be an Err as it might indicate problems with the input data – it's better to draw attention to the problem there and then than rely on the fact that it happens to wrap correctly imo.
from geo.
Note that this is using geo v 0.26.0
from geo.
This third one actually seems reasonable to me:
#[test]
fn x_out_of_range() {
// x is out of long rannge but will compute fine
let x = point!( x: -361_f64 , y: 0_f64);
let y = point!( x: 0_f64 , y: 0_f64);
assert!(!x.geodesic_bearing(y).is_nan())
}
Longitude is just being wrapped.
e.g.
#[test]
fn x_out_of_range() {
// x is out of long rannge but will compute fine
let x = point!( x: -361_f64 , y: 0_f64);
let y = point!( x: 0_f64 , y: 0_f64);
assert!(!x.geodesic_bearing(y).is_nan())
let x_simplified = point!( x: -1_f64 , y: 0_f64);
assert_eq!(x.geodesic_bearing(y), x_simplified.geodesic_bearing(y))
}
That results hold true for haversine and geodesic bearing, which seems arguably reasonable to me. Do you think anything should change about that example?
The first two, with latitude out of bounds, seem more problematic - how should we handle nonsense input?
geodesic_bearing is returning f64::NaN, which is probably mostly an artifact of being ported from c++, but at least it indicates "something is wrong here". In rust a Result<f64>
type would probably be more idiomatic.
But with the haversine implementation - it seems like it's just garbage output right? Is there any world where you can get a meaningful result from a latitude more than 90º?
My inclination at this point is, for both HaversineBearing and GeodesicBearing:
- return an Err if the input latitude is out of bounds.
- proceed as normal if the longitude is out of bounds, knowing that the math will effectively
mod 360
the results.
Changing the return type would be a breaking change.
from geo.
HaversineBearing and GeodesicBearing recently superceded Bearing
as a breaking change. I think returning Result<f64>
would be an appropriate api change and within a short enough time period to be "stabilized." I would agree with @urschrei here—return an Err
even though the calculation can continue but probably shouldn't.
from geo.
Hey, can this be assigned to me?
- Checking input parameters for lat lon
- Returning a Result<f64, Err>
Should I make a custom Err?
from geo.
Hey, I'm stuck and I need some help!
I opened PR #1161
If you could take a look and give me a hand, I would really appreciate it.
from geo.
Related Issues (20)
- MultiPoint::len
- Panic in BooleanOps::union for Polygon<f32> HOT 2
- VecSet may cause panics HOT 7
- Proposal: Common abstraction layer for collection types (via `Deref` and `DerefMut`) HOT 2
- Add delauney triangulation algorithm to root `geo` crate docs index
- Thoughts on algorithms for trait-based geometries
- concave_hull returns nonsense results for simple polygons HOT 1
- Panic in RegionAssembly reproducibly HOT 4
- Clarify that current cross-track distance uses spherical (Haversine) earth model, add Ellipsoidal (Vincenty) version HOT 2
- Missing `contains` implementations
- `is_valid` for all geometry types. HOT 3
- Problems building with Rust 1.75.0 HOT 1
- Add is_equal_topo method to IntersectionMatrix to determine topological equality
- How to calculate intersection area of two rotated rectangles? HOT 2
- Missing PointZ implementations HOT 1
- Latest ahash dep and Rust 1.70.0 are incompatible HOT 4
- 3D (3-dimensional) data types HOT 2
- Rhumb destinations do not wrap angles after the first pole intersection HOT 8
- GeodesicDestination produces cyclcically incosistent results HOT 5
- Expose fields in AffineTransform struct (or have a way to access the internal values)? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geo.