-
Notifications
You must be signed in to change notification settings - Fork 3
Land offline search and Android geocoder for more accurate addresses #773
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If there's network available then we can use Photon (our own server) or possible Android Geocoder if the phone supports it (likely, but not guaranteed). Without network we'll have to do our own geocoding using the tile data that we have.
Tests for both forward and reverse geocoding including use of a library (AndroidAddressFormatter) to present the addresses in the correct format for their location. That is now used for Photon, Android and Offline output and the results tend to be fairly close. During tile parsing we now parse the housenumber layer into a number of FeatureTrees, one for each named road. This makes it much easier to reverse geocode when we're map matched - or indeed just assuming the nearest road. The Geocoder Test now gives the most accurate results with LocalDecoder for the first test where the location is on a corner between two streets. When there's a map matched Way the LocalDecoder uses it, whereas the other two are performing a search without any extra knowledge. There's also a new StreetDescription class. This follows a named street and creates linear maps of street numbers and point of interest. This can then be looked up to get an interpolated street address and a description of the location relative to intersections and POI. It's used within OfflineGeocoder for reverse geocoding. The search UI has been changed so that the user has to hit the search icon to trigger a search. There are a few reasons for this: 1. AndroidGeocoder calls have a daily allowed limit and so we don't want to use more than we have to. 2. It encourages the user to write a more complete search which is what is required by both AndroidGeocoder and LocalGeocoder. The default geocoder setup is "Auto" which uses Android if there's network, and Offline if there's not i.e. not Photon at all. However, in theory not all phones have Android geocoder support and so it will fall back to using Photon if that's the case and there is network. Settings has the option to select which search to use. Offline will still be the fall back in the case of no network. Offline search results have a slightly different icon in the results list (just for developer debug for now). The string comparison used in searching is an adjusted Levenshtein Damerau which compares only up to the length of the search string. This is to allow matching of partial strings e.g. "Tesco" (or indeed "Yesco" with "Tesco express").
Named cycle ways such as Bears Way and Hills Road cycleway which run parallel to roads were making for very confusing directions. Treating them as if they are pavements improves callouts significantly as they are now largely ignored and callouts are given from the perspective of the adjacent street. The intersection callout code needed a little more adjustment so that pavements (cycleways or sidewalks) aren't called out in intersections and those which consist of only pavements are ignored altogether.
Add a new TreeId WAY_SELECTED which can be set to either ROADS or ROADS_AND_PATHS. It controls everything in the app to either include paths or only deal with roads. For now it's hard coded to ROADS_AND_PATHS, but it allows a change later.
This had been changed during offline map search testing. It can be restored now, though we need an updated build in order to make those tests work.
Update the github recipes and fix up failing unit tests.
…ults The AndroidGeocoder when available has good street number accuracy. The FusedGeocoder uses this where possible, but also uses PhotonGeocoder for POI names which the AndroidGeocoder lacks. The result should be seamless address searching and improved addresses for POI searching.
The geocoders are designed to give accurate results but the train/bus callout (road sense callout) requires just a general location that can always be made from the local grid.
The Android and Photon geocoders are used together and so remove the ability to select them individually.
This reduces the area over which AndroidGeocoder works, but we've been very generous allowing 10 degrees in every direction.
It's now possible to click on search results and return to the search list without losing the search text from the input field. Unfortunately it's not so easy to have the cursor in the input field appear at the end of the text but it's better than before.
This is specifically for the case of searching for "Post Office" and finding "Craigash Road Post Office". All UK post offices are named in this way and it's very likely a common pattern in other countries. As a result the search has been altered to look for the search pattern at the end of strings as well as at the beginning.
AndroidGeocoder requires the town/city name e.g. 35 Sauchiehall Glasgow. But OfflineGeocoder in TileSearch only wants the street name. This code tries to match the last words of the search string with local settlements and removes them so that the search is just looking for street names. I'd hope that this robust across languages, but more testing required.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The majority of the changes here are in the area of search, geocoding and reverse geocoding. We always used our photon search server, but OSM isn't always great for street numbering and there is an Android geocoder available on many Android phones (not all) which does a much better job. The changes from the user perspective are:
There's still some work to do, but it's an improvement on what was there before.