/** * get map tile from its numbers * * @param int $x x number of the tile * @param int $y y number of the tile * @param int $zoom map zoom * @return Tile */ public function getTile($x, $y, $zoom) { $tx = $x; $ty = $y; $this->_validateTileNumbers($tx, $ty, $zoom); if (!$this->_useTileImage) { $tile = new EmptyTile($this->getTileWidth(), $this->getTileHeight(), $this->_imageHandler); } else { if ($this->_useCache && $this->_tileCache->hasTile($tx, $ty, $zoom)) { //if tile image is in cache, take it from there $image = $this->_tileCache->getTile($tx, $ty, $zoom); $tile = new Tile($image); } else { $image = $this->_loadImage($this->_createUrl($tx, $ty, $zoom)); if ($image === false) { //when loading an image failed $tile = new EmptyTile($this->getTileWidth(), $this->getTileHeight(), $this->_imageHandler); } else { $this->_tileCache->addTile($image, $tx, $ty, $zoom); $tile = new Tile($image); } } } $tile->setWorldMap($this->getWorldMap($zoom)); $tile->setTileData($x, $y, $zoom); $tile->setImageHandler($this->_imageHandler); return $tile; }