public override string ToString() { string retStr = Add.ToString(); if (LongLat != null) { retStr += " [ " + LongLat.ToString() + " ] "; } return(retStr); }
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); }