コード例 #1
0
 /**
  * Check if is in range
  *
  * @return bool
  */
 public function inRange()
 {
     $pokestop = S2LatLng::fromDegrees($this->getLatitude(), $this->getLongitude());
     $player = S2LatLng::fromDegrees($this->pokemonGoAPI->getLatitude(), $this->pokemonGoAPI->getLongitude());
     $distance = $pokestop->getEarthDistance($player);
     return $distance < 30;
 }
コード例 #2
0
ファイル: Map.php プロジェクト: tuttarealstep/pokegoapi-php
 /**
  * @param $latitude
  * @param $longitude
  * @param $width
  * @return array
  */
 public function getCellIds($latitude, $longitude, $width)
 {
     $latLng = S2LatLng::fromDegrees($latitude, $longitude);
     $cellId = S2CellId::fromLatLng($latLng)->parent(15);
     $index = 0;
     $jindex = 0;
     $level = $cellId->level();
     $size = 1 << S2CellId::MAX_LEVEL - $level;
     $face = $cellId->toFaceIJOrientation($index, $jindex);
     $cells = [];
     $halfWidth = floor($width / 2);
     for ($x = -$halfWidth; $x <= $halfWidth; $x++) {
         for ($y = -$halfWidth; $y <= $halfWidth; $y++) {
             $cells[] = S2CellId::fromFaceIJ($face, $index + $x * $size, $jindex + $y * $size)->parent(15)->id();
         }
     }
     return $cells;
 }