Small fixes for 1.6 release
[zxing.git] / csharp / client / result / GeoParsedResult.cs
1 /*\r
2 * Copyright 2008 ZXing authors\r
3 *\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
7 *\r
8 *      http://www.apache.org/licenses/LICENSE-2.0\r
9 *\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
15 */\r
16 using System;\r
17 namespace com.google.zxing.client.result\r
18 {\r
19         \r
20         /// <author>  Sean Owen\r
21         /// </author>\r
22         /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
23         /// </author>\r
24         public sealed class GeoParsedResult:ParsedResult\r
25         {\r
26                 public System.String GeoURI\r
27                 {\r
28                         get\r
29                         {\r
30                                 return geoURI;\r
31                         }\r
32                         \r
33                 }\r
34                 /// <returns> latitude in degrees\r
35                 /// </returns>\r
36                 public double Latitude\r
37                 {\r
38                         get\r
39                         {\r
40                                 return latitude;\r
41                         }\r
42                         \r
43                 }\r
44                 /// <returns> longitude in degrees\r
45                 /// </returns>\r
46                 public double Longitude\r
47                 {\r
48                         get\r
49                         {\r
50                                 return longitude;\r
51                         }\r
52                         \r
53                 }\r
54                 /// <returns> altitude in meters. If not specified, in the geo URI, returns 0.0\r
55                 /// </returns>\r
56                 public double Altitude\r
57                 {\r
58                         get\r
59                         {\r
60                                 return altitude;\r
61                         }\r
62                         \r
63                 }\r
64                 override public System.String DisplayResult\r
65                 {\r
66                         get\r
67                         {\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
73                                 {\r
74                                         result.Append(", ");\r
75                                         result.Append(altitude);\r
76                                         result.Append('m');\r
77                                 }\r
78                                 return result.ToString();\r
79                         }\r
80                         \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
84                         /// </returns>\r
85                         /*\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
90                         result.append(',');\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
99                         int logBaseTwo = 0;\r
100                         while (altitudeInKFeet > 1 && logBaseTwo < 18) {\r
101                         altitudeInKFeet >>= 1;\r
102                         logBaseTwo++;\r
103                         }\r
104                         int zoom = 19 - logBaseTwo;\r
105                         result.append("&z=");\r
106                         result.append(zoom);\r
107                         }\r
108                         return result.toString();\r
109                         }\r
110                         */\r
111                         \r
112                 }\r
113                 \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
122                 \r
123                 internal GeoParsedResult(System.String geoURI, double latitude, double longitude, double altitude):base(ParsedResultType.GEO)\r
124                 {\r
125                         this.geoURI = geoURI;\r
126                         this.latitude = latitude;\r
127                         this.longitude = longitude;\r
128                         this.altitude = altitude;\r
129                 }\r
130         }\r
131 }