Cast lat/lon to float; check for non-empty

This commit is contained in:
Evan Prodromou 2013-06-08 21:16:58 -04:00
parent bb0cf686df
commit 14fbd68a12

View File

@ -906,25 +906,27 @@ class ActivityObject
list($lat, $lon) = explode(' ', $this->geopoint); list($lat, $lon) = explode(' ', $this->geopoint);
$object['location'] = array( if (!empty($lat) && !empty($lon)) {
'objectType' => 'place', $object['location'] = array(
'position' => sprintf("%+02.5F%+03.5F/", $lat, $lon), 'objectType' => 'place',
'lat' => $lat, 'position' => sprintf("%+02.5F%+03.5F/", $lat, $lon),
'lon' => $lon 'lat' => $lat,
); 'lon' => $lon
);
$loc = Location::fromLatLon($lat, $lon); $loc = Location::fromLatLon((float)$lat, (float)$lon);
if ($loc) { if ($loc) {
$name = $loc->getName(); $name = $loc->getName();
if ($name) { if ($name) {
$object['location']['displayName'] = $name; $object['location']['displayName'] = $name;
} }
$url = $loc->getURL(); $url = $loc->getURL();
if ($url) { if ($url) {
$object['location']['url'] = $url; $object['location']['url'] = $url;
}
} }
} }
} }