Skip to content

Commit

Permalink
2.1.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinCanton authored May 20, 2024
2 parents 4081853 + f88b0d3 commit 31e2302
Show file tree
Hide file tree
Showing 69 changed files with 4,545 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

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

## [2.0.0](https://github.com/JustinCanton/Geo.NET/compare/1.6.0...2.0.0) (2024-01-30)
## [2.1.0](https://github.com/JustinCanton/Geo.NET/compare/2.0.0...2.1.0) (2024-05-20)
### Features
- **radar**: adding support for the Radar geocoding API ([#100](https://github.com/JustinCanton/Geo.NET/issues/100)) ([448b087](https://github.com/JustinCanton/Geo.NET/commit/448b0876a0fb36fc74f348752e7dd77f63f3f7dd))
- **positionstack**: adding support for the positionstack geocoding API ([#65](https://github.com/JustinCanton/Geo.NET/issues/65)) ([205676b](https://github.com/JustinCanton/Geo.NET/commit/205676ba8a27451caf9000333fb0d8f67223b796))

## [2.0.0](https://github.com/JustinCanton/Geo.NET/compare/1.6.0...2.0.0) (2024-01-28)
### ⚠ BREAKING CHANGES
- removed native support for net5.0 since it is an out of support item, and dropped netstandard2.1 since this supports netstandard2.0
- removed the usage of Newtonsoft.Json and moved to use System.Text.Json
Expand Down
28 changes: 28 additions & 0 deletions Geo.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geo.MapBox.Tests", "test\Ge
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geo.MapQuest.Tests", "test\Geo.MapQuest.Tests\Geo.MapQuest.Tests.csproj", "{85FF4115-0880-4DF6-816A-B314CA0432D3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geo.Radar", "src\Geo.Radar\Geo.Radar.csproj", "{38C213E3-55D6-4FC7-87CA-E28C3EDD42EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geo.Radar.Tests", "test\Geo.Radar.Tests\Geo.Radar.Tests.csproj", "{1A320DE3-B14B-46EE-A0E6-C6783E585F73}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geo.Positionstack", "src\Geo.Positionstack\Geo.Positionstack.csproj", "{03C7B4AE-7905-4292-8133-3F4AA6EDCA3A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geo.Positionstack.Tests", "test\Geo.Positionstack.Tests\Geo.Positionstack.Tests.csproj", "{E09BD60D-6E8A-4210-9274-695A2DFFE976}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -107,6 +115,22 @@ Global
{85FF4115-0880-4DF6-816A-B314CA0432D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85FF4115-0880-4DF6-816A-B314CA0432D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85FF4115-0880-4DF6-816A-B314CA0432D3}.Release|Any CPU.Build.0 = Release|Any CPU
{38C213E3-55D6-4FC7-87CA-E28C3EDD42EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38C213E3-55D6-4FC7-87CA-E28C3EDD42EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38C213E3-55D6-4FC7-87CA-E28C3EDD42EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38C213E3-55D6-4FC7-87CA-E28C3EDD42EA}.Release|Any CPU.Build.0 = Release|Any CPU
{1A320DE3-B14B-46EE-A0E6-C6783E585F73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A320DE3-B14B-46EE-A0E6-C6783E585F73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A320DE3-B14B-46EE-A0E6-C6783E585F73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A320DE3-B14B-46EE-A0E6-C6783E585F73}.Release|Any CPU.Build.0 = Release|Any CPU
{03C7B4AE-7905-4292-8133-3F4AA6EDCA3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03C7B4AE-7905-4292-8133-3F4AA6EDCA3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03C7B4AE-7905-4292-8133-3F4AA6EDCA3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03C7B4AE-7905-4292-8133-3F4AA6EDCA3A}.Release|Any CPU.Build.0 = Release|Any CPU
{E09BD60D-6E8A-4210-9274-695A2DFFE976}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E09BD60D-6E8A-4210-9274-695A2DFFE976}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E09BD60D-6E8A-4210-9274-695A2DFFE976}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E09BD60D-6E8A-4210-9274-695A2DFFE976}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -126,6 +150,10 @@ Global
{3EE9598A-8464-450E-9BE4-C19E3FC1450D} = {67253D97-9FC9-4749-80DC-A5D84339DC05}
{2D1EB4BD-E554-46B6-8FEE-73CC486341F2} = {67253D97-9FC9-4749-80DC-A5D84339DC05}
{85FF4115-0880-4DF6-816A-B314CA0432D3} = {67253D97-9FC9-4749-80DC-A5D84339DC05}
{38C213E3-55D6-4FC7-87CA-E28C3EDD42EA} = {8F3BA9BC-542C-450C-96C9-F0D72FECC930}
{1A320DE3-B14B-46EE-A0E6-C6783E585F73} = {67253D97-9FC9-4749-80DC-A5D84339DC05}
{03C7B4AE-7905-4292-8133-3F4AA6EDCA3A} = {8F3BA9BC-542C-450C-96C9-F0D72FECC930}
{E09BD60D-6E8A-4210-9274-695A2DFFE976} = {67253D97-9FC9-4749-80DC-A5D84339DC05}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C4B688C4-40EC-4577-9EB2-4CF2412DA0B1}
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ The support for this project includes:
- Licensed API
- [Geocoding](https://developer.mapquest.com/documentation/geocoding-api/address/get/)
- [Reverse Geocoding](https://developer.mapquest.com/documentation/geocoding-api/reverse/get/)
- Positionstack
- [Geocoding](https://positionstack.com/documentation#forward_geocoding)
- [Reverse Geocoding](https://positionstack.com/documentation#reverse_geocoding)
- Radar
- [Geocoding](https://radar.com/documentation/api#geocoding)
- [Reverse Geocoding](https://radar.com/documentation/api#reverse-geocode)
- [Autocomplete](https://radar.com/documentation/api#autocomplete)


## Configuration and Sample Usage
Expand All @@ -47,6 +54,8 @@ The configuration and sample usage for each supported interface can be found wit
- [HERE](https://github.com/JustinCanton/Geo.NET/tree/master/src/Geo.Here)
- [MapBox](https://github.com/JustinCanton/Geo.NET/tree/master/src/Geo.MapBox)
- [MapQuest](https://github.com/JustinCanton/Geo.NET/tree/master/src/Geo.MapQuest)
- [Positionstack](https://github.com/JustinCanton/Geo.NET/tree/master/src/Geo.Positionstack)
- [Radar](https://github.com/JustinCanton/Geo.NET/tree/master/src/Geo.Radar)


## Suggestions or Discussion Points
Expand Down
12 changes: 8 additions & 4 deletions src/Geo.Core/GeoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public abstract class GeoClient
{
private static readonly JsonSerializerOptions _options = GetJsonSerializerOptions();

private readonly HttpClient _client;
private readonly ILogger<GeoClient> _logger;

/// <summary>
Expand All @@ -40,10 +39,15 @@ protected GeoClient(
#endif
{
Resources.GeoClient.Culture = CultureInfo.InvariantCulture;
_client = client ?? throw new ArgumentNullException(nameof(client));
Client = client ?? throw new ArgumentNullException(nameof(client));
_logger = loggerFactory?.CreateLogger<GeoClient>() ?? NullLogger<GeoClient>.Instance;
}

/// <summary>
/// Gets the http client associated with the <see cref="GeoClient"/>.
/// </summary>
protected HttpClient Client { get; private set; }

/// <summary>
/// Gets the name of the API being called for exception logging purposes.
/// </summary>
Expand Down Expand Up @@ -287,11 +291,11 @@ internal async Task<HttpResponseMessage> HttpCallAsync(
{
if (method.Method == HttpMethod.Get.Method)
{
return await _client.GetAsync(uri, cancellationToken).ConfigureAwait(false);
return await Client.GetAsync(uri, cancellationToken).ConfigureAwait(false);
}
else
{
return await _client.PostAsync(uri, content, cancellationToken).ConfigureAwait(false);
return await Client.PostAsync(uri, content, cancellationToken).ConfigureAwait(false);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Geo.MapBox/Services/MapBoxGeocoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MapBoxGeocoding : GeoClient, IMapBoxGeocoding
/// Initializes a new instance of the <see cref="MapBoxGeocoding"/> class.
/// </summary>
/// <param name="client">A <see cref="HttpClient"/> used for placing calls to the here Geocoding API.</param>
/// <param name="options">An <see cref="IOptions{TOptions}"/> of <see cref="KeyOptions{T}"/> containing Google key information.</param>
/// <param name="options">An <see cref="IOptions{TOptions}"/> of <see cref="KeyOptions{T}"/> containing MapBox key information.</param>
/// <param name="loggerFactory">An <see cref="ILoggerFactory"/> used to create a logger used for logging information.</param>
public MapBoxGeocoding(
HttpClient client,
Expand Down
37 changes: 37 additions & 0 deletions src/Geo.Positionstack/Abstractions/IPositionstackGeocoding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// <copyright file="IPositionstackGeocoding.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.Positionstack
{
using System.Threading;
using System.Threading.Tasks;
using Geo.Core.Models.Exceptions;
using Geo.Positionstack.Models.Parameters;
using Geo.Positionstack.Models.Responses;

/// <summary>
/// An interface for calling the Positionstack geocoding methods.
/// </summary>
public interface IPositionstackGeocoding
{
/// <summary>
/// Calls the Positionstack geocoding API and returns the results.
/// </summary>
/// <param name="parameters">A <see cref="GeocodingParameters"/> with the parameters of the request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> used to cancel the request.</param>
/// <returns>A <see cref="Response"/> with the response from Positionstack.</returns>
/// <exception cref="GeoNETException">Thrown for multiple different reasons. Check the inner exception for more information.</exception>
Task<Response> GeocodingAsync(GeocodingParameters parameters, CancellationToken cancellationToken = default);

/// <summary>
/// Calls the Positionstack reverse geocoding API and returns the results.
/// </summary>
/// <param name="parameters">A <see cref="ReverseGeocodingParameters"/> with the parameters of the request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> used to cancel the request.</param>
/// <returns>A <see cref="Response"/> with the response from Positionstack.</returns>
/// <exception cref="GeoNETException">Thrown for multiple different reasons. Check the inner exception for more information.</exception>
Task<Response> ReverseGeocodingAsync(ReverseGeocodingParameters parameters, CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// <copyright file="IFilterGeocodeParameters.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.Positionstack.Models
{
using System.Collections.Generic;

/// <summary>
/// The base filter parameters used for geocoding or reverse geocoding.
/// </summary>
public interface IFilterGeocodeParameters
{
/// <summary>
/// Gets or sets the 2-letter(e.g.en) or the 3-letter code(e.g.eng) of your preferred language to translate specific API response objects.
/// <para>Optional.</para>
/// <para>Default: English.</para>
/// </summary>
string Language { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the country module should be enabled to include more extensive country data in your API response.
/// <para>Optional.</para>
/// <para>Default: false.</para>
/// </summary>
bool CountryModule { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the sun module should be enabled to include astrology data in your API response.
/// <para>Optional.</para>
/// <para>Default: false.</para>
/// </summary>
bool SunModule { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the timezone module should be enabled to include timezone data in your API response.
/// <para>Optional.</para>
/// <para>Default: false.</para>
/// </summary>
bool TimezoneModule { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the bounding box module should be enabled to include boundary coordinates in your API response.
/// <para>Optional.</para>
/// <para>Default: false.</para>
/// </summary>
bool BoundingBoxModule { get; set; }

/// <summary>
/// Gets or sets a limit between 1 and 80 to limit the number of results returned per geocoding query.
/// <para>Optional.</para>
/// <para>Default: 10.</para>
/// </summary>
uint Limit { get; set; }

/// <summary>
/// Gets a list of one or more response fields to decrease API response size.
/// <para>Optional.</para>
/// </summary>
IList<string> Fields { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <copyright file="ILocationGeocodeParameters.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.Positionstack.Models
{
using System.Collections.Generic;

/// <summary>
/// The location based filter parameters used for geocoding or reverse geocoding.
/// </summary>
public interface ILocationGeocodeParameters
{
/// <summary>
/// Gets one or more 2-letter(e.g.AU) or 3-letter country codes(e.g.AUS) to filter the geocoding results.
/// <para>Optional.</para>
/// </summary>
IList<string> Countries { get; }

/// <summary>
/// Gets or sets a filter for the geocoding results specifying a region. This could be a neighbourhood, district, city, county, state or administrative area. Example: region= Berlin to filter by locations in Berlin.
/// <para>Optional.</para>
/// </summary>
string Region { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// <copyright file="ServiceCollectionExtensions.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.Extensions.DependencyInjection
{
using System;
using Geo.Positionstack;
using Geo.Positionstack.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

/// <summary>
/// Extension methods for the <see cref="IServiceCollection"/> class.
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Adds the Positionstack geocoding services to the service collection.
/// <para>
/// Adds the services:
/// <list type="bullet">
/// <item><see cref="IOptions{TOptions}"/> of <see cref="IPositionstackGeocoding"/></item>
/// <item><see cref="IPositionstackGeocoding"/></item>
/// </list>
/// </para>
/// </summary>
/// <param name="services">An <see cref="IServiceCollection"/> to add the Positionstack services to.</param>
/// <returns>An <see cref="KeyBuilder{T}"/> to configure the Positionstack geocoding.</returns>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="services"/> is null.</exception>
public static KeyBuilder<IPositionstackGeocoding> AddPositionstackGeocoding(this IServiceCollection services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}

services.AddKeyOptions<IPositionstackGeocoding>();

return new KeyBuilder<IPositionstackGeocoding>(services.AddHttpClient<IPositionstackGeocoding, PositionstackGeocoding>());
}
}
}
62 changes: 62 additions & 0 deletions src/Geo.Positionstack/Extensions/LoggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// <copyright file="LoggerExtensions.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.Positionstack
{
using System;
using Geo.Positionstack.Services;
using Microsoft.Extensions.Logging;

/// <summary>
/// Extension methods for the <see cref="ILogger"/> class.
/// </summary>
internal static class LoggerExtensions
{
private static readonly Action<ILogger, string, Exception> _error = LoggerMessage.Define<string>(
LogLevel.Error,
new EventId(1, nameof(PositionstackGeocoding)),
"PositionstackGeocoding: {ErrorMessage}");

private static readonly Action<ILogger, string, Exception> _warning = LoggerMessage.Define<string>(
LogLevel.Warning,
new EventId(2, nameof(PositionstackGeocoding)),
"PositionstackGeocoding: {WarningMessage}");

private static readonly Action<ILogger, string, Exception> _debug = LoggerMessage.Define<string>(
LogLevel.Debug,
new EventId(3, nameof(PositionstackGeocoding)),
"PositionstackGeocoding: {DebugMessage}");

/// <summary>
/// "PositionstackGeocoding: {ErrorMessage}".
/// </summary>
/// <param name="logger">An <see cref="ILogger"/> used to log the error message.</param>
/// <param name="errorMessage">The error message to log.</param>
public static void PositionstackError(this ILogger logger, string errorMessage)
{
_error(logger, errorMessage, null);
}

/// <summary>
/// "PositionstackGeocoding: {WarningMessage}".
/// </summary>
/// <param name="logger">An <see cref="ILogger"/> used to log the warning message.</param>
/// <param name="warningMessage">The warning message to log.</param>
public static void PositionstackWarning(this ILogger logger, string warningMessage)
{
_warning(logger, warningMessage, null);
}

/// <summary>
/// "PositionstackGeocoding: {DebugMessage}".
/// </summary>
/// <param name="logger">An <see cref="ILogger"/> used to log the debug message.</param>
/// <param name="debugMessage">The debug message to log.</param>
public static void PositionstackDebug(this ILogger logger, string debugMessage)
{
_debug(logger, debugMessage, null);
}
}
}
Loading

0 comments on commit 31e2302

Please sign in to comment.