-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add interface API for geocoders #38169
Conversation
Refs qgis/QGIS-Enhancement-Proposals#64 @rduivenvoorde ping, you've previously shown interest in this topic |
@nyalldawson Thanks! I try to understand current reasoning, most of my points in the QEP were already served by the QgsLocator stuff, with which I was very happy :-) Some thoughts ( I try to be helpfull, please ignore if I make stuff too complex ):
Brainwaving about the gui part now:
Ok, HTIH :-) |
Right - so the locator is definitely not going anywhere, and in my view should remain as the UI interface for "one-off" searches. For those, this interface is designed to assist plugin developers with easily exposing their geocoder to the locator and allow them to skip all the "copy and paste" required to create a locator filter. If the plugin is exposing a geocoder which follows a standard (such as an ArcGIS Server locator), then it could be as simple as the plugin creating a filter by:
Again, the intention is to create a simple adaptor class which exposes a geocoder as a ready-made bulk processing algorithm. In that case, the algorithm adapter would be responsible for transforming the geocoder result into a feature (and making the decision about whether to just take the first result, or ...? and whether to add additional "geocode metadata" attributes as fields, etc)
I'd say we should address this by adding some "preview geometry" functionality to the locator, so that you can hover over results in the list and see a temporary highlight of the result geometry.
It's for lots of things :), but mostly to allow us flexibility to add other useful things to the context in future without breaking api. If we add all these as extra arguments now, then we can't possibly add more later without breaking api. Currently the context contains useful things like a bounding box geometry which can optionally be used by the geocoder to prioritise results based on their proximity to this area. It's up to the individual geocoder if this is useful, but the more information we provide through the context the more useful the geocoder results will be.
Yes, that's why the methods return a list of results. Depending on the task we may only want to use the first results and discard the rest (e.g. bulk geocoding), but elsewhere we'd want to expose them all and let the user pick (locator filter)
That's a good point. Let me think on that one. Maybe another capability flag to indicate that a geocoder supports this and a new virtual method.
The proposed API should be ok for this use case. Incidentally, back a couple of lifetimes ago I used to work in a field where we spent a lot of effort geocoding records. One tool I made there was an interactive geocoder, which would bulk geocode and prompt users for choices whenever the results where ambiguous. They'd get a nice dialog showing all identified "close" matches along with a map canvas they could use to manually place the record. Maybe one day we'll have a tool like this in QGIS too! (or a plugin for it)
See above note about the context. For the locator filter, we'd use the current map canvas extent as this geographic hint.
As above, we'll still utilise the locator bar for one-off searches 😄 |
Great idea. I'd say though we should have a max scale, so that if someone is zoomed onto a very small area, the geocoder doesn't limit search to that narrow area. |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist. |
I'd like to merge this now, unless anyone has objections? |
Hey, I'd love for this to be merged :) |
sounds good to me. |
Registry no -- but algorithm and filter adapters will be.
I'll include tests of the algorithm and filter... but this PR is just an interface, so there's no really anything I can usefully test... |
Thanks. Yes please do, I will try to implement both our national geocoder AND reverse geocoder in it then :-) One practical thing is there is often a round trip to retrieve the actual object, so you get 'results' back within it feature id's which you have to fetch separately. One other thing I wonder, this seems to return a 'list' of GeocoderResults (being mostly features). Geocoder then is via geocodeString (example input is zipcode plus building number) https://geodata.nationaalgeoregister.nl/locatieserver/v3/suggest?q=2022zj 23&rows=20&fq=+type:gemeente+type:woonplaats+type:weg+type:postcode+type:adres+type:perceel+type:hectometerpaal And ReverseGeocoding is via geocodeFeature |
That's handled by the "adapter" classes. I think it'll become clearer when I open the next PR. I'll merge this one for now and will revisit this discussion in the follow up PRs. |
This PR adds a basic interface for geocoder classes and operations, to allow a standard API for these using services.
Currently we have tons of geocoder-ish plugins, all of which use their own approaches and interface. Some have updated to use the unified locator bar as their UI, but others have retained custom UI, and to date few (maybe none?) are exposed through processing for bulk geocoding operations.
Accordingly, this interface is designed to remedy this situation! The intention here is that a follow up PR will add adapter classes for easily exposing a QgsGeocoderInterface implementation as a Processing algorithm or locator bar filter, e.g. via
Possibly we code include some services out-of-the-box as processing algorithms!
Here's an example Google Maps geocoder which follows the interface: