New C# port from Suraj Supekar
[zxing.git] / csharp / client / result / GeoParsedResult.cs
diff --git a/csharp/client/result/GeoParsedResult.cs b/csharp/client/result/GeoParsedResult.cs
new file mode 100755 (executable)
index 0000000..da4f217
--- /dev/null
@@ -0,0 +1,131 @@
+/*\r
+* Copyright 2008 ZXing authors\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+*      http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*/\r
+using System;\r
+namespace com.google.zxing.client.result\r
+{\r
+       \r
+       /// <author>  Sean Owen\r
+       /// </author>\r
+       /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
+       /// </author>\r
+       public sealed class GeoParsedResult:ParsedResult\r
+       {\r
+               public System.String GeoURI\r
+               {\r
+                       get\r
+                       {\r
+                               return geoURI;\r
+                       }\r
+                       \r
+               }\r
+               /// <returns> latitude in degrees\r
+               /// </returns>\r
+               public double Latitude\r
+               {\r
+                       get\r
+                       {\r
+                               return latitude;\r
+                       }\r
+                       \r
+               }\r
+               /// <returns> longitude in degrees\r
+               /// </returns>\r
+               public double Longitude\r
+               {\r
+                       get\r
+                       {\r
+                               return longitude;\r
+                       }\r
+                       \r
+               }\r
+               /// <returns> altitude in meters. If not specified, in the geo URI, returns 0.0\r
+               /// </returns>\r
+               public double Altitude\r
+               {\r
+                       get\r
+                       {\r
+                               return altitude;\r
+                       }\r
+                       \r
+               }\r
+               override public System.String DisplayResult\r
+               {\r
+                       get\r
+                       {\r
+                               System.Text.StringBuilder result = new System.Text.StringBuilder(50);\r
+                               result.Append(latitude);\r
+                               result.Append(", ");\r
+                               result.Append(longitude);\r
+                               if (altitude > 0.0f)\r
+                               {\r
+                                       result.Append(", ");\r
+                                       result.Append(altitude);\r
+                                       result.Append('m');\r
+                               }\r
+                               return result.ToString();\r
+                       }\r
+                       \r
+                       /// <returns> a URI link to Google Maps which display the point on the Earth described\r
+                       /// by this instance, and sets the zoom level in a way that roughly reflects the\r
+                       /// altitude, if specified\r
+                       /// </returns>\r
+                       /*\r
+                       public String getGoogleMapsURI() {\r
+                       StringBuffer result = new StringBuffer(50);\r
+                       result.append("http://maps.google.com/?ll=");\r
+                       result.append(latitude);\r
+                       result.append(',');\r
+                       result.append(longitude);\r
+                       if (altitude > 0.0f) {\r
+                       // Map altitude to zoom level, cleverly. Roughly, zoom level 19 is like a\r
+                       // view from 1000ft, 18 is like 2000ft, 17 like 4000ft, and so on.\r
+                       double altitudeInFeet = altitude * 3.28;\r
+                       int altitudeInKFeet = (int) (altitudeInFeet / 1000.0);\r
+                       // No Math.log() available here, so compute log base 2 the old fashioned way\r
+                       // Here logBaseTwo will take on a value between 0 and 18 actually\r
+                       int logBaseTwo = 0;\r
+                       while (altitudeInKFeet > 1 && logBaseTwo < 18) {\r
+                       altitudeInKFeet >>= 1;\r
+                       logBaseTwo++;\r
+                       }\r
+                       int zoom = 19 - logBaseTwo;\r
+                       result.append("&z=");\r
+                       result.append(zoom);\r
+                       }\r
+                       return result.toString();\r
+                       }\r
+                       */\r
+                       \r
+               }\r
+               \r
+               //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
+               private System.String geoURI;\r
+               //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
+               private double latitude;\r
+               //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
+               private double longitude;\r
+               //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
+               private double altitude;\r
+               \r
+               internal GeoParsedResult(System.String geoURI, double latitude, double longitude, double altitude):base(ParsedResultType.GEO)\r
+               {\r
+                       this.geoURI = geoURI;\r
+                       this.latitude = latitude;\r
+                       this.longitude = longitude;\r
+                       this.altitude = altitude;\r
+               }\r
+       }\r
+}
\ No newline at end of file