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

Reverse geocoding: first and second fields will have no separator between them even if the first field is not HOUSE_NUMBER #98

Closed
1 of 4 tasks
VincentJoshuaET opened this issue Nov 16, 2022 · 1 comment · Fixed by #102
Assignees
Labels
bug Something isn't working

Comments

@VincentJoshuaET
Copy link

VincentJoshuaET commented Nov 16, 2022

Environment

  • Search SDK Component (check at least one)
    • Core Search SDK (SearchEngine class, and etc.)
    • Offline Search SDK (OfflineSearchEngine class, and etc.)
    • Address Autofill SDK
    • Search UI SDK
  • Android OS version: All
  • Devices affected: All
  • Search SDK Version: 1.0.0-beta.39
  • Included in project Maps SDK, Nav SDK versions if available: Maps 10.9.1

Code examples

val callback = object : SearchCallback {
        override fun onResults(results: List<SearchResult>, responseInfo: ResponseInfo) {
            val result = results.firstOrNull() ?: return
            val address = result.address ?: return
            val formatted = address.formattedAddress(SearchAddress.FormatStyle.Long) ?: return
            continuation.resume(formatted)
        }
        override fun onError(e: Exception) {
            Timber.tag("MapboxUtil").e(e)
        }
    }
    search(ReverseGeoOptions(coordinates.asPoint, limit = 1), Executors.newSingleThreadExecutor() , callback)

Observed behavior and steps

Geocoding [84.0375137, 28.1715234] and formatting the address with FormatStyle.Long results to:
Lekhnath Kaski District, Gandaki, Nepal

Expected behavior

When it should be:
Lekhnath, Kaski District, Gandaki, Nepal

It is because on fun formattedAddress(style: FormatStyle = FormatStyle.Medium): String?, it omits the separator when the first component on the FormatStyle is HOUSE_NUMBER, but it does not check if the first non-null field is actually HOUSE_NUMBER.

My workaround is to create a custom FormatStyle without HOUSE_NUMBER

@VincentJoshuaET VincentJoshuaET added the bug Something isn't working label Nov 16, 2022
@DzmitryFomchyn
Copy link
Contributor

Thank you for the report, I'll fix this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants