/** * load all tiles * * @param array $leftUpCorner * @param array $rightDownCorner * @return array */ protected function _getTiles($leftUpCorner, $rightDownCorner) { $tiles = array(); $leftUpTilesNumber = $this->_tileSource->getTileNumbersFromCoordinates($leftUpCorner['lon'], $leftUpCorner['lat'], $this->_worldMap->getZoom()); $rightDownTilesNumber = $this->_tileSource->getTileNumbersFromCoordinates($rightDownCorner['lon'], $rightDownCorner['lat'], $this->_worldMap->getZoom()); $tilesGetter = new TilesGetter($leftUpTilesNumber, $rightDownTilesNumber, $this->_tileSource, $this->_worldMap); $tilesGetter->startLoading(); while (!$tilesGetter->isLoaded()) { //wating for finishing loading } return $tilesGetter->getTiles(); }
/** * get coordinates of the point in pixels, left up corner of map has coordiantes: 0 px 0 px * * @param float $lon * @param float $lat * @return array */ public function getPixelPointFromCoordinates($lon, $lat) { $leftUp = $this->getLeftUpCorner(); $leftUpPointInPixel = $this->_worldMap->getPixelXY($leftUp['lon'], $leftUp['lat']); $pointInPixel = $this->_worldMap->getPixelXY($lon, $lat); return array('x' => $pointInPixel['x'] - $leftUpPointInPixel['x'], 'y' => $pointInPixel['y'] - $leftUpPointInPixel['y']); }
private function _createTileGettersTable() { $numberOfTilesToLoad = 0; for ($y = $this->_leftUpTileNumbers['y']; $y <= $this->_rightDownTileNumbers['y']; $y++) { $row = array(); $x = $this->_leftUpTileNumbers['x']; while (true) { $tileGetter = new StandardTileGetter($this->_tileSource, $x, $y, $this->_worldMap->getZoom()); $row[] = $tileGetter; $numberOfTilesToLoad++; if ($x == $this->_rightDownTileNumbers['x']) { break; } $x++; } $this->_tileGetters[] = $row; } if ($numberOfTilesToLoad > self::$limitOfTiles) { throw new WrongMapRequestDataException('Too many tiles to load'); } }
/** * create world for given latitude distance between two given latitudes and given height of the map * * @param float $lat * @param float $lat2 * @param int $height * @return WorldMap */ public function createProperWordlFromHeight($lat, $lat2, $height) { $maxZoom = $this->_tileSource->getMaxZoom(); for ($i = $this->_tileSource->getMinZoom(); $i <= $maxZoom; $i++) { $world = new WorldMap($i, $this->_tileSource); $distance = $world->getPixelDistance(0, $lat, 0, $lat2); if ($width > $distance['y']) { return $world; } } return $world; }
protected function _run() { $this->_tile = $this->_tileSource->getTile($this->_tileNumbers['x'], $this->_tileNumbers['y'], $this->_worldMap->getZoom()); $this->_isLoaded = true; }