f1ana / Nominatim.API

Library for utilizing geocoding (forward and reverse), in addition to address lookups, with the Nominatim HTTP API. Targets .NET 6 and .NET Standard 2.0.
https://www.nuget.org/packages/Nominatim.API
MIT License
51 stars 28 forks source link

Dymamic base url and simplified use #28

Closed sawcheg closed 2 years ago

sawcheg commented 2 years ago

Hi, I use your nuget package in my projects. after updating to version 2.0, I ran into the problem of dynamically changing the base Url.

Therefore, I slightly modified the code, while simplifying the use of the API. Also I fixed the tests.

Please review the changes and include them in the next package update.

f1ana commented 2 years ago

There is a much easier way to accomplish this using the standard Microsoft DI library. Using GeocoderIntegrationTests as an example, you can simply register a geocoder with an URL override such as this:

            serviceCollection.AddScoped(typeof(IForwardGeocoder),
                s => new ForwardGeocoder(s.GetService<INominatimWebInterface>(), "https://some.other.url/"));

I can adapt this to use IConfiguration down the road, but I don't think what you are trying to accomplish merits a major refactoring of the library. If you run into any other issues, please file an issue and I will be happy to help.