aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/cgeonavigate.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgeo/geocaching/cgeonavigate.java')
-rw-r--r--src/cgeo/geocaching/cgeonavigate.java52
1 files changed, 22 insertions, 30 deletions
diff --git a/src/cgeo/geocaching/cgeonavigate.java b/src/cgeo/geocaching/cgeonavigate.java
index 6beaef7..f8b17e6 100644
--- a/src/cgeo/geocaching/cgeonavigate.java
+++ b/src/cgeo/geocaching/cgeonavigate.java
@@ -1,10 +1,8 @@
package cgeo.geocaching;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
import org.apache.commons.lang3.StringUtils;
@@ -22,6 +20,7 @@ import android.view.SubMenu;
import android.view.WindowManager;
import android.widget.TextView;
import cgeo.geocaching.activity.AbstractActivity;
+import cgeo.geocaching.geopoint.Geopoint;
public class cgeonavigate extends AbstractActivity {
@@ -32,8 +31,7 @@ public class cgeonavigate extends AbstractActivity {
private cgDirection dir = null;
private cgUpdateLoc geoUpdate = new update();
private cgUpdateDir dirUpdate = new UpdateDirection();
- private Double dstLatitude = null;
- private Double dstLongitude = null;
+ private Geopoint dstCoords = null;
private Double cacheHeading = Double.valueOf(0);
private Double northHeading = Double.valueOf(0);
private String title = null;
@@ -87,8 +85,7 @@ public class cgeonavigate extends AbstractActivity {
if (extras != null) {
title = extras.getString("geocode");
name = extras.getString("name");
- dstLatitude = extras.getDouble("latitude");
- dstLongitude = extras.getDouble("longitude");
+ dstCoords = new Geopoint(extras.getDouble("latitude"), extras.getDouble("longitude"));
if (StringUtils.isNotBlank(name)) {
if (StringUtils.isNotBlank(title)) {
@@ -249,8 +246,8 @@ public class cgeonavigate extends AbstractActivity {
if (id == 0) {
Intent mapIntent = new Intent(this, settings.getMapFactory().getMapClass());
mapIntent.putExtra("detail", false);
- mapIntent.putExtra("latitude", dstLatitude);
- mapIntent.putExtra("longitude", dstLongitude);
+ mapIntent.putExtra("latitude", dstCoords.getLatitude());
+ mapIntent.putExtra("longitude", dstCoords.getLongitude());
startActivity(mapIntent);
} else if (id == 1) {
@@ -285,13 +282,14 @@ public class cgeonavigate extends AbstractActivity {
cgCoord coordinate = coordinates.get(id - 4);
title = coordinate.name;
- dstLatitude = coordinate.latitude;
- dstLongitude = coordinate.longitude;
+ dstCoords = coordinate.coords;
setTitle();
setDestCoords();
updateDistanceInfo();
- Log.d(cgSettings.tag, "destination set: " + title + " (" + String.format(Locale.getDefault(), "%.8f", dstLatitude) + " | " + String.format(Locale.getDefault(), "%.8f", dstLongitude) + ")");
+ Log.d(cgSettings.tag, "destination set: " + title + " (" +
+ String.format(Locale.getDefault(), "%.8f", dstCoords.getLatitude()) + " | " +
+ String.format(Locale.getDefault(), "%.8f", dstCoords.getLongitude()) + ")");
return true;
}
@@ -307,15 +305,15 @@ public class cgeonavigate extends AbstractActivity {
}
private void setDestCoords() {
- if (dstLatitude == null || dstLatitude == null) {
+ if (dstCoords == null) {
return;
}
- ((TextView) findViewById(R.id.destination)).setText(cgBase.formatCoords(dstLatitude, dstLongitude, true));
+ ((TextView) findViewById(R.id.destination)).setText(cgBase.formatCoords(dstCoords, true));
}
- public void setDest(Double lat, Double lon) {
- if (lat == null || lon == null) {
+ public void setDest(final Geopoint coords) {
+ if (coords == null) {
return;
}
@@ -323,22 +321,16 @@ public class cgeonavigate extends AbstractActivity {
setTitle();
setDestCoords();
- dstLatitude = lat;
- dstLongitude = lon;
+ dstCoords = coords;
updateDistanceInfo();
}
- public Map<String, Double> getCoordinatesNow() {
- Map<String, Double> coordsNow = new HashMap<String, Double>();
- if (geo != null) {
- coordsNow.put("latitude", geo.latitudeNow);
- coordsNow.put("longitude", geo.longitudeNow);
- }
- return coordsNow;
+ public Geopoint getCoordinatesNow() {
+ return geo.coordsNow;
}
private void updateDistanceInfo() {
- if (geo == null || geo.latitudeNow == null || geo.longitudeNow == null || dstLatitude == null || dstLongitude == null) {
+ if (geo == null || geo.coordsNow == null || dstCoords == null) {
return;
}
@@ -349,8 +341,8 @@ public class cgeonavigate extends AbstractActivity {
headingView = (TextView) findViewById(R.id.heading);
}
- cacheHeading = cgBase.getHeading(geo.latitudeNow, geo.longitudeNow, dstLatitude, dstLongitude);
- distanceView.setText(base.getHumanDistance(cgBase.getDistance(geo.latitudeNow, geo.longitudeNow, dstLatitude, dstLongitude)));
+ cacheHeading = cgBase.getHeading(geo.coordsNow, dstCoords);
+ distanceView.setText(base.getHumanDistance(cgBase.getDistance(geo.coordsNow, dstCoords)));
headingView.setText(String.format(Locale.getDefault(), "%.0f", cacheHeading) + "°");
}
@@ -370,7 +362,7 @@ public class cgeonavigate extends AbstractActivity {
navLocation = (TextView) findViewById(R.id.nav_location);
}
- if (geo.latitudeNow != null && geo.longitudeNow != null) {
+ if (geo.coordsNow != null) {
String satellites = null;
if (geo.satellitesVisible != null && geo.satellitesFixed != null && geo.satellitesFixed > 0) {
satellites = res.getString(R.string.loc_sat) + ": " + geo.satellitesFixed + "/" + geo.satellitesVisible;
@@ -406,9 +398,9 @@ public class cgeonavigate extends AbstractActivity {
} else {
humanAlt = String.format("%.0f", geo.altitudeNow) + " m";
}
- navLocation.setText(cgBase.formatCoords(geo.latitudeNow, geo.longitudeNow, true) + " | " + humanAlt);
+ navLocation.setText(cgBase.formatCoords(geo.coordsNow, true) + " | " + humanAlt);
} else {
- navLocation.setText(cgBase.formatCoords(geo.latitudeNow, geo.longitudeNow, true));
+ navLocation.setText(cgBase.formatCoords(geo.coordsNow, true));
}
updateDistanceInfo();