public function testB() { $lat = 55.613855; $lng = 37.978578; $loc = \S2\S2LatLng::fromDegrees(55.6141284375, 37.9788514375); $s2ll = \S2\S2CellId::fromToken(self::guidToToken('700c7c5346a246ee88eee70b200d0b33.16'))->toLatLng(); $this->assertEquals('(-0.023004811178492, -3.06557268979)', (string) $s2ll); $s2ll = \S2\S2CellId::fromToken(self::guidToToken('414ab9b68fd0000000082a7300000025.6'))->toLatLng(); $this->assertEquals('(0.97053474915648, 0.66268771618818)', (string) $s2ll); $loc_1 = \S2\S2LatLng::fromDegrees(55.605873, 37.970864); $loc_ezhio = \S2\S2LatLng::fromE6(55608152, 37972176); $loc_oktz = \S2\S2LatLng::fromE6(55607195, 37971367); $loc_art = \S2\S2LatLng::fromE6(55605726, 37970664); $dist = self::GreatEarthDistance($loc_1, $s2ll); $this->assertEquals(212.99711509717, $dist); }
/** * @param GetMapObjectsMessage $msg * @param int $width */ protected function addCellIds(GetMapObjectsMessage $msg, $width = 6) { $latLng = S2LatLng::fromDegrees($this->session->getLocation()->getLatitude(), $this->session->getLocation()->getLongitude()); $cellId = S2CellId::fromLatLng($latLng)->parent(15); $size = 2 ** (S2CellId::MAX_LEVEL - $cellId->level()); $iIndex = 0; $jIndex = 0; $face = $cellId->toFaceIJOrientation($iIndex, $jIndex); $halfWidth = (int) floor($width / 2); for ($x = -$halfWidth; $x <= $halfWidth; $x++) { for ($y = -$halfWidth; $y <= $halfWidth; $y++) { $msg->addCellId(S2CellId::fromFaceIJ($face, $iIndex + $x * $size, $jIndex + $y * $size)->parent(15)->id()); } } }