From f5a8c176e160812b7350f88d7bc4d3014e3ec060 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 9 Jul 2013 21:53:53 +0200 Subject: Remove elevation handling Geocaches do not contain useful elevation information. We used to get it using Google API, but the information was not very useful because our handling of altitude was inconsistent. Also, the Google elevation API usage limits states that "the Elevation API may only be used in conjunction with displaying results on a Google map; using elevation data without displaying a map for which elevation data was requested is prohibited". This removes elevation handling completely, except in the settings to avoid getting in the way of the settings rewrite. The elevation related settings should be removed there instead when both works are merged. --- main/src/cgeo/geocaching/CacheDetailActivity.java | 19 +---- main/src/cgeo/geocaching/CompassActivity.java | 7 +- main/src/cgeo/geocaching/Geocache.java | 13 ---- main/src/cgeo/geocaching/IGeoData.java | 1 - main/src/cgeo/geocaching/MainActivity.java | 7 +- main/src/cgeo/geocaching/cgData.java | 90 ++++++++++------------ .../src/cgeo/geocaching/connector/gc/GCParser.java | 10 --- main/src/cgeo/geocaching/geopoint/Geopoint.java | 28 ------- main/src/cgeo/geocaching/geopoint/Units.java | 12 --- 9 files changed, 44 insertions(+), 143 deletions(-) (limited to 'main/src/cgeo/geocaching') diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 1b31463..9dffeb2 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -160,24 +160,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity 0); - cache.setUserModifiedCoords(cursor.getInt(36) > 0); - cache.setFinalDefined(cursor.getInt(39) > 0); - cache.setLogPasswordRequired(cursor.getInt(43) > 0); + cache.setFavoritePoints(cursor.getInt(23)); + cache.setRating(cursor.getFloat(24)); + cache.setVotes(cursor.getInt(25)); + cache.setMyVote(cursor.getFloat(26)); + cache.setDisabled(cursor.getInt(27) == 1); + cache.setArchived(cursor.getInt(28) == 1); + cache.setPremiumMembersOnly(cursor.getInt(29) == 1); + cache.setFound(cursor.getInt(30) == 1); + cache.setFavorite(cursor.getInt(31) == 1); + cache.setInventoryItems(cursor.getInt(32)); + cache.setOnWatchlist(cursor.getInt(33) == 1); + cache.setReliableLatLon(cursor.getInt(34) > 0); + cache.setUserModifiedCoords(cursor.getInt(35) > 0); + cache.setFinalDefined(cursor.getInt(38) > 0); + cache.setLogPasswordRequired(cursor.getInt(42) > 0); Log.d("Loading " + cache.toString() + " (" + cache.getListId() + ") from DB"); diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index ea15633..9ecb51b 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -1756,16 +1756,6 @@ public abstract class GCParser { } } - if (Settings.isElevationWanted()) { - if (CancellableHandler.isCancelled(handler)) { - return; - } - CancellableHandler.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_elevation); - if (cache.getCoords() != null) { - cache.setElevation(cache.getCoords().getElevation()); - } - } - if (Settings.isRatingWanted()) { if (CancellableHandler.isCancelled(handler)) { return; diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java index 1973b03..11f03cb 100644 --- a/main/src/cgeo/geocaching/geopoint/Geopoint.java +++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java @@ -323,34 +323,6 @@ public final class Geopoint implements ICoordinates, Parcelable { } } - public Double getElevation() { - try { - final String uri = "http://maps.googleapis.com/maps/api/elevation/json"; - final Parameters params = new Parameters( - "sensor", "false", - "locations", format(Format.LAT_LON_DECDEGREE_COMMA)); - final JSONObject response = Network.requestJSON(uri, params); - - if (response == null) { - return null; - } - - if (!StringUtils.equalsIgnoreCase(response.getString("status"), "OK")) { - return null; - } - - if (response.has("results")) { - JSONArray results = response.getJSONArray("results"); - JSONObject result = results.getJSONObject(0); - return result.getDouble("elevation"); - } - } catch (Exception e) { - Log.w("Geopoint.getElevation", e); - } - - return null; - } - @Override public Geopoint getCoords() { return this; diff --git a/main/src/cgeo/geocaching/geopoint/Units.java b/main/src/cgeo/geocaching/geopoint/Units.java index 75d71d0..b99e00e 100644 --- a/main/src/cgeo/geocaching/geopoint/Units.java +++ b/main/src/cgeo/geocaching/geopoint/Units.java @@ -47,18 +47,6 @@ public class Units { return String.format(formatString + " %s", scaled.left, scaled.right); } - /** - * Get human readable elevation, depending on settings for metric units. - * Result is rounded to full meters/feet, as the sensors don't have that precision anyway. - * - * @param meters - * @return - */ - public static String getElevation(float meters) { - final ImmutablePair scaled = scaleDistance(meters / 1000f); - return (meters >= 0 ? "↥ " : "↧ ") + String.format("%d %s", Math.abs(Math.round(scaled.left)), scaled.right); - } - public static String getDistanceFromMeters(float meters) { return getDistanceFromKilometers(meters / 1000f); } -- cgit v1.1