本文整理汇总了PHP中Location::fromLatLon方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::fromLatLon方法的具体用法?PHP Location::fromLatLon怎么用?PHP Location::fromLatLon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location::fromLatLon方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
function prepare($args)
{
parent::prepare($args);
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. ' . 'Try again, please.'));
}
$this->lat = $this->trimmed('lat');
$this->lon = $this->trimmed('lon');
$this->location = Location::fromLatLon($this->lat, $this->lon);
return true;
}
示例2: prepare
function prepare($args)
{
parent::prepare($args);
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('网页错误,请返回重试
'));
}
$this->lat = $this->trimmed('lat');
$this->lon = $this->trimmed('lon');
$this->location = Location::fromLatLon($this->lat, $this->lon);
return true;
}
示例3: asLocation
public function asLocation()
{
$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
$location = Location::fromLatLon($this->lat, $this->lon);
}
if (is_null($location)) {
throw new ServerException('Location could not be looked up from existing data.');
}
return $location;
}
示例4: locationOptions
static function locationOptions($lat, $lon, $location_id, $location_ns, $profile = null)
{
$options = array();
if (!empty($location_id) && !empty($location_ns)) {
$options['location_id'] = $location_id;
$options['location_ns'] = $location_ns;
$location = Location::fromId($location_id, $location_ns);
if ($location instanceof Location) {
$options['lat'] = $location->lat;
$options['lon'] = $location->lon;
}
} else {
if (!empty($lat) && !empty($lon)) {
$options['lat'] = $lat;
$options['lon'] = $lon;
$location = Location::fromLatLon($lat, $lon);
if ($location instanceof Location) {
$options['location_id'] = $location->location_id;
$options['location_ns'] = $location->location_ns;
}
} else {
if (!empty($profile)) {
if (isset($profile->lat) && isset($profile->lon)) {
$options['lat'] = $profile->lat;
$options['lon'] = $profile->lon;
}
if (isset($profile->location_id) && isset($profile->location_ns)) {
$options['location_id'] = $profile->location_id;
$options['location_ns'] = $profile->location_ns;
}
}
}
}
return $options;
}
示例5: asArray
function asArray()
{
$object = array();
if (Event::handle('StartActivityObjectOutputJson', array($this, &$object))) {
// XXX: attachments are added by Activity
// author (Add object for author? Could be useful for repeats.)
// content (Add rendered version of the notice?)
// downstreamDuplicates
// id
if ($this->id) {
$object['id'] = $this->id;
} else {
if ($this->link) {
$object['id'] = $this->link;
}
}
if ($this->type == ActivityObject::PERSON || $this->type == ActivityObject::GROUP) {
// displayName
$object['displayName'] = $this->title;
// XXX: Not sure what the best avatar is to use for the
// author's "image". For now, I'm using the large size.
$imgLink = null;
$avatarMediaLinks = array();
foreach ($this->avatarLinks as $a) {
// Make a MediaLink for every other Avatar
$avatar = new ActivityStreamsMediaLink($a->url, $a->width, $a->height, $a->type, 'avatar');
// Find the big avatar to use as the "image"
if ($a->height == AVATAR_PROFILE_SIZE) {
$imgLink = $avatar;
}
$avatarMediaLinks[] = $avatar->asArray();
}
if (!array_key_exists('status_net', $object)) {
$object['status_net'] = array();
}
$object['status_net']['avatarLinks'] = $avatarMediaLinks;
// extension
// image
if (!empty($imgLink)) {
$object['image'] = $imgLink->asArray();
}
}
// objectType
//
// We can probably use the whole schema URL here but probably the
// relative simple name is easier to parse
$object['objectType'] = self::canonicalType($this->type);
// summary
$object['summary'] = $this->summary;
// content, usually rendered HTML
$object['content'] = $this->content;
// published (probably don't need. Might be useful for repeats.)
// updated (probably don't need this)
// TODO: upstreamDuplicates
if ($this->link) {
$object['url'] = $this->link;
}
/* Extensions */
// @fixme these may collide with XML extensions
// @fixme multiple tags of same name will overwrite each other
// @fixme text content from XML extensions will be lost
foreach ($this->extra as $e) {
list($objectName, $props, $txt) = array_pad($e, 3, null);
if (!empty($objectName)) {
$parts = explode(":", $objectName);
if (count($parts) == 2 && $parts[0] == "statusnet") {
if (!array_key_exists('status_net', $object)) {
$object['status_net'] = array();
}
$object['status_net'][$parts[1]] = $props;
} else {
$object[$objectName] = $props;
}
}
}
if (!empty($this->geopoint)) {
list($lat, $lon) = explode(' ', $this->geopoint);
if (!empty($lat) && !empty($lon)) {
$object['location'] = array('objectType' => 'place', 'position' => sprintf("%+02.5F%+03.5F/", $lat, $lon), 'lat' => $lat, 'lon' => $lon);
$loc = Location::fromLatLon((double) $lat, (double) $lon);
if ($loc) {
$name = $loc->getName();
if ($name) {
$object['location']['displayName'] = $name;
}
$url = $loc->getURL();
if ($url) {
$object['location']['url'] = $url;
}
}
}
}
if (!empty($this->poco)) {
$object['portablecontacts_net'] = array_filter($this->poco->asArray());
}
if (!empty($this->thumbnail)) {
if (is_string($this->thumbnail)) {
$object['image'] = array('url' => $this->thumbnail);
} else {
$object['image'] = array('url' => $this->thumbnail->getUrl());
//.........这里部分代码省略.........
示例6: locationFromPoint
static function locationFromPoint($point)
{
$point = str_replace(',', ' ', $point);
// per spec "treat commas as whitespace"
$point = preg_replace('/\\s+/', ' ', $point);
$point = trim($point);
$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 point");
return Location::fromLatLon($lat, $lon);
}
}
common_log(LOG_ERR, "Ignoring bogus georss:point value {$point}");
return null;
}
示例7: testLocationFromLatLon
/**
* @dataProvider locationLatLons
*/
public function testLocationFromLatLon($lat, $lon, $language, $location)
{
$result = Location::fromLatLon($lat, $lon, $language);
$this->assertEquals($result, $location);
}
示例8: getLocation
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);
}
}
if (is_null($location)) {
// still haven't found it!
if (!empty($this->location)) {
$location = Location::fromName($this->location);
}
}
return $location;
}