From 97af5e195421591265094685d9fa86af8d464794 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 17 Feb 2011 20:12:28 -0800 Subject: [PATCH] Add geopoint (GeoJSON) extension to AS JSON output --- lib/activity.php | 18 ++++++++++++++++++ lib/activityobject.php | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/activity.php b/lib/activity.php index a8e6d25af9..e2699ebadc 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -447,6 +447,24 @@ class Activity $activity[$objectName] = $props; } } + + /* more extensions */ + + if (!empty($this->context)) { + + if (!empty($this->context->location)) { + $loc = $this->context->location; + + // GeoJSON + + $activity['geopoint'] = array( + 'type' => 'Point', + 'coordinates' => array($loc->lat, $loc->lon) + ); + } + + } + return array_filter($activity); } diff --git a/lib/activityobject.php b/lib/activityobject.php index 0f151ec298..ae2f4649e5 100644 --- a/lib/activityobject.php +++ b/lib/activityobject.php @@ -714,6 +714,18 @@ class ActivityObject $object[$objectName] = $props; } + // GeoJSON + + if (!empty($this->geopoint)) { + + list($lat, $long) = explode(' ', $this->geopoint); + + $object['geopoint'] = array( + 'type' => 'Point', + 'coordinates' => array($lat, $long) + ); + } + return array_filter($object); } } -- 2.39.5