protected function Geolocation::prepareValue in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Feeds/Target/Geolocation.php \Drupal\geolocation\Feeds\Target\Geolocation::prepareValue()
Prepares a single value.
Parameters
int $delta: The field delta.
array $values: The values.
Overrides FieldTargetBase::prepareValue
1 call to Geolocation::prepareValue()
- Geolocation::prepareValues in src/
Feeds/ Target/ Geolocation.php - Prepares the the values that will be mapped to an entity.
File
- src/
Feeds/ Target/ Geolocation.php, line 33
Class
- Geolocation
- Defines a geolocation field mapper.
Namespace
Drupal\geolocation\Feeds\TargetCode
protected function prepareValue($delta, array &$values) {
if (isset($values)) {
if (isset($values['lat']) && isset($values['lng'])) {
$values['lat'] = floatval($values['lat']);
$values['lng'] = floatval($values['lng']);
$values['lat_sin'] = sin(deg2rad($values['lat']));
$values['lat_cos'] = cos(deg2rad($values['lat']));
$values['lng_rad'] = deg2rad($values['lng']);
}
return $values;
}
else {
throw new EmptyFeedException();
}
}