Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.0 Release (#47) #49

Merged
merged 1 commit into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.

## 1.1.0
## [1.2.0](https://github.com/JustinCanton/Geo.NET/compare/1.1.1...1.2.0) (2022-08-20)
### Features
- adding extra information and logging surrounding exceptions ([#44](https://github.com/JustinCanton/Geo.NET/pull/44)) ([7b5b154](https://github.com/JustinCanton/Geo.NET/commit/7b5b15441181bda16b0a644e2b3ef8e7b06cc074))

### Bug Fixes
- fixing an issue where the query is not properly encoded, and fixing an issue where the query string building is using an outdated method ([#46](https://github.com/JustinCanton/Geo.NET/pull/46)) ([5b55f4d](https://github.com/JustinCanton/Geo.NET/commit/5b55f4d249a617e4667e92b5cb0b2c9b6b02ec6f))

## [1.1.1](https://github.com/JustinCanton/Geo.NET/compare/1.1.0...1.1.1) (2022-07-21)
### Bug Fixes
- fixing a vulnerability in newtonsoft nuget ([#39](https://github.com/JustinCanton/Geo.NET/pull/39)) ([fa192ca](https://github.com/JustinCanton/Geo.NET/commit/fa192cab2a965503aa5a50885010836461cb822b))

## [1.1.0](https://github.com/JustinCanton/Geo.NET/compare/1.0.0...1.1.0) (2022-06-04)
### Features
- Adding score into the HERE Geocoding response ([#33](https://github.com/JustinCanton/Geo.NET/pull/33)) ([c8f42e1](https://github.com/JustinCanton/Geo.NET/commit/c8f42e1f155da17dd3869f304c3b9e36a938da71))
- Adding net6.0 support ([#34](https://github.com/JustinCanton/Geo.NET/pull/34)) ([e8eebca](https://github.com/JustinCanton/Geo.NET/commit/e8eebca37d82e3659e7c5e6e2ea4f4777f45f4f7))

## 1.0.0
## 1.0.0 (2021-01-10)
### Features
- Adding support for ArcGIS Suggest API
- Adding support for ArcGIS Address Candidate API
Expand Down
18 changes: 1 addition & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,7 @@ The configuration and sample usage for each supported interface can be found wit
- [MapQuest](https://github.com/JustinCanton/Geo.NET/tree/master/src/Geo.MapQuest)


## Roadmap

### 1.1.0
|Status|Goal|
|:--:|--|
|✅|Adding score into the HERE Geocoding response|
|✅|Adding net6.0 support|
|✅|Adding ChangeLog|


### 1.2.0
|Status|Goal|
|:--:|--|
|❌|Adding support for conversion from coordinates to flexible polylines rather than requiring polylines as input for the HERE API ([#36](https://github.com/JustinCanton/Geo.NET/issues/36))|


### Suggestions or Discussion Points
## Suggestions or Discussion Points
If you would like to weigh in on any suggestion, please make a Github Issue and we can discuss further.

✅ = Accepted
Expand Down
3 changes: 2 additions & 1 deletion src/Geo.ArcGIS/Models/Exceptions/ArcGISException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Geo.ArcGIS.Models.Exceptions
using System.Globalization;
using System.Net.Http;
using System.Threading.Tasks;
using Geo.Core.Models.Exceptions;
using Newtonsoft.Json;

/// <summary>
Expand All @@ -23,7 +24,7 @@ namespace Geo.ArcGIS.Models.Exceptions
/// <exception cref="TaskCanceledException">Thrown when the ArcGIS request is cancelled.</exception>
/// <exception cref="JsonReaderException">Thrown when an error occurs while reading the return JSON text.</exception>
/// <exception cref="JsonSerializationException">Thrown when when an error occurs during JSON deserialization.</exception>
public class ArcGISException : Exception
public sealed class ArcGISException : GeoCoreException
{
private const string DefaultMessage = "{0} See the inner exception for more information.";

Expand Down
115 changes: 59 additions & 56 deletions src/Geo.ArcGIS/Services/ArcGISGeocoding.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/Geo.Bing/Models/Exceptions/BingException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Geo.Bing.Models.Exceptions
using System.Globalization;
using System.Net.Http;
using System.Threading.Tasks;
using Geo.Core.Models.Exceptions;
using Newtonsoft.Json;

/// <summary>
Expand All @@ -23,7 +24,7 @@ namespace Geo.Bing.Models.Exceptions
/// <exception cref="TaskCanceledException">Thrown when the Bing request is cancelled.</exception>
/// <exception cref="JsonReaderException">Thrown when an error occurs while reading the return JSON text.</exception>
/// <exception cref="JsonSerializationException">Thrown when when an error occurs during JSON deserialization.</exception>
public class BingException : Exception
public sealed class BingException : GeoCoreException
{
private const string DefaultMessage = "{0} See the inner exception for more information.";

Expand Down
61 changes: 31 additions & 30 deletions src/Geo.Bing/Services/BingGeocoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
namespace Geo.Bing.Services
{
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Globalization;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using Geo.Bing.Abstractions;
using Geo.Bing.Models.Exceptions;
using Geo.Bing.Models.Parameters;
using Geo.Bing.Models.Responses;
using Geo.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
Expand All @@ -39,18 +38,20 @@ public class BingGeocoding : ClientExecutor, IBingGeocoding
/// </summary>
/// <param name="client">A <see cref="HttpClient"/> used for placing calls to the Bing Geocoding API.</param>
/// <param name="keyContainer">A <see cref="IBingKeyContainer"/> used for fetching the Bing key.</param>
/// <param name="localizerFactory">A <see cref="IStringLocalizerFactory"/> used to create a localizer for localizing log or exception messages.</param>
/// <param name="logger">A <see cref="ILogger{T}"/> used for logging information.</param>
/// <param name="exceptionProvider">An <see cref="IGeoNETExceptionProvider"/> used to provide exceptions based on an exception type.</param>
/// <param name="localizerFactory">An <see cref="IStringLocalizerFactory"/> used to create a localizer for localizing log or exception messages.</param>
/// <param name="loggerFactory">An <see cref="ILoggerFactory"/> used to create a logger used for logging information.</param>
public BingGeocoding(
HttpClient client,
IBingKeyContainer keyContainer,
IGeoNETExceptionProvider exceptionProvider,
IStringLocalizerFactory localizerFactory,
ILogger<BingGeocoding> logger = null)
: base(client, localizerFactory)
ILoggerFactory loggerFactory = null)
: base(client, exceptionProvider, localizerFactory, loggerFactory)
{
_keyContainer = keyContainer ?? throw new ArgumentNullException(nameof(keyContainer));
_localizer = localizerFactory?.Create(typeof(BingGeocoding)) ?? throw new ArgumentNullException(nameof(localizerFactory));
_logger = logger ?? NullLogger<BingGeocoding>.Instance;
_logger = loggerFactory?.CreateLogger<BingGeocoding>() ?? NullLogger<BingGeocoding>.Instance;
}

/// <inheritdoc/>
Expand Down Expand Up @@ -118,7 +119,7 @@ internal Uri ValidateAndBuildUri<TParameters>(TParameters parameters, Func<TPara
internal Uri BuildGeocodingRequest(GeocodingParameters parameters)
{
var uriBuilder = new UriBuilder(BaseUri);
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
var query = QueryString.Empty;

if (string.IsNullOrWhiteSpace(parameters.Query))
{
Expand All @@ -127,11 +128,11 @@ internal Uri BuildGeocodingRequest(GeocodingParameters parameters)
throw new ArgumentException(error, nameof(parameters.Query));
}

query.Add("query", parameters.Query);
query = query.Add("query", parameters.Query);

BuildLimitedResultQuery(parameters, ref query);

AddBingKey(query);
AddBingKey(ref query);

uriBuilder.Query = query.ToString();

Expand All @@ -154,7 +155,7 @@ internal Uri BuildReverseGeocodingRequest(ReverseGeocodingParameters parameters)
}

var uriBuilder = new UriBuilder(BaseUri + $"/{parameters.Point}");
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
var query = QueryString.Empty;

var includes = new CommaDelimitedStringCollection();
if (parameters.IncludeAddress == true)
Expand Down Expand Up @@ -194,7 +195,7 @@ internal Uri BuildReverseGeocodingRequest(ReverseGeocodingParameters parameters)

if (includes.Count > 0)
{
query.Add("includeEntityTypes", includes.ToString());
query = query.Add("includeEntityTypes", includes.ToString());
}
else
{
Expand All @@ -203,7 +204,7 @@ internal Uri BuildReverseGeocodingRequest(ReverseGeocodingParameters parameters)

BuildBaseQuery(parameters, ref query);

AddBingKey(query);
AddBingKey(ref query);

uriBuilder.Query = query.ToString();

Expand All @@ -230,11 +231,11 @@ internal Uri BuildAddressGeocodingRequest(AddressGeocodingParameters parameters)
}

var uriBuilder = new UriBuilder(BaseUri);
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
var query = QueryString.Empty;

if (!string.IsNullOrWhiteSpace(parameters.AdministrationDistrict))
{
query.Add("adminDistrict", parameters.AdministrationDistrict);
query = query.Add("adminDistrict", parameters.AdministrationDistrict);
}
else
{
Expand All @@ -243,7 +244,7 @@ internal Uri BuildAddressGeocodingRequest(AddressGeocodingParameters parameters)

if (!string.IsNullOrWhiteSpace(parameters.Locality))
{
query.Add("locality", parameters.Locality);
query = query.Add("locality", parameters.Locality);
}
else
{
Expand All @@ -252,7 +253,7 @@ internal Uri BuildAddressGeocodingRequest(AddressGeocodingParameters parameters)

if (!string.IsNullOrWhiteSpace(parameters.PostalCode))
{
query.Add("postalCode", parameters.PostalCode);
query = query.Add("postalCode", parameters.PostalCode);
}
else
{
Expand All @@ -261,7 +262,7 @@ internal Uri BuildAddressGeocodingRequest(AddressGeocodingParameters parameters)

if (!string.IsNullOrWhiteSpace(parameters.AddressLine))
{
query.Add("addressLine", parameters.AddressLine);
query = query.Add("addressLine", parameters.AddressLine);
}
else
{
Expand All @@ -270,7 +271,7 @@ internal Uri BuildAddressGeocodingRequest(AddressGeocodingParameters parameters)

if (parameters.CountryRegion != null)
{
query.Add("countryRegion", parameters.CountryRegion.TwoLetterISORegionName.ToUpperInvariant());
query = query.Add("countryRegion", parameters.CountryRegion.TwoLetterISORegionName.ToUpperInvariant());
}
else
{
Expand All @@ -279,7 +280,7 @@ internal Uri BuildAddressGeocodingRequest(AddressGeocodingParameters parameters)

BuildLimitedResultQuery(parameters, ref query);

AddBingKey(query);
AddBingKey(ref query);

uriBuilder.Query = query.ToString();

Expand All @@ -290,12 +291,12 @@ internal Uri BuildAddressGeocodingRequest(AddressGeocodingParameters parameters)
/// Builds up the limited result query parameters.
/// </summary>
/// <param name="parameters">A <see cref="ResultParameters"/> with the limited result parameters to build the uri with.</param>
/// <param name="query">A <see cref="NameValueCollection"/> with the built up query parameters.</param>
internal void BuildLimitedResultQuery(ResultParameters parameters, ref NameValueCollection query)
/// <param name="query">A <see cref="QueryString"/> with the built up query parameters.</param>
internal void BuildLimitedResultQuery(ResultParameters parameters, ref QueryString query)
{
if (parameters.MaximumResults > 0 && parameters.MaximumResults <= 20)
{
query.Add("maxResults", parameters.MaximumResults.ToString(CultureInfo.InvariantCulture));
query = query.Add("maxResults", parameters.MaximumResults.ToString(CultureInfo.InvariantCulture));
}
else
{
Expand All @@ -309,12 +310,12 @@ internal void BuildLimitedResultQuery(ResultParameters parameters, ref NameValue
/// Builds up the base query parameters.
/// </summary>
/// <param name="parameters">A <see cref="BaseParameters"/> with the base parameters to build the uri with.</param>
/// <param name="query">A <see cref="NameValueCollection"/> with the built up query parameters.</param>
internal void BuildBaseQuery(BaseParameters parameters, ref NameValueCollection query)
/// <param name="query">A <see cref="QueryString"/> with the built up query parameters.</param>
internal void BuildBaseQuery(BaseParameters parameters, ref QueryString query)
{
if (parameters.IncludeNeighbourhood == true)
{
query.Add("includeNeighborhood", "1");
query = query.Add("includeNeighborhood", "1");
}
else
{
Expand All @@ -334,7 +335,7 @@ internal void BuildBaseQuery(BaseParameters parameters, ref NameValueCollection

if (includes.Count > 0)
{
query.Add("include", includes.ToString());
query = query.Add("include", includes.ToString());
}
else
{
Expand All @@ -345,10 +346,10 @@ internal void BuildBaseQuery(BaseParameters parameters, ref NameValueCollection
/// <summary>
/// Adds the Bing key to the query parameters.
/// </summary>
/// <param name="query">A <see cref="NameValueCollection"/> with the query parameters.</param>
internal void AddBingKey(NameValueCollection query)
/// <param name="query">A <see cref="QueryString"/> with the query parameters.</param>
internal void AddBingKey(ref QueryString query)
{
query.Add("key", _keyContainer.GetKey());
query = query.Add("key", _keyContainer.GetKey());
}
}
}
26 changes: 26 additions & 0 deletions src/Geo.Core/Abstractions/IGeoNETExceptionProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// <copyright file="IGeoNETExceptionProvider.cs" company="Geo.NET">
// Copyright (c) Geo.NET.
// Licensed under the MIT license. See the LICENSE file in the solution root for full license information.
// </copyright>

namespace Geo.Core
{
using System;
using Geo.Core.Models.Exceptions;

/// <summary>
/// An interface used to provide an exception based on the exception type.
/// </summary>
public interface IGeoNETExceptionProvider
{
/// <summary>
/// Gets an exception of type <typeparamref name="TException"/>.
/// </summary>
/// <typeparam name="TException">The type of the exception to get.</typeparam>
/// <param name="message">The message the exception should have.</param>
/// <param name="innerException">Optional. The inner exception to include in the exception.</param>
/// <returns>An exception of type <typeparamref name="TException"/>.</returns>
TException GetException<TException>(string message, Exception innerException = null)
where TException : GeoCoreException;
}
}
Loading