Coded a Migrate field handler for the 1.2 release of Geofield before realizing there was support for geofield 1.x in migrate_extras.

Patch in comment #1 in case anyone needs it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

setvik’s picture

eneko1907’s picture

Issue summary: View changes

Problem is the geofield handler proposed here and the existing in migrate_extras for geofield version 1.2 may fail with recent migrate module versions, as the arguments array use is deprecated. In fact, we do not need this handler anymore, we can work with geo subfields directly. Problem may be, the geofield handler included in extra will get in your way, may send you in a wild goose chase. disable it (in the admin migration configuration screen admin/content/admin/configure or programmatically )

Im other words, you should not do

$arguments = array(
  'lat' => array('source_field' => 'latitude'),
  'lon' => array('source_field' => 'longitude'),
);
$this->addFieldMapping('field_coordinate', 'point')->arguments($arguments);

or variations of the example snippet above. those may fail with the conditions above (geo1.2, migrate 2.4+, migrate_extras)

What works?
Say my sources are in 'lat' and 'long'
in your geo-migration class construct:

[...]
     $this->addFieldMapping('field_coordinates','geo')
      ->description('in PrepareRow');
    $this->addFieldMapping('field_coordinates:geo_type')->defaultValue('point');
    $this->addFieldMapping('field_coordinates:lat','lat');
    $this->addFieldMapping('field_coordinates:lon','long');
    $this->addFieldMapping('field_coordinates:left','long');  //        left
    $this->addFieldMapping('field_coordinates:top','lat');        //  top
    $this->addFieldMapping('field_coordinates:right','long');   //      right
    $this->addFieldMapping('field_coordinates:bottom','lat');  //       bottom
[...]

and in the function prepareRow of your geo migration class

[...]
$row->geo = 'POINT (' . $row->long . ' ' . $row->lat . ')';
[...]

One more thing - the migration_extras geofield handler will be on your way, as explained.
in case you did install migration_extras (chances are you did), remember you need to disable
the field handler for geo.

eneko1907’s picture

Status: Needs review » Needs work

Also, I'd suggest the migrate_extras geofield handler is either removed or updated, so we avoid this confusion. in any event, i'm changing the needs review to needs work.

FMB’s picture

FMB’s picture

Status: Needs work » Closed (duplicate)