當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Point::getLatitude方法代碼示例

本文整理匯總了PHP中Point::getLatitude方法的典型用法代碼示例。如果您正苦於以下問題:PHP Point::getLatitude方法的具體用法?PHP Point::getLatitude怎麽用?PHP Point::getLatitude使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Point的用法示例。


在下文中一共展示了Point::getLatitude方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createFromCenterAndDistance

 /**
  * @param Point    $center
  * @param Distance $distance
  *
  * @return BoundingBox
  * @author Maximilian Ruta <mr@xtain.net>
  */
 public static function createFromCenterAndDistance(Point $center, Distance $distance)
 {
     $distanceInDegrees = $distance->getInGeographicDegrees() / 2;
     $sw = new Point($center->getLatitude() - $distanceInDegrees, $center->getLongitude() - $distanceInDegrees);
     $ne = new Point($center->getLatitude() + $distanceInDegrees, $center->getLongitude() + $distanceInDegrees);
     return new BoundingBox($sw, $ne);
 }
開發者ID:XTAIN,項目名稱:geo,代碼行數:14,代碼來源:BoundingBox.php

示例2: distance

 /**
  * @param Point $place1
  * @param Point $place2
  *
  * @return Distance
  * @author Maximilian Ruta <mr@xtain.net>
  */
 public static function distance(Point $place1, Point $place2)
 {
     $theta = $place1->getLongitude() - $place2->getLongitude();
     $dist = sin(deg2rad($place1->getLatitude())) * sin(deg2rad($place2->getLatitude())) + cos(deg2rad($place1->getLatitude())) * cos(deg2rad($place2->getLatitude())) * cos(deg2rad($theta));
     $dist = acos($dist);
     $dist = rad2deg($dist);
     return new Distance($dist);
 }
開發者ID:XTAIN,項目名稱:geo,代碼行數:15,代碼來源:Calculator.php

示例3: getCartographicDistance

 /**
  * @param Point $point
  * @return float
  *
  * thanks to http://stackoverflow.com/questions/7672759/how-to-calculate-distance-from-lat-long-in-php
  */
 public function getCartographicDistance(Point $point)
 {
     $earthRadius = 3958.75;
     $dLat = deg2rad($point->getLatitude() - $this->latitude);
     $dLng = deg2rad($point->getLongitude() - $this->longitude);
     $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($this->latitude)) * cos(deg2rad($point->getLatitude())) * sin($dLng / 2) * sin($dLng / 2);
     $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
     $dist = $earthRadius * $c;
     // from miles to km
     $meterConversion = 1.609344;
     $geopointDistance = $dist * $meterConversion;
     return round($geopointDistance, 0);
 }
開發者ID:CatalinaO,項目名稱:trip-planner,代碼行數:19,代碼來源:Point.php

示例4: distanceTo

 /**
  * Calculate distance to another point
  *
  * @param Point $point
  * @param string $unit
  * @return float
  */
 public function distanceTo(Point $point, $unit = Gps::KILOMETER)
 {
     $latitudeFrom = deg2rad($this->latitude);
     $longitudeFrom = deg2rad($this->longitude);
     $latitudeTo = deg2rad(floatval($point->getLatitude()));
     $longitudeTo = deg2rad(floatval($this->getLongitude()));
     $longitudeDelta = $longitudeTo - $longitudeFrom;
     $longitudeDelta = $longitudeTo - $longitudeFrom;
     $magnitudeA = pow(cos($latitudeTo) * sin($longitudeDelta), 2) + pow(cos($latitudeFrom) * sin($latitudeTo) - sin($latitudeFrom) * cos($latitudeTo) * cos($longitudeDelta), 2);
     $magnitudeB = sin($latitudeFrom) * sin($latitudeTo) + cos($latitudeFrom) * cos($latitudeTo) * cos($longitudeDelta);
     $distance = atan2(sqrt($magnitudeA), $magnitudeB) * Gps::EARTH_RADIUS;
     switch ($unit) {
         case Gps::KILOMETER:
             return round($distance, 2);
             break;
         case Gps::METER:
             return round($distance * 1000, 2);
             break;
         default:
             throw new \InvalidArgumentException(sprintf('Unit "%s" is not valid', $unit));
             break;
     }
 }
開發者ID:juliangut,項目名稱:gps,代碼行數:30,代碼來源:Point.php

示例5: getAzimuthToPoint

 public function getAzimuthToPoint(Point $point2)
 {
     // перевести координаты в радианы
     $lat1 = $this->getLatitude() * M_PI / 180;
     $lat2 = $point2->getLatitude() * M_PI / 180;
     $long1 = $this->getLongitude() * M_PI / 180;
     $long2 = $point2->getLongitude() * M_PI / 180;
     // косинусы и синусы широт и разницы долгот
     $cl1 = cos($lat1);
     $cl2 = cos($lat2);
     $sl1 = sin($lat1);
     $sl2 = sin($lat2);
     $delta = $long2 - $long1;
     $cdelta = cos($delta);
     $sdelta = sin($delta);
     //вычисление начального азимута
     $x = (double) ($cl1 * $sl2) - $sl1 * $cl2 * $cdelta;
     $y = (double) $sdelta * $cl2;
     $z = atan2($y, $x) * 180 / M_PI;
     if ($z < 0) {
         $z += 360;
     }
     return $z;
 }
開發者ID:arsenyru,項目名稱:geodata,代碼行數:24,代碼來源:Point.php

示例6: distanceTo

 public function distanceTo(Point $point) : float
 {
     return Tools::distance($this->getLatitude(), $this->getLongitude(), $point->getLatitude(), $point->getLongitude());
 }
開發者ID:jlaso,項目名稱:gps,代碼行數:4,代碼來源:Point.php


注:本文中的Point::getLatitude方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。