+ result.append("deg E");
+ if (altitude > 0.0f) {
+ result.append(", ");
+ result.append(altitude);
+ result.append('m');
+ }
+ return result.toString();
+ }
+
+ /**
+ * @return a URI link to Google Maps which display the point on the Earth described
+ * by this instance, and sets the zoom level in a way that roughly reflects the
+ * altitude, if specified
+ */
+ public String getGoogleMapsURI() {
+ StringBuffer result = new StringBuffer(50);
+ result.append("http://maps.google.com/?ll=");
+ result.append(latitude);
+ result.append(',');
+ result.append(longitude);
+ if (altitude > 0.0f) {
+ // Map altitude to zoom level, cleverly. Roughly, zoom level 19 is like a
+ // view from 1000ft, 18 is like 2000ft, 17 like 4000ft, and so on.
+ float altitudeInFeet = altitude * 3.28f;
+ int altitudeInKFeet = (int) (altitudeInFeet / 1000.0f);
+ // No Math.log() available here, so compute log base 2 the old fashioned way
+ // Here logBaseTwo will take on a value between 0 and 18 actually
+ int logBaseTwo = 0;
+ while (altitudeInKFeet > 1 && logBaseTwo < 18) {
+ altitudeInKFeet >>= 1;
+ logBaseTwo++;
+ }
+ int zoom = 19 - logBaseTwo;
+ result.append("&z=");
+ result.append(zoom);
+ }