From 8e8d6b04380048efa0480105003ee4255130b4d2 Mon Sep 17 00:00:00 2001 From: Jimmy Shih Date: Fri, 22 Jun 2012 17:59:14 -0700 Subject: [PATCH] When generating Fusion Table url, if the track is empty, use Google's latitude and longitude to generate a valid url. --- .../fusiontables/SendFusionTablesUtils.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/fusiontables/SendFusionTablesUtils.java b/MyTracks/src/com/google/android/apps/mytracks/io/fusiontables/SendFusionTablesUtils.java index 1c12cf27e..909d3b56d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/fusiontables/SendFusionTablesUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/fusiontables/SendFusionTablesUtils.java @@ -56,14 +56,20 @@ public class SendFusionTablesUtils { Log.e(TAG, "Invalid track"); return null; } - - // TODO(jshih): Determine the correct bounding box and zoom level that - // will show the entire track. - TripStatistics stats = track.getTripStatistics(); - double latE6 = stats.getBottom() + (stats.getTop() - stats.getBottom()) / 2; - double lonE6 = stats.getLeft() + (stats.getRight() - stats.getLeft()) / 2; - int z = 15; - + double latE6; + double lonE6; + int z; + if (track.getNumberOfPoints() < 2) { + // Use Google's latitude and longitude + latE6 = 37.423 * 1.E6; + lonE6 = -122.084 * 1.E6; + z = 2; + } else { + TripStatistics stats = track.getTripStatistics(); + latE6 = stats.getBottom() + (stats.getTop() - stats.getBottom()) / 2; + lonE6 = stats.getLeft() + (stats.getRight() - stats.getLeft()) / 2; + z = 15; + } // We explicitly format with Locale.US because we need the latitude and // longitude to be formatted in a locale-independent manner. Specifically, // we need the decimal separator to be a period rather than a comma.