当前位置: 首页>>代码示例>>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;未经允许,请勿转载。