New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haversine formula fix #2408

Merged
merged 3 commits into from Oct 5, 2017

Conversation

Projects
None yet
3 participants
@pomadchin
Member

pomadchin commented Oct 5, 2017

Fixes #2383

@pomadchin pomadchin requested a review from echeipesh Oct 5, 2017

package geotrellis.util
object Haversine {
val EARTH_RADIUS = 6378137d // Use what gdal2tiles uses.

This comment has been minimized.

@metasim

metasim Oct 5, 2017

Member

I'd suggest adding a doc comment declaring the units used.

val EARTH_RADIUS = 6378137d // Use what gdal2tiles uses.
// (x: Double, y: Double) points
def apply(start: (Double, Double), end: (Double, Double), R: Double = EARTH_RADIUS): Double = {

This comment has been minimized.

@metasim

metasim Oct 5, 2017

Member

For future GeoTrellisites, I'd suggest a doc comment indicating what the components of start and end are. e.g. (Latitude, Longitude), or (Longitude, Latitude) or (radius, angle), etc.

@@ -31,6 +31,9 @@ object Point {
implicit def jtsCoord2Point(coord: jts.Coordinate): Point =
Point(factory.createPoint(coord))
implicit def pointToTuple2(point: Point): (Double, Double) =

This comment has been minimized.

@metasim

metasim Oct 5, 2017

Member

While this is a nice convenience for people familiar with the particular code that translates between Point and Tuple2, I've been burned enough by unexpected or unintended conversions in the past to avoid this sort of thing personally, especially when the conversion is to a more general type. If you were converting between Point and something like Position(lat, lng) I'd be a bit less concerned because the translation semantics of x -> lat and y -> lng are clear, but _1 and _2 have no inherent semantics and therefore information is lost in the implicit conversion.

This comment has been minimized.

@pomadchin

pomadchin Oct 5, 2017

Member

Yes, i decided to remove this implicit at all as it is indeed ambiguous.

@pomadchin pomadchin added this to the 1.2 milestone Oct 5, 2017

@pomadchin pomadchin force-pushed the pomadchin:fix/haversine branch from 3ffde37 to 79dd8af Oct 5, 2017

@pomadchin

This comment has been minimized.

Member

pomadchin commented Oct 5, 2017

@metasim do you have any additional comments?

@metasim

metasim approved these changes Oct 5, 2017

@pomadchin pomadchin force-pushed the pomadchin:fix/haversine branch from 79dd8af to e28762f Oct 5, 2017

@echeipesh echeipesh merged commit cdaa151 into locationtech:master Oct 5, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
ip-validation
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment