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

Refactor Address Suggestion Logic to Improve Readability and Align with Addressing Standards. Fixes #10541 #10561

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Deeptanshu-sankhwar
Copy link
Contributor

Fixes #10541

This PR refactors the logic for determining address suggestions to improve readability and ensure compliance with addressing standards. The updated logic falls back to name:en for English names, and truncates multi-value name tags at the first delimiter (;) to handle dual names appropriately.

Screenshot 2024-11-27 at 10 24 44 AM

Comment on lines +60 to +61
: d.tags['name:en']
? d.tags['name:en'] // Fallback to English name
Copy link
Collaborator

@1ec5 1ec5 Nov 27, 2024

Choose a reason for hiding this comment

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

If I’m reading this code correctly, it doesn’t fall back to name:en, it prioritizes name:en over name. But not every region speaks English; that was just an example I gave. I gave some more details about how you might solve this problem in #10541 (comment). However, the simplest solution may just be to truncate on the first semicolon; we could leave #10541 open to address the linguistic problem separately.

Comment on lines +58 to +64
const value = resultProp && d.tags[resultProp]
? d.tags[resultProp]
: d.tags['name:en']
? d.tags['name:en'] // Fallback to English name
: d.tags.name
? d.tags.name.split(';')[0].trim() // Use the first part of name (split by delimiter `;`)
: null; // Default to null if no valid value exists
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this code would be clearer if you first refactor the line to use if/else statements instead of a ternary. Nested ternaries are very difficult to reason about. (Besides, without parentheses, I wouldn’t know at a glance whether the order of precedence is actually what you’ve implied using whitespace.)

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.

Address field dropdowns should choose a name in the relevant language
2 participants