I described the issue at http://drupal.org/node/348524#comment-1246187; bdragon fixed it during a chat today in IRC. He asked me to post the issue here to remind him to commit the changes.

But to summarize the issue for the record: Location data that's imported via SQL failed to geocode, and there was no way to force it to refresh. He fixed it by adding the following to location.module after line 1087, i.e. just before $location['province_name'] = '';

       if (isset($location['source']) && $location['source'] == 4) {
          _location_geo_logic($location, array('street' => 1), array());
          db_query("UPDATE {location} SET latitude = '%f', longitude = '%f', source = %d WHERE lid = %d",
          $location['latitude'],
          $location['longitude'],
          $location['source'],
          $location['lid']);
        }

bdragon, do it to it! And a thousand thanks for working through it today.

Comments

tgeller’s picture

More useful info about how this actually works:

  • When you want to force the geocoding, set the "source" field in the "location" table to 4 for each record. So for example:
INSERT INTO location
  (street,city,province,postal_code,country, source, is_primary)
VALUES
  ('829 14th Street','San Francisco','CA','94114','US',4,0);
  • The geocoding will then be recalculated when the location is "loaded" -- for example, when you visit that the node or user that contains this location.
  • Here's one way to force geocoding on a *batch* of locations, per bdragon. Using the devel module, enter the following in the "Execute PHP" block. (Warning: Executing PHP on your site is dangerous! Backup your site.)
    $result = db_query('SELECT lid from {location} where source = 4');
    while ($row = db_fetch_object($result)) { 
      location_load_location($row->lid); 
      sleep(2); 
    }

    I haven't actually tested this myself yet.

Enjoy!

tgeller’s picture

One last note for the record: http://www.batchgeocode.com is useful if you want to avoid this mess and just import the geocoded data directly. :)

tgeller’s picture

I've tested that PHP code, and it works. Hoorah!

bdragon’s picture

Version: 6.x-3.0 » 6.x-3.x-dev
Assigned: Unassigned » bdragon
Status: Active » Fixed

OK, committed a modified version (less hardcoding of "4" and a knob to turn it on and off.)

http://drupal.org/cvs?commit=175274
http://drupal.org/cvs?commit=175276
http://drupal.org/cvs?commit=175278

Status: Fixed » Closed (fixed)

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

BenK’s picture

Just need to keep track of this thread....

bryancasler’s picture

subscribing

bewhy’s picture

Status: Closed (fixed) » Needs work

I've attempted the fixes here and they haven't worked.
{whining deleted}

it hadn't worked because i didn't turn on the geocoding options on in the location module DURING IMPORT

legolasbo’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Closing old D6 issues as D6 is end of life