2 * Copyright 2008 ZXing authors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 namespace com.google.zxing.client.result
\r
20 /// <author> Sean Owen
\r
22 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
24 public sealed class GeoParsedResult:ParsedResult
\r
26 public System.String GeoURI
\r
34 /// <returns> latitude in degrees
\r
36 public double Latitude
\r
44 /// <returns> longitude in degrees
\r
46 public double Longitude
\r
54 /// <returns> altitude in meters. If not specified, in the geo URI, returns 0.0
\r
56 public double Altitude
\r
64 override public System.String DisplayResult
\r
68 System.Text.StringBuilder result = new System.Text.StringBuilder(50);
\r
69 result.Append(latitude);
\r
70 result.Append(", ");
\r
71 result.Append(longitude);
\r
72 if (altitude > 0.0f)
\r
74 result.Append(", ");
\r
75 result.Append(altitude);
\r
78 return result.ToString();
\r
81 /// <returns> a URI link to Google Maps which display the point on the Earth described
\r
82 /// by this instance, and sets the zoom level in a way that roughly reflects the
\r
83 /// altitude, if specified
\r
86 public String getGoogleMapsURI() {
\r
87 StringBuffer result = new StringBuffer(50);
\r
88 result.append("http://maps.google.com/?ll=");
\r
89 result.append(latitude);
\r
91 result.append(longitude);
\r
92 if (altitude > 0.0f) {
\r
93 // Map altitude to zoom level, cleverly. Roughly, zoom level 19 is like a
\r
94 // view from 1000ft, 18 is like 2000ft, 17 like 4000ft, and so on.
\r
95 double altitudeInFeet = altitude * 3.28;
\r
96 int altitudeInKFeet = (int) (altitudeInFeet / 1000.0);
\r
97 // No Math.log() available here, so compute log base 2 the old fashioned way
\r
98 // Here logBaseTwo will take on a value between 0 and 18 actually
\r
100 while (altitudeInKFeet > 1 && logBaseTwo < 18) {
\r
101 altitudeInKFeet >>= 1;
\r
104 int zoom = 19 - logBaseTwo;
\r
105 result.append("&z=");
\r
106 result.append(zoom);
\r
108 return result.toString();
\r
114 //UPGRADE_NOTE: Final was removed from the declaration of 'geoURI '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
115 private System.String geoURI;
\r
116 //UPGRADE_NOTE: Final was removed from the declaration of 'latitude '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
117 private double latitude;
\r
118 //UPGRADE_NOTE: Final was removed from the declaration of 'longitude '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
119 private double longitude;
\r
120 //UPGRADE_NOTE: Final was removed from the declaration of 'altitude '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
121 private double altitude;
\r
123 internal GeoParsedResult(System.String geoURI, double latitude, double longitude, double altitude):base(ParsedResultType.GEO)
\r
125 this.geoURI = geoURI;
\r
126 this.latitude = latitude;
\r
127 this.longitude = longitude;
\r
128 this.altitude = altitude;
\r