Entry.php in Feeds 8.3
File
src/Zend/Extension/Georss/Entry.php
View source
<?php
namespace Drupal\feeds\Zend\Extension\Georss;
use Zend\Feed\Reader\Extension\AbstractEntry;
class Entry extends AbstractEntry {
public function getGeoPoint($index = 0) {
$points = $this
->getGeoPoints();
return isset($points[$index]) ? $points[$index] : NULL;
}
public function getGeoPoints() {
if (!isset($this->data['georss'])) {
$this
->populateData();
}
return $this->data['georss'];
}
protected function populateData() {
$this->data['georss'] = [];
$list = $this->xpath
->evaluate($this
->getXpathPrefix() . '//georss:point');
foreach ($list as $point) {
$parts = explode(' ', preg_replace('/\\s+/', ' ', trim($point->nodeValue)));
if (count($parts) === 2) {
$this->data['georss'][] = [
'lat' => is_numeric($parts[0]) ? (double) $parts[0] : NULL,
'lon' => is_numeric($parts[1]) ? (double) $parts[1] : NULL,
];
}
}
}
protected function registerNamespaces() {
$this
->getXpath()
->registerNamespace('georss', 'http://www.georss.org/georss');
}
}