]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add geopoint (GeoJSON) extension to AS JSON output
authorZach Copley <zach@status.net>
Fri, 18 Feb 2011 04:12:28 +0000 (20:12 -0800)
committerZach Copley <zach@status.net>
Fri, 18 Feb 2011 04:12:28 +0000 (20:12 -0800)
lib/activity.php
lib/activityobject.php

index a8e6d25af955281c33244ab3be419a38fd73a96b..e2699ebadcfee1fb8d4a37be90d974ba85a5ec7a 100644 (file)
@@ -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);
     }
 
index 0f151ec2984aef18930cb69dd07c0f1787371da4..ae2f4649e50cd9c908d9d3040a8607eb884247b9 100644 (file)
@@ -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);
     }
 }