private GeoCodingResult MapRequestResult(Result resultObj) { try { var geoCodingResult = new GeoCodingResult { Coordinate = new Coordinate(resultObj.Geometry.Location.Latitude, resultObj.Geometry.Location.Longitude) }; var city = resultObj.AddressComponents.FirstOrDefault(x => x.IsCity); geoCodingResult.City = (city != null) ? city.LongName : string.Empty; var state = resultObj.AddressComponents.FirstOrDefault(x => x.IsState); geoCodingResult.State = (state != null) ? state.LongName : string.Empty; var postalCode = resultObj.AddressComponents.FirstOrDefault(x => x.IsPostalCode); geoCodingResult.Zip = (postalCode != null) ? postalCode.LongName : string.Empty; var country = resultObj.AddressComponents.FirstOrDefault(x => x.IsCountry); geoCodingResult.Country = (country != null) ? country.LongName : string.Empty; return(geoCodingResult); } catch (Exception err) { throw new GeoCodingMapException(err); } }
private GeoCodingResult MapRequestResult(Result resultObj) { try { var geoCodingResult = new GeoCodingResult { Coordinate = new Coordinate(resultObj.Geometry.Location.Latitude, resultObj.Geometry.Location.Longitude) }; var city = resultObj.AddressComponents.FirstOrDefault(x => x.IsCity); geoCodingResult.City = (city != null) ? city.LongName : string.Empty; var state = resultObj.AddressComponents.FirstOrDefault(x => x.IsState); geoCodingResult.State = (state != null) ? state.LongName : string.Empty; var postalCode = resultObj.AddressComponents.FirstOrDefault(x => x.IsPostalCode); geoCodingResult.Zip = (postalCode != null) ? postalCode.LongName : string.Empty; var country = resultObj.AddressComponents.FirstOrDefault(x => x.IsCountry); geoCodingResult.Country = (country != null) ? country.LongName : string.Empty; return geoCodingResult; } catch (Exception err) { throw new GeoCodingMapException(err); } }
public CoordinateViewModel Create(GeoCodingResult result) { return new CoordinateViewModel { Latitude = result.Coordinate.Latitude, Longitude = result.Coordinate.Longitude, Description = result.GetDescription() }; }
public RequestResult Parse(string json) { var result = new GeoCodingResult(); RequestResult parseResult; try { parseResult = JsonConvert.DeserializeObject<RequestResult>(json); } catch (Exception err) { throw new GeoCodingParseException(err); } return parseResult; }
public RequestResult Parse(string json) { var result = new GeoCodingResult(); RequestResult parseResult; try { parseResult = JsonConvert.DeserializeObject <RequestResult>(json); } catch (Exception err) { throw new GeoCodingParseException(err); } return(parseResult); }