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

Nominatim search provider #7302

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

glughi
Copy link
Contributor

@glughi glughi commented Oct 28, 2024

What this PR does

Added search provider for Nominatim of OpenStreetMap

Checklist

  • There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
  • I've updated relevant documentation in doc/.
  • I've updated CHANGES.md with what I changed.
  • I've provided instructions in the PR description on how to test this PR.

searchResults.results.length = 0;
searchResults.message = undefined;

if (searchText === undefined || /^\s*$/.test(searchText)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is unnecessary as searchText is always defined and is longer than min length. It is validated in SearchProviderMixin

CesiumMath.toDegrees(view.rectangle.south);

const promise = loadJson(
this.url +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to have this as a Resource if possible, it will be more readable than manually constructed string

name: "Primary country",
description: "Name of the country to prioritize the search results."
})
countryCodes: string = "it";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that terria defaults should be Australia

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to leave it undefined?

}
}

function createZoomToFunction(model: NominatimSearchProvider, resource: any) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add the proper type definition to the resource here instead of any? It should be Feature if I am correct.

@zoran995
Copy link
Contributor

zoran995 commented Oct 28, 2024

also, it would be nice to add unit tests for new features

p.s. Not sure what is team's standpoint whether this should reside in the terria codebase or be a plugin for terriajs, so we don't increase the codebase size and implement/maintain every possible search provider out there. It is the main reason the configurable search providers are implemented, and I didn't have time to test the possibility of using a search provider from a plugin but I don't see why it shouldn't work. @na9da what's your opinion on this

@na9da
Copy link
Collaborator

na9da commented Oct 29, 2024

@zoran995 - thanks for reviewing it.

It might be possible to write this as a plugin, but will require importing several private Terria classes which is not ideal. I would accept this PR and split it out later when the use case is better supported by the plugin framework.

@zoran995
Copy link
Contributor

zoran995 commented Oct 30, 2024

@na9da LGTM, but I noticed one thing that might need additional consideration.
When searching for the place it won't prioritise the results from the currently visible region but will show results from the entire world. As you can see in the image although the map shows Australia the first result is for Germany.
image
In v7 this was resolved by sending double requests to the search provider, first for getting only results in the current view box and second for getting results outside and then those were composed by taking a few results from those.

Do we need to handle this somehow, as multiple requests won't play nicely with the Nominatim TOS? Users already can limit the query to specific countries using countryCodes. Maybe we should also expose bounded as a trait so the user can configure whether to return only results from the viewable part of the map or all results.

@glughi Besides the above this is in a pretty good state from the code perspective, it just needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants