Fix extended addresses preventing contact map location matches #1446
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.
Contacts with extended addresses (apartment numbers, suite numbers, etc.) were not showing up on the map due to geocoding failures. The issue was in the address processing logic within
AddressService::lookupAddressExternal().Problem
The vCard ADR format uses semicolon-separated fields:
For example:
The existing code only removed the post office box (field 0) but kept the extended address (field 1), resulting in geocoding queries like:
These queries often fail with geocoding services like Nominatim because apartment numbers make the address too specific or ambiguous.
Solution
Enhanced the address processing to remove both the post office box (field 0) AND the extended address (field 1) from geocoding queries:
Now the same address produces a clean geocoding query:
Impact
Fixes #712.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/Bogdaan/open-location-code/zipball/6e384e41cc6d6dd4d87f95c36aabf0de5256bf3f/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/eea219a577085bd13ff0cb644a422c20798316c7/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/93222100a91399314c3726857e249e76c4a7d760/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/nextcloud/coding-standard/zipball/9c719c4747fa26efc12f2e8b21c14a9a75c6ba6d/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/pel/pel/zipball/b95fe29cdacf9d36330da277f10910a13648c84c/usr/bin/php8.3 -n -c /tmp/RHb0xQ /usr/bin/composer install --no-dev(http block)https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c/usr/bin/php8.3 -n -c /tmp/Eav9mG /usr/bin/composer install --no-interaction --ignore-platform-reqs(http block)nominatim.openstreetmap.orgphp /tmp/test_geocoding.php(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.