Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
An example:
Currently, if you try to geocode an addressfield containing only Tunisia as a country (no street, city,...), this will be parsed into the text address "TN" (country code), which will be understood by Google Geocoding API as an administrative area code for Tennessee...
Here's a patch to use "component filter" feature to avoid those wrong geocodings.
Comment | File | Size | Author |
---|---|---|---|
#24 | geocoder-structured_format-1967520-24.patch | 12.29 KB | basvredeling |
#21 | geocoder-structured_format-1967520-21.patch | 8.4 KB | ron_s |
#9 | geocoder-structured-format-1967520-9.patch | 7.15 KB | ron_s |
#5 | geocoder-structured-format-1967520-4.patch | 6.86 KB | stockliasteroid |
#4 | geocoder-structured-format.patch | 6.88 KB | GaëlG |
Comments
Comment #1
Simon Georges CreditAttribution: Simon Georges commentedThis could probably be adapted to work for Mapquest Nominatim service as well, if someone wants to take a look at it.
Comment #2
GaëlGThis one is for MapQuest Nominatim.
Comment #3
GaëlGOops, I forgot the
$params = $static_params;
in the else case.Comment #4
GaëlGI made some improvements to this for better geocoding responses (google region parameter, no address parameter when components is used,...). Here's a patch containing all the improvements (including the previous patches), for Google and Mapquest Nominatim.
Comment #5
stockliasteroid CreditAttribution: stockliasteroid commentedThanks for your work on this!
After reviewing and testing a bit, I think the approach needs to be modified... The Component Filtering in the Google Geocoding service aren't meant to be used instead of an address query, but in combination with one, at least if you want non-approximate results. Component filtering only supports a very small subset of address components, and as such won't return accurate results if it's used without an address query. See https://developers.google.com/maps/documentation/geocoding/#ComponentFil.... Specifically, it only supports the following components: administrative_area, route, postal_code, country, and locality. So, I modified the patch to only use administrative_area, country, and locality components, and then I pass the address query along with this data. This fixes the wrong country issue (I was getting Romanian addresses returned as if they were in Iowa), but still returns accurate rooftop-level results.
I also rolled the patch with relative paths, which should make it easier to apply.
Comment #6
gge CreditAttribution: gge commentedHello,
I just tested the above patch (#5) and everything seems to work as expected.
Thanks!
Comment #7
Simon Georges CreditAttribution: Simon Georges commentedOk, let met test that, and I'll commit it, thanks for all the work!).
Comment #8
ron_s CreditAttribution: ron_s commentedPatch #5 seems to help with the issues we started to see after moving from Geocoder 7.x-1.2 to 7.x-1.x-dev. The geocoding in 1.x-dev returns very unpredictable results, and if an address is not typed a very specific way, Geocoder will generate a point hundreds of kilometers away.
Only issue though is the patch does not apply cleanly to 7.x-1.x-dev. Was this written for 7.x-1.2, and will be moved to a -dev version?
Comment #9
ron_s CreditAttribution: ron_s commentedAttached is a re-roll of the patch against the current 7.x-1.x-dev and an interdiff.
The one area that seems confusing is the code added in
geocoder_google
. There is already some new code in 7.x-1.x-dev listed under the comment of "Add any given biasing
" which sets the value of$query['components']
.Then immediately following that is the code included in this patch, which if
$components
is notempty
, the value of$query['components']
is reset. Also right after this is more code that resets$query['region']
if$geocoder_settings['geocoder_region_google']
is set.Should these blocks of code be combined into one conditional?
Comment #10
ron_s CreditAttribution: ron_s commentedThe way the code is structured right now in
geocoder_google
,$components
takes precedence over$options
. If that is the case, I'd think the code in that block should be as follows. Thoughts?Comment #11
ron_s CreditAttribution: ron_s commentedAfter using patch #9 for the past couple of weeks, it's clear the comments mentioned in #10 regarding the conditional need to be incorporated.
Attached is a new patch for review -- this seems to be working fairly well.
Comment #12
GaëlGThere's still a problem with the current Google handling. The doc says "Note: Each address component can only be specified either in the address parameter or as a component filter, but not both. Doing so may result in ZERO_RESULTS."
We have locality, (sub)administrative area and country both in address and components. This might be better:
PS: sorry to provide no patch, I'm in hurry and just hacked from the stable version's patch.
Comment #13
joelpittetMight as well fix these broken translations.
t('The text to a !link', array('!link'=> l(...)));
Gives context to the translators and won't change the string every time the URL changes.
Comment #14
ron_s CreditAttribution: ron_s commentedThanks for the feedback. I've created a new patch including feedback from @GaëlG and @joelpittet. I also included the patch I posted here (https://www.drupal.org/node/2499771)... it's a simple mapquest typo that really should be fixed.
See attached and let me know if any other thoughts.
Comment #15
ron_s CreditAttribution: ron_s commented@joelpittet, thank you for taking care of the typo in #2499771. Even though a simple fix, I prefer not to mark my own patches as reviewed.
Attached is a new version of the patch for review that does not include the mapquest fix.
Comment #16
ron_s CreditAttribution: ron_s commentedGiven the recent release of 7.x-1.3 and focus on the 2.x branch, I'm not certain if anyone still wants this patch? I've created a new version and it is attached for review.
I also separated the broken URL translations referenced in #13 into its own issue: https://www.drupal.org/node/2664294
Comment #17
basvredeling#16 doesn't apply to 1.x-dev dd 5 June 2016
Comment #18
ron_s CreditAttribution: ron_s commentedI've been updating this patch for over a year with no feedback. It would be good to hear from the module maintainers if this is something they plan to review and consider to be committed.
Comment #19
basvredeling#1 I agree. I've tested this, albeit briefly. The functionality is needed but doesn't currently apply. I might not be a module maintainer but I'll gladly review your patch.
Comment #20
ron_s CreditAttribution: ron_s commentedFeel free to review what exists in #16. I haven't tried it out, but might be able to still apply the patch manually to test it.
Comment #21
ron_s CreditAttribution: ron_s commentedUpdated patch. The only difference is the
try
function was removed fromgeocoder_google
in 7.x-1.x-dev. Otherwise the patch is the same.Comment #22
basvredelingI've taken a quick look at the patch, generally it looks good. I've tested some basic google geocoding results. Geocoding works pretty well, but there's not a great difference between my previous geocoded results and my previous results. Couldn't test mapquest stuff. Component splitting is only specific to this service. And there is some further work to do in general.
So, probably not the review you were hoping for but at least this is moving again. I'll see if I can add a patch myself.
Comment #23
ron_s CreditAttribution: ron_s commented$components
parameter can be removed. If you read comment #12 above, it should have been removed then.As for refactoring or adding more widgets, you can change whatever you like.
Comment #24
basvredelingOkay, I've got a new patch. Please review. For clarification:
Comment #25
wranvaud CreditAttribution: wranvaud at Phase2 commentedMarking as related to #2859851 although I'm not sure it would solve this particular issue.
I like the approach of https://www.drupal.org/project/geocoder/issues/2859851 because it leverages the addressfield module to produce correctly formatted addresses.
Comment #26
PolHello,
What is the status of this patch ?
Thanks!
Comment #27
ron_s CreditAttribution: ron_s commentedThe status? It needs review, and now because of the new release, it needs work. There needs to be someone other than me and anyone else contributing to the patch to actually try it and see if it works as expected.
Once again, another geocoder patch that sits idle for years, and ultimately a new release is made that doesn't include it. Extremely frustrating.
The patches in both #21 and #24 no longer apply cleanly to the most recent release, so someone is going to need to roll a new version for review.
Comment #28
spacemuon CreditAttribution: spacemuon as a volunteer commentedPlease delete comment