当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::fromLatLon方法代码示例

本文整理汇总了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;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:12,代码来源:geocode.php

示例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;
 }
开发者ID:himmelex,项目名称:NTW,代码行数:13,代码来源:geocode.php

示例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;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:15,代码来源:Notice_location.php

示例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;
 }
开发者ID:a780201,项目名称:gnu-social,代码行数:35,代码来源:Notice.php

示例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());
//.........这里部分代码省略.........
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:101,代码来源:activityobject.php

示例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;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:17,代码来源:activitycontext.php

示例7: testLocationFromLatLon

 /**
  * @dataProvider locationLatLons
  */
 public function testLocationFromLatLon($lat, $lon, $language, $location)
 {
     $result = Location::fromLatLon($lat, $lon, $language);
     $this->assertEquals($result, $location);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:8,代码来源:LocationTest.php

示例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;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:20,代码来源:Profile.php


注:本文中的Location::fromLatLon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。