diff options
author | Brion Vibber <brion@pobox.com> | 2010-02-08 15:46:38 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-02-08 15:46:38 -0800 |
commit | b9b0f0410aa688cc3ee77df1563773527a8d59a9 (patch) | |
tree | 1851e5c87022a672b5732f7348b34d0279e47fb6 | |
parent | 384387c9b05aefb438f5dbe7e272b1f234ede172 (diff) |
Pull GeoRSS locations over OStatus feeds
-rw-r--r-- | plugins/OStatus/lib/feedmunger.php | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/plugins/OStatus/lib/feedmunger.php b/plugins/OStatus/lib/feedmunger.php index 948017702..cbaec6775 100644 --- a/plugins/OStatus/lib/feedmunger.php +++ b/plugins/OStatus/lib/feedmunger.php @@ -225,11 +225,46 @@ class FeedMunger $notice->created = common_sql_date($entry->updated); // @fixme $notice->is_local = Notice::GATEWAY; $notice->source = 'feed'; - + + $location = $this->getLocation($entry); + if ($location) { + if ($location->location_id) { + $notice->location_ns = $location->location_ns; + $notice->location_id = $location->location_id; + } + $notice->lat = $location->lat; + $notice->lon = $location->lon; + } + return $notice; } /** + * @param feed item $entry + * @return mixed Location or false + */ + function getLocation($entry) + { + $dom = $entry->model; + $points = $dom->getElementsByTagNameNS('http://www.georss.org/georss', 'point'); + + for ($i = 0; $i < $points->length; $i++) { + $point = trim($points->item(0)->textContent); + $coords = explode(' ', $point); + if (count($coords) == 2) { + list($lat, $lon) = $coords; + if (is_numeric($lat) && is_numeric($lon)) { + common_log(LOG_INFO, "Looking up location for $lat $lon from georss"); + return Location::fromLatLon($lat, $lon); + } + } + common_log(LOG_ERR, "Ignoring bogus georss:point value $point"); + } + + return false; + } + + /** * @param XML_Feed_Type $entry * @return string notice text, within post size limit */ |