public GoogleMapAddress QueryLocalSourceForAddress(LongLat ll) { DataTable tb = Database.ExecutePCodeDatabaseQuery("SELECT postcode FROM tbl_postcodes WHERE latitude = " + ll.Latatude.ToString() + " and longitude = " + ll.Longatude.ToString()); if (tb.Rows.Count != 1) { return(null); } string pcode = tb.Rows[0][0].ToString(); pcode = pcode.Insert(pcode.Length - 3, " "); return(new GoogleMapAddress(pcode, "UK")); }
public LongLat QueryGoogleForLongLat(GoogleMapAddress add) { if (add == null) { throw new NullReferenceException("Invalid LongLat Object. Cannot Load PostCode"); } if (add.PostCode.Split(' ').Count() > 2) { throw new Exception("Invalid Postcode Format"); } LongLat retVal; try { retVal = QueryLocalSourceForLongLat(add); } catch (Exception e) { retVal = null; } if (retVal == null) { try { LocationDetailsQuery qr = QueryGoogleForLocation(add.ToString()); if (qr.ErrorCode != null) { throw new Exception("Error Loading Location Details : " + qr.ErrorCode); } else if (qr.LongLat == null) { throw new PostCodeNotFoundException("Post Code Not Found For (" + add.PostCode + "," + add.Country + ")"); } retVal = new LongLat(qr.LongLat.Split(',')[0], qr.LongLat.Split(',')[1], add.PostCode); } catch (Exception ex) { throw new Exception("Failed to get location details"); } } return(retVal); }
public GoogleMapAddress QueryGoogleForAddress(LongLat ll) { // if (Add == null) // throw new NullReferenceException("Invalid Address Object. Cannot Load LongLat"); GoogleMapAddress retVal; try { retVal = QueryLocalSourceForAddress(ll); } catch (Exception ex) { retVal = null; } if (retVal == null) { try { LocationDetailsQuery qr = QueryGoogleForLocation(ll.ToString()); if (qr.ErrorCode != null) { throw new Exception("Error Loading Location Details : " + qr.ErrorCode); } else if (qr.PCode == null) { throw new PostCodeNotFoundException("Post Code Not Found For (" + ll.Longatude + ", " + ll.Latatude + ")"); } else if (qr.Country == null) { throw new CountryNotFoundException("Country Not Found For (" + ll.Longatude + ", " + ll.Latatude + ")"); } retVal = new GoogleMapAddress(qr.PCode, qr.Country); } catch (Exception ex) { throw new Exception("Failed to get location details"); } } return(retVal); }
public GoogleMapLocation(LongLat longlat, string tag = null) { this.LongLat = longlat; this.Add = QueryGoogleForAddress(longlat); this.Tag = tag; }
public GoogleMapLocation(GoogleMapAddress add, string tag = null) { this.Add = add; this.LongLat = QueryGoogleForLongLat(@add); this.Tag = tag; }
public GoogleMapLocation(GoogleMapAddress add, LongLat longlat, string tag = null) { this.Add = add; this.LongLat = longlat; this.Tag = tag; }