Skip to content

Commit

Permalink
Merge branch 'bing-api-neighbourhood'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rikki Calteaux committed Sep 18, 2017
2 parents 89c88ad + 8695f81 commit d224038
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
22 changes: 11 additions & 11 deletions src/Geocoding.Microsoft/BingAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ public string AdminDistrict2
public string CountryRegion
{
get { return countryRegion ?? ""; }
}
}

public string Locality
{
get { return locality ?? ""; }
}
public string Locality
{
get { return locality ?? ""; }
}

public string Neighborhood
{
get { return neighborhood ?? ""; }
}
public string Neighborhood
{
get { return neighborhood ?? ""; }
}

public string PostalCode
public string PostalCode
{
get { return postalCode ?? ""; }
}
Expand All @@ -60,7 +60,7 @@ public BingAddress(string formattedAddress, Location coordinates, string address
this.adminDistrict2 = adminDistrict2;
this.countryRegion = countryRegion;
this.locality = locality;
this.neighborhood = neighborhood;
this.neighborhood = neighborhood;
this.postalCode = postalCode;
this.type = type;
this.confidence = confidence;
Expand Down
14 changes: 7 additions & 7 deletions src/Geocoding.Microsoft/BingMapsGeocoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class BingMapsGeocoder : IGeocoder
public Location UserLocation { get; set; }
public Bounds UserMapView { get; set; }
public IPAddress UserIP { get; set; }
public bool IncludeNeighborhood { get; set; }
public bool IncludeNeighborhood { get; set; }

public BingMapsGeocoder(string bingKey)
public BingMapsGeocoder(string bingKey)
{
if (string.IsNullOrWhiteSpace(bingKey))
throw new ArgumentException("bingKey can not be null or empty");
Expand Down Expand Up @@ -86,11 +86,11 @@ private IEnumerable<KeyValuePair<string, string>> GetGlobalParameters()
if (UserIP != null)
yield return new KeyValuePair<string, string>("userIp", UserIP.ToString());

if (IncludeNeighborhood)
yield return new KeyValuePair<string, string>("inclnb", IncludeNeighborhood ? "1" : "0");
}
if (IncludeNeighborhood)
yield return new KeyValuePair<string, string>("inclnb", IncludeNeighborhood ? "1" : "0");
}

private bool AppendGlobalParameters(StringBuilder parameters, bool first)
private bool AppendGlobalParameters(StringBuilder parameters, bool first)
{
var values = GetGlobalParameters().ToArray();

Expand Down Expand Up @@ -212,7 +212,7 @@ private IEnumerable<BingAddress> ParseResponse(Json.Response response)
location.Address.AdminDistrict2,
location.Address.CountryRegion,
location.Address.Locality,
location.Address.Neighborhood,
location.Address.Neighborhood,
location.Address.PostalCode,
(EntityType)Enum.Parse(typeof(EntityType), location.EntityType),
EvaluateConfidence(location.Confidence)
Expand Down
10 changes: 5 additions & 5 deletions src/Geocoding.Microsoft/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public class Address
public string CountryRegion { get; set; }
[DataMember(Name = "formattedAddress")]
public string FormattedAddress { get; set; }
[DataMember(Name = "locality")]
public string Locality { get; set; }
[DataMember(Name = "neighborhood")]
public string Neighborhood { get; set; }
[DataMember(Name = "postalCode")]
[DataMember(Name = "locality")]
public string Locality { get; set; }
[DataMember(Name = "neighborhood")]
public string Neighborhood { get; set; }
[DataMember(Name = "postalCode")]
public string PostalCode { get; set; }
}
[DataContract]
Expand Down
40 changes: 20 additions & 20 deletions test/Geocoding.Tests/BingMapsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ public async Task ApplyUserLocation(string address, double userLatitude, double
geoCoder.UserLocation = new Location(userLatitude, userLongitude);
BingAddress[] addresses = (await geoCoder.GeocodeAsync(address)).ToArray();
Assert.Equal(country, addresses[0].CountryRegion);
}
}

[Theory]
[InlineData("Montreal", 45, -73, 46, -74, "Canada")]
[InlineData("Montreal", 43, 0, 44, 1, "France")]
[InlineData("Montreal", 46, -90, 47, -91, "United States")]
public async Task ApplyUserMapView(string address, double userLatitude1, double userLongitude1, double userLatitude2, double userLongitude2, string country)
{
geoCoder.UserMapView = new Bounds(userLatitude1, userLongitude1, userLatitude2, userLongitude2);
BingAddress[] addresses = (await geoCoder.GeocodeAsync(address)).ToArray();
Assert.Equal(country, addresses[0].CountryRegion);
}
[Theory]
[InlineData("Montreal", 45, -73, 46, -74, "Canada")]
[InlineData("Montreal", 43, 0, 44, 1, "France")]
[InlineData("Montreal", 46, -90, 47, -91, "United States")]
public async Task ApplyUserMapView(string address, double userLatitude1, double userLongitude1, double userLatitude2, double userLongitude2, string country)
{
geoCoder.UserMapView = new Bounds(userLatitude1, userLongitude1, userLatitude2, userLongitude2);
BingAddress[] addresses = (await geoCoder.GeocodeAsync(address)).ToArray();
Assert.Equal(country, addresses[0].CountryRegion);
}

[Theory]
[InlineData("24 sussex drive ottawa, ontario")]
public async Task ApplyIncludeNeighborhood(string address)
{
geoCoder.IncludeNeighborhood = true;
BingAddress[] addresses = (await geoCoder.GeocodeAsync(address)).ToArray();
Assert.NotNull(addresses[0].Neighborhood);
}
[Theory]
[InlineData("24 sussex drive ottawa, ontario")]
public async Task ApplyIncludeNeighborhood(string address)
{
geoCoder.IncludeNeighborhood = true;
BingAddress[] addresses = (await geoCoder.GeocodeAsync(address)).ToArray();
Assert.NotNull(addresses[0].Neighborhood);
}

[Fact]
[Fact]
//https://github.com/chadly/Geocoding.net/issues/8
public async Task CanReverseGeocodeIssue8()
{
Expand Down

0 comments on commit d224038

Please sign in to comment.