Skip to content

Conversation

@davecraig
Copy link
Contributor

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:

  1. The search box no longer searches as you type, it only searches when enter/search on the keyboard are pressed
  2. Address search with streetnumber should be much better on many phones in many parts of the world e.g. "20 Roselea Drive Milngavie" will give an accurate result. It should be clear when the result is not accurate in that the result only returns the street and not the house.
  3. If offline maps have been downloaded then there is offline search available. This is used when there's no network available or the user has set the Search to Offline in the settings. Offline search works well for POI and street numbers when there's OSM data available. In all cases it should be much better than no search if there's no network.

There's still some work to do, but it's an improvement on what was there before.

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.
@davecraig davecraig merged commit 5186ef3 into Scottish-Tech-Army:main Jan 21, 2026
1 check passed
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.

1 participant