From e9644f03de3e30d46764ca0046ed29730cbe414e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 29 Oct 2009 14:43:18 -0400 Subject: [PATCH] get location from a Notice --- classes/Notice.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index fdf5cd4c87..c08a66790f 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1412,4 +1412,21 @@ class Notice extends Memcached_DataObject $contentlimit = self::maxContent(); return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit)); } + + function getLocation() + { + $location = null; + + if (!empty($this->location_id) && !empty($this->location_ns)) { + $location = Location::fromId($this->location_id, $this->location_ns); + } + + if (is_null($location)) { // no ID, or Location::fromId() failed + if (!empty($this->lat) && !empty($this->lon)) { + $location = Location::fromLatLon($this->lat, $this->lon); + } + } + + return $location; + } }