-
Notifications
You must be signed in to change notification settings - Fork 239
Added distance and elevation (min/max) computation #38
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
Open
thePanz
wants to merge
9
commits into
labexp:master
Choose a base branch
from
thePanz:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
53d6bd0
Added distance and elevation (min/max) computation
thePanz 0b5869f
Fix: fixed wrong RADIUS_EARTH_METERS value
thePanz f059d3f
Fixes for numeric types (using Float instead of Double)
thePanz 4ad2288
Using Float for distance computation instead of Double
thePanz 87bf1f3
Added speed (GPS data) display
thePanz 1b25ff1
Added option to avoid counting zero-value speeds
thePanz fb9d3b0
Added speed (Km/h) and elevation (m) units with localized formetter
thePanz 90ba53a
Fix: do not compute Track statistics when not needed!
thePanz 33bf8b8
Fix: fixed distance computation formula, avoid NaN for Math.acos() fu…
thePanz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/me/guillaumin/android/osmtracker/util/DistanceUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.guillaumin.android.osmtracker.util; | ||
|
||
public class DistanceUtil { | ||
|
||
private static final double DEG2RAD = Math.PI / 180.0; | ||
// private static final double RAD2DEG = 180.0 / Math.PI; | ||
private static final double RADIUS_EARTH_METERS = 6371.01; | ||
|
||
/** | ||
* Computes the distance with Spherical Law of Cosines | ||
* http://www.movable-type.co.uk/scripts/latlong.html | ||
* @param lat1 | ||
* @param lon1 | ||
* @param lat2 | ||
* @param lon2 | ||
* @return The distance (in meters) between point1 and point2 | ||
*/ | ||
public static double getDistance(final double lat1, final double lon1, final double lat2, final double lon2) { | ||
double theta = lon1 - lon2; | ||
double a = Math.sin(DEG2RAD * lat1) * Math.sin(DEG2RAD * lat2); | ||
double b = Math.cos(DEG2RAD * lat1) * Math.cos(DEG2RAD * lat2) * Math.cos(DEG2RAD * theta); | ||
|
||
return Math.acos(a + b) * RADIUS_EARTH_METERS; | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value is expressed in Km, so the final computation do not need to convert from meters.
The correct "meters" values is 63781370.0