Problem/Motivation

Since the fix of the parent bug report, Geocoder uses the 'code' field for administrative_area. This field can be empty, as seen in the screenshot (coordinates in Europe, Nominatim provider), even though the 'name' field might contain data.

code

Steps to reproduce

Use Nominatim provider. Set a breakpoint at line 79 of DumperPluginManager.php, and see that the 'code' field is empty.

Proposed resolution

Change the code: use the 'code' field if it's not empty, otherwise use the 'name' field if it's not empty.

    if (!empty($geojson_array['properties']['adminLevels'])) {
      $administrative_area_array = array_shift($geojson_array['properties']['adminLevels']);
      if(!empty($administrative_area_array['code'])) {
        $administrative_area = $administrative_area_array['code'];
      } elseif(!empty($administrative_area_array['name'])) {
        $administrative_area = $administrative_area_array['name'];
      }
CommentFileSizeAuthor
geocoder_dumperpluginmanager.png158.9 KBovquiaf

Comments

ovquiaf created an issue. See original summary.

  • itamair committed a8f60177 on 8.x-4.x
    Issue #3510705: Use administrative_area '''name'' when "code" is empty.
    
itamair’s picture

Status: Active » Fixed

thanks @ovquiaf ... Qa and Tested what you say and it makes sense to me.
Committed into dev (with some better ternary operator implementation) is going to be part of the news (incoming) Geocoder release.

ovquiaf’s picture

Thanks for implementing it, I wasn't sure how to contribute a patch, or how verbose the code should be. Looking forward to the release!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.