I would like to use Feeds to import wkt data from CSV files. I have used the existing Feeds plugin to import point location by splitting the data into lat and long but I want import LINESTRING and MULTILINESTRING. For testing I am replacing the existing Feeds plugin but my aim is to make a plugin that works for lat/long and wkt.
For testing I have simplified the existing code to just pass the wkt string but this doesn't work so I obviously haven't got the format correct. Can someone help with the right format to pass wkt? The code I am using is below
<?php
namespace Drupal\geofield\Feeds\Target;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\feeds\Exception\EmptyFeedException;
use Drupal\feeds\FieldTargetDefinition;
use Drupal\feeds\Plugin\Type\Target\FieldTargetBase;
/**
* Defines a geofield field mapper.
*
* @FeedsTarget(
* id = "geofield_feeds_target",
* field_types = {"geofield"}
* )
*/
class Geofield extends FieldTargetBase {
/**
* {@inheritdoc}
*/
protected static function prepareTarget(FieldDefinitionInterface $field_definition) {
return FieldTargetDefinition::createFromFieldDefinition($field_definition)
->addProperty('wkt');
}
/**
* {@inheritdoc}
*/
protected function prepareValue($delta, array &$values) {
if (isset($values['wkt']) && empty($values['wkt'])) {
// If wkt is empty set it to null
$values['wkt'] = NULL;
}
dpm($values['wkt']);
}
}
All help appreciated
Closed: duplicate
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.