osmin icon indicating copy to clipboard operation
osmin copied to clipboard

Enhancement: Location search

Open Framstag opened this issue 4 years ago • 10 comments

The location search interaction does not seem to be optimal yet. If I pass to existing and complete location, everything is OK (nice icons btw. ;-)). I currently use the syntax pattern for this.

However...

In case where I entered the and parts of the I do net get suggestions (at least not fast)

Also in the case I have entered and I do not get any suggestion for streetnumbers. This may be interpreted, that there no number known. The application in this case should at least signal that there are streetnumber or even suggest streetnumbers. We have with OSM a very database with many details. We should be proud and show it ;-)

Again, if there are missing feature in libosmscout for this, or if there are performance problems on "the other side", plese make issues there.

Framstag avatar Mar 27 '21 11:03 Framstag

Currently the client-qt exposes only search by pattern. Should be improved ... I will make a review

janbar avatar Apr 09 '21 17:04 janbar

@Framstag , having a look on search, I found a major issue in core functions:

UTF8StringToUpper, UTF8StringToLower.

Those functions use locale settings to initialize facet, but IMO unicode strings shouldn't handle within this way. For now only the locale code page can be processed right. So if the env is C you cannot handle latin, cyrilic or any other page. That is opposite to the unicode concept. The side effect is you cannot match properly the search string, as resulting you take many others matched objects with a failed convert (char code ?). I am looking for a resolution, first we can use libicu but that add a new dependency. So second I am coding a table to convert lower/upper properly for unicode strings.

janbar avatar Apr 19 '21 14:04 janbar

You are right, these functions doesn't work with C locale. But it is correct, because for converting unicode characters to lower or upper, you really need to know locale. It is locale dependent.

Karry avatar Apr 19 '21 14:04 Karry

You should setup global C++ locale somewhere in your application, before start using these functions

  try {
    std::locale::global(std::locale(""));
  } catch (const std::runtime_error& e) {
    std::cerr << "Cannot set locale: \"" << e.what() << "\"" << std::endl;
  }

Karry avatar Apr 19 '21 14:04 Karry

@Karry, right, but some platforms have only C with character set utf8. As example you are english user and you need to search a location in Germany. In this case you will never succeed to find what you wish. The transliterate is applied on the upper transformation which fails.

Edit: Transliterate is ok because we are using iconv. But the upper function breaks the strings.

janbar avatar Apr 19 '21 14:04 janbar

Note also that at least LocationService uses a StringMatcherFactoryRef for comparison, which allows to inject another implementation.

Which code is the problem and does it use above matcher?

Background: I have an aversion regarding big library build and runtime dependencies ;-) Especially ICU is a monster. By injecting your own implementation (which might use ICU) you could be able to fix this?

Note that using MSYS you do not even get a proper C++ locale at all. A reason why some tests are disabled there.

Framstag avatar Apr 19 '21 15:04 Framstag

@Framstag, me too I have an aversion regarding dependencies. So I am making the code to convert properly an unicode string to upper or lower. Big work to build the table for pages code but it works. I am near the target ... ;-). The code is simple and very fast, because I take the character from the array of the page code.

janbar avatar Apr 19 '21 15:04 janbar

A sample with GREC character with C locale or any other locale:

Ρίξτε μια ματιά εφησυχασμού, Ω ισχυρή γυναίκα, άγια, βασίλισσα, Για τη θανατηφόρα ανεπάρκεια μου Χωρίς αμφιβολία να σας κάνει γαλήνιο: Πάντα λυπημένος από τον μαραμένο χρόνο, Τουλάχιστον, χαμόγελο στον καταραμένο γέρο.

ΡΊΞΤΕ ΜΙΑ ΜΑΤΙΆ ΕΦΗΣΥΧΑΣΜΟΎ, Ω ΙΣΧΥΡΉ ΓΥΝΑΊΚΑ, ΆΓΙΑ, ΒΑΣΊΛΙΣΣΑ, ΓΙΑ ΤΗ ΘΑΝΑΤΗΦΌΡΑ ΑΝΕΠΆΡΚΕΙΑ ΜΟΥ ΧΩΡΊΣ ΑΜΦΙΒΟΛΊΑ ΝΑ ΣΑΣ ΚΆΝΕΙ ΓΑΛΉΝΙΟ: ΠΆΝΤΑ ΛΥΠΗΜΈΝΟΣ ΑΠΌ ΤΟΝ ΜΑΡΑΜΈΝΟ ΧΡΌΝΟ, ΤΟΥΛΆΧΙΣΤΟΝ, ΧΑΜΌΓΕΛΟ ΣΤΟΝ ΚΑΤΑΡΑΜΈΝΟ ΓΈΡΟ.

janbar avatar Apr 19 '21 15:04 janbar

Hi, I tried searching for "CCCB" but it didn't find anything:

Screenshot of the search in Osmin

imatge

For comparison, here I did the same search in OSM: https://www.openstreetmap.org/search?query=CCCB

Screenshot of the search in https://www.openstreetmap.org/

imatge

I have the version 1.8.7 on the pinephone. I have downloaded the map for spain.

Eloitor avatar Feb 23 '23 16:02 Eloitor

Hi, "CCCB" is probably an alias or alternative name for this location. The embedded database cannot includes all things you could find from an internet server that has terrabytes of data. I tried with "centre de cultura barcelona" and that matches with the location. Also I released the new version 1.9.6, that handles more recent databases (maps version 24 with transliterate option). Upgrading, you will need to download again the maps.

janbar avatar Feb 25 '23 15:02 janbar