Skip to content

Haversine formula fix - #2408

Merged
echeipesh merged 3 commits into
locationtech:masterfrom
pomadchin:fix/haversine
Oct 5, 2017
Merged

echeipesh merged 3 commits into
locationtech:masterfrom
pomadchin:fix/haversine

Conversation

@pomadchin

Copy link
Copy Markdown
Member

Fixes #2383

@pomadchin
pomadchin requested a review from echeipesh October 5, 2017 08:59
package geotrellis.util

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

implicit def jtsCoord2Point(coord: jts.Coordinate): Point =
Point(factory.createPoint(coord))

implicit def pointToTuple2(point: Point): (Double, Double) =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 commented Oct 5, 2017 •

Copy link
Copy Markdown
Member Author

@metasim do you have any additional comments?

@echeipesh
echeipesh merged commit cdaa151 into locationtech:master Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants