Ejemplo n.º 1
0
 /**
  * Creates a new GeoLocation with the given latitude and longitude.
  *
  * @throws java.lang.IllegalArgumentException If the coordinates are not valid geo coordinates
  * @param latitude The latitude in the range of [-90, 90]
  * @param longitude The longitude in the range of [-180, 180]
  */
 public GeoLocation(double latitude, double longitude)
 {
     if (!GeoLocation.coordinatesValid(latitude, longitude))
     {
         throw new System.Exception("Not a valid geo location: " + latitude + ", " + longitude);
     }
     this.latitude  = latitude;
     this.longitude = longitude;
 }
Ejemplo n.º 2
0
 public static GeoLocation _parse(object o)
 {
     try {
         Dictionary <string, object> os = (Dictionary <string, object>)o;
         List <object> ls = (List <object>)os["l"];
         if (ls.Count != 2)
         {
             return(null);
         }
         double latitude  = (double)ls[0];
         double longitude = (double)ls[1];
         if (GeoLocation.coordinatesValid(latitude, longitude))
         {
             return(new GeoLocation(latitude, longitude));
         }
         else
         {
             return(null);
         }
     } catch (Exception e) {
         return(null);
     }
 }