Giter VIP home page Giter VIP logo

geo.net's Introduction

Geo.NET

This is a simple, light-weight solution for interfacing with multiple geocoding APIs.

The support for this project includes:

Configuration and Sample Usage

The configuration and sample usage for each supported interface can be found within each project.

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 ❌ = Rejected ❓ = Still discussing

Decision Suggestion
Adding support for routing APIs (This may spawn a new repository rather than being placed in this repository)

Get Started and How To Contribute

Use a form of Visual Studio to work with the project for a seamless experience.

Pull the project, and open the Geo.NET.sln file to build this library.

Some of the best ways to contribute are to try things out, file issues, join in design conversations, and make pull-requests.

geo.net's People

Contributors

caspertwo avatar farthom avatar justincanton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

geo.net's Issues

Remove net5 support

Is your feature request related to a problem? Please describe.
Net5 has been out of support by Microsoft for a while. It should be dropped from the target frameworks of the Geo packages.

Describe the solution you'd like
We need to remove direct net5 support from the nuget.

Add the possibility to configure API Keys at runtime

Hello @JustinCanton,

I was using the library and I saw something that could improve the usability of it. Basically it seems that there is no possibility to configure API keys of the providers outside the Startup.

This could lead to some problems sometimes, maybe you want to have some custom or complex logic to decide which API key should you use directly in the service using the provider.

Basically, something like this:

public MapboxGeocodingHelpers(IOptions<ApplicationConfiguration> appSettings, IMapBoxGeocoding mapBoxGeocoding)
{
   _mapBoxGeocoding = mapBoxGeocoding;
   _mapBoxGeocoding.SetApiKey(appSettings.Value.MapboxAPIKey)
}

Or like the official Google API is doing

public async Task<CompleteAddressDTO> GeocodeAddress(string address, CultureInfo culture)
{
   AddressGeocodeRequest request = new AddressGeocodeRequest { Key = _appSettings.GoogleMapsApiKeyForBackEnd, Address = address, Language = GetLanguageFromCulture(culture) };
   GeocodeResponse response = await GoogleMaps.Geocode.AddressGeocode.QueryAsync(request);
   ...
}

Do you plan to implement something like that? I think it will be very useful in various scenarios

MapBox Query with pound sign # has Unexpected Results

When calling .BuildGeocodingRequest or .BuildReverseGeocodingRequest with a query that contains a pound sign (#) the resulting URI is truncated at the location of the # and characters after are not included. This is related to how UriBuilder and UriBuilder .Query interact, specifically the constructed URI is fine (line 125) but when UriBuilder.Query is assigned to at 158 it truncates everything after #. There may be other problematic characters related to the construction of URIs.

According to the MapBox api any such punctuation can be passed but it's treated as a word separator:
https://docs.mapbox.com/help/troubleshooting/address-geocoding-format-guide/

One possible fix is to replace all such punctuation with spaces.

A more ambitious fix would be to implement some sort of GeocodingParameters.Query builder pattern which could handle this and also enforce other MapBox query limitations such as a max "word" length of 20 and a max character length of 256. This pattern could also implement the "batch" feature where multiple queries are separated via semicolons (though batch queries also require mapbox.places-permanent)

Support flexible polyline encoding for the HERE API endpoints

Is your feature request related to a problem? Please describe.
The HERE endpoints take in a flexible polyline which specify the area to search within. It would be nice to have the ability to take in a coordinate, and convert it to a polyline within the this nuget, instead of requiring a polyline be passed in.

Describe the solution you'd like
Reference the nuget from the https://github.com/heremaps/flexible-polyline for generating the polyline information.

Describe alternatives you've considered
Implement polyline support ourselves to avoid external nuget dependencies.

Additional context
See https://github.com/heremaps/flexible-polyline for more information about how it works.

Here not returning status code when unsuccesfull call

Hi @JustinCanton , I was making some tests for the HERE connector.

I have got the error: "The call to Here did not return a successful http status code. See the exception data for more information." but no Inner Exception is shown. This leads to that you don't know if your API key is invalid, if you exceeded the limits, if you sent a wrong parameter etc. etc. and it is impossible to debug what's going on.

Here the exampe: https://ibb.co/Y7BwsFf

Many thanks

MapBox 404 not handled.

When a query to MapBox returns 0 results the library isn't handling it gracefully.

To Reproduce
using nuget Geo.MapBox 1.1.1

Call Mapbox.GeocodingAsync with some query that returns no results.

Raw request:

  • replace NONEXISTENTPLACE with any number of queries that have 0 results
  • replace TOKEN with your access token
GET https://api.mapbox.com/geocoding/v5/mapbox.places/NONEXISTENTPLACE?autocomplete=true&fuzzyMatch=true&limit=1&routing=false&access_token=TOKEN HTTP/1.1
Host: api.mapbox.com

Raw response

HTTP/1.1 404 Not Found
Content-Type: application/json; charset=utf-8
Content-Length: 23
Connection: keep-alive
Date: Tue, 09 Aug 2022 00:01:06 GMT
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: x-rate-limit-interval,x-rate-limit-limit,x-rate-limit-remaining,x-rate-limit-reset
Cache-Control: max-age=604800
X-Rate-Limit-Limit: 600
X-Rate-Limit-Interval: 60
X-Rate-Limit-Reset: 1660003326
Last-Modified: Thu, 04 Aug 2022 19:09:01 GMT
Vary: Accept-Encoding
X-Cache: Error from cloudfront
Via: 1.1 5ece3a8d1e959c303daa9320e4fea502.cloudfront.net (CloudFront)
Age: 77

{"message":"Not Found"}

The library throws an exception with no exception data or inner exception.

Geo.MapBox.Models.Exceptions.MapBoxException
  HResult=0x80131500
  Message=The call to MapBox did not return a successful http status code. See the exception data for more information. See the inner exception for more information.
  Source=Geo.Core
  StackTrace:
   at Geo.Core.ClientExecutor.<CallAsync>d__4`2.MoveNext()
   at Geo.MapBox.Services.MapBoxGeocoding.<GeocodingAsync>d__9.MoveNext()
InnerException | null | System.Exception

Expected behavior
One of the following in order of preference (you should probably standardize the "no result" response across your other providers:

  1. A Empty set/object
  2. null
  3. An exception properly indicating no results found.

Don't pull in entire ASP.NET Core framework

Is your feature request related to a problem? Please describe.
Usage of the framework reference is causing issues for usage of the nuget outside of an AspNet Core environment is causing issues. See #59 for more information about the usage.

Describe the solution you'd like
Remove the framework reference.

Describe alternatives you've considered
The alternatives at the moment are:

  • Use an older version of Microsoft.AspNetCore.Http.Abstractions for all frameworks
  • Pull the QueryString code into this repo and use a local implementation

AddressCandidateParameters in ArcGis Missing many parameters

Hi @JustinCanton,

Followinf my tests I saw that the FindAddressCandidates of ArcGis is missing pretty many parameters, but looking in the source code I think most of the endppoints of ArcGis are missing a lot of parameters.

In this case perhaps are specially interesting countryCode, category, maxLocations, matchOutOfRange, locationType, langCode, sourceCountry among others.

And I was wondering if you are using the outFields=* to retrieve all the response, because in any other case they return the bare minimum.

Many thanks!

Concurrency issue when creating a resource provider

Describe the bug
It seems like there is a concurrency issue when creating a resource provider in the services. It doesn't seem to happen often, as it has only happened once in all of the builds.

To Reproduce
It is a random error, that I cannot reproduce. It has only happened in one build.

  Failed Geo.MapQuest.Tests.Services.MapQuestGeocodingShould.ReverseGeocodingAsyncSuccessfully [231 ms]
  Error Message:
   System.ArgumentException : The key already existed in the dictionary.
  Stack Trace:
     at System.Collections.Concurrent.ConcurrentDictionary`2.System.Collections.Generic.IDictionary<TKey,TValue>.Add(TKey key, TValue value)
   at Geo.Core.GeoNETResourceStringProviderFactory.CreateResourceStringProvider(String resourceFileName, Assembly assembly) in /home/runner/work/Geo.NET/Geo.NET/src/Geo.Core/GeoNETResourceStringProviderFactory.cs:line 54
   at Geo.Core.GeoNETResourceStringProviderFactory.CreateResourceStringProvider(Type resourceType) in /home/runner/work/Geo.NET/Geo.NET/src/Geo.Core/GeoNETResourceStringProviderFactory.cs:line 35
   at Geo.Core.GeoNETResourceStringProviderFactory.CreateResourceStringProvider[TResource]() in /home/runner/work/Geo.NET/Geo.NET/src/Geo.Core/GeoNETResourceStringProviderFactory.cs:line 24
   at Geo.Core.ClientExecutor..ctor(HttpClient client, IGeoNETExceptionProvider exceptionProvider, IGeoNETResourceStringProviderFactory resourceStringProviderFactory, ILoggerFactory loggerFactory) in /home/runner/work/Geo.NET/Geo.NET/src/Geo.Core/ClientExecutor.cs:line 43
   at Geo.MapQuest.Services.MapQuestGeocoding..ctor(HttpClient client, IMapQuestKeyContainer keyContainer, IMapQuestEndpoint endpoint, IGeoNETExceptionProvider exceptionProvider, IGeoNETResourceStringProviderFactory resourceStringProviderFactory, ILoggerFactory loggerFactory) in /home/runner/work/Geo.NET/Geo.NET/src/Geo.MapQuest/Services/MapQuestGeocoding.cs:line 54
   at Geo.MapQuest.Tests.Services.MapQuestGeocodingShould.BuildService(MapQuestEndpoint endpoint) in /home/runner/work/Geo.NET/Geo.NET/test/Geo.MapQuest.Tests/Services/MapQuestGeocodingShould.cs:line 526
   at Geo.MapQuest.Tests.Services.MapQuestGeocodingShould.ReverseGeocodingAsyncSuccessfully() in /home/runner/work/Geo.NET/Geo.NET/test/Geo.MapQuest.Tests/Services/MapQuestGeocodingShould.cs:line 473
--- End of stack trace from previous location where exception was thrown ---

Expected behavior
The code should successfully create the resource even in a concurrent environment.

Add support for Language in MapBox

Hi, it seems that an important property, the Language is missing from the MapBox Geocoder.
As from the documentation, a language can be passed to influence the results but, there is no configuration for this, except the readonly Languages property.

Do you plan to implement this in the close future?
Many thanks

Move from Newtonsoft.Json to System.Text.Json

We need to move from Newtonsoft to System.Text.Json, since Newtonsoft has reached its end of life and is slower in comparison to other json serializers.

Utf8Json is an alternative that can be considered, but I would prefer to not have external dependencies within the code aside from Microsoft dependencies.

Remove culture from query generation

Describe the bug
When generating the query string, some objects are using their ToString method to build up information. This is causing a problem when it comes to different cutltures though. Some cultures print out floats differently. We need to make sure the ToString generation is culture invariant.

To Reproduce
Steps to reproduce the behavior:

  1. Call MapBox Reverse Geocoding passing in a coordinate in a Turkish culture
  2. Check the generated url, the url has a point with a comma (29,2323234545)

Expected behavior
The generate url should have a point with a decimal (29.2323234545)

Replace IStringLocalizer in favour of lower level resource management

Is your feature request related to a problem? Please describe.
I would like to avoid using Microsoft localization within the library, since using it restricts what other users are able to do in terms of localization.

Describe the solution you'd like
I would like to use the ResourceManager class to fetch resources instead of using the IStringLocalizer wrapper.

Describe alternatives you've considered
There aren't too many alternatives for this unfortunately. I could abandon resource files altogether, but I would prefer to avoid that.

Additional context

Add support for net7

Is your feature request related to a problem? Please describe.
Direct support for net7. needs to be added.

Describe the solution you'd like
Add net7 support

Wrong 'in' parameter in Here Maps

Hey @JustinCanton,

I was just switching to your latest version and my unit tests already spotted an error.

In Here Maps you are passing the 'in' parameters in this way:
https://geocode.search.hereapi.com/v1/geocode?q=31 Hills Point Road, Charlotte&in=USA&limit=1&lang=es-ES&show=countryInfo,streetInfo&apiKey=xxx

But according to their documentation you should use:

countryCode:USA OR countryCode:CAN,MEX,USA

I used the exception data as you told me the other time and this is what I saw:

{"status":400,"title":"Illegal input for parameter 'in'","cause":"Actual parameter value: 'USA'","action":"Unsupported key: 'USA'. Supported keys: 'countryCode'","correlationId":"fa73fe06-133b-4aaf-b654-e9c75177e7ac","requestId":"REQ-c5ae3f1b-3231-4f50-8cb7-15f0277af84c"}

Do you think it will be fast to fix and redeploy to nuget?
Many thanks!

Update the exception handling to centralize the exceptions

Is your feature request related to a problem? Please describe.
There are currently different exceptions for each API being called. This is a lot to deal with when catching the exceptions or using the code.

Describe the solution you'd like
I would like to consolidate these and have them under one exception to allow for easier exception handling.

Add support for netstandard2.0

Is your feature request related to a problem? Please describe.
The lack of support for netstandard2.0 limits the number of frameworks able to use the library. I would like to expand support to include netstandard2.0 which is far more flexible.

Describe the solution you'd like
Add netstandard2.0 support.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.