//Calling package:BingGeocoder to return address GEO coding private static List <GEOCodeStep> BingGeocoderList(string address, string webService, string key) { var geoCodeStepsList = new List <GEOCodeStep>(); string apikey = GetConfigFile().IniReadValue(webService, key); try { BingGeocoderClient bingClient = new BingGeocoderClient(apikey); BingGeocoderResult bingResult = new BingGeocoderResult(); bingResult = bingClient.Geocode(address); if (bingResult.Latitude != null && bingResult.Longitude != null) { var geoCodeSteps = new GEOCodeStep(); geoCodeSteps.Status = "OK"; geoCodeSteps.lat = bingResult.Latitude; geoCodeSteps.lng = bingResult.Longitude; geoCodeStepsList.Add(geoCodeSteps); } else { var geoCodeSteps = new GEOCodeStep(); //geoCodeSteps.Status = respStatus; geoCodeSteps.lat = "ZERO_RESULTS"; geoCodeSteps.lng = "ZERO_RESULTS"; geoCodeStepsList.Add(geoCodeSteps); } } catch (Exception ex) { RecordLog("BingGeocoderList", ex.Message); return(null); } return(geoCodeStepsList); }
public void ShouldReturnEmptyResultWithFakeKeyProvided() { var geocoder = new BingGeocoderClient("blah"); var result = geocoder.Geocode("blah"); Assert.AreEqual(result.Confidence, "No results"); Assert.IsNotNull(result.ErrorMessage); }
public void ShouldReturnValidResultWithRealKeyProvidedAndRealQuery() { var geocoder = new BingGeocoderClient(Key); var result = geocoder.Geocode("ATL"); Assert.AreNotEqual(result.Confidence, "No results"); Assert.IsNotNull(result.Latitude); Assert.IsNotNull(result.Longitude); Assert.IsNull(result.ErrorMessage); }
public void ShouldReturnValidResultWithRealKeyProvidedAndRealAddress() { var geocoder = new BingGeocoderClient(Key); var result = geocoder.Geocode("1230 Peachtree St", "Atlanta", "GA", "30309"); Assert.AreNotEqual(result.Confidence, "No results"); Assert.IsNotNull(result.Latitude); Assert.IsNotNull(result.Longitude); Assert.IsNull(result.ErrorMessage); }
public void ShouldReturnEmptyResultWithRealKeyProvidedAndFakeAddress() { var geocoder = new BingGeocoderClient(Key); var result = geocoder.Geocode("123 Blah Blah", "Test", "Test", "Test"); Assert.AreNotEqual(result.Confidence, "No results"); Assert.IsNotNull(result.Latitude); Assert.IsNotNull(result.Longitude); Assert.IsNull(result.ErrorMessage); }