/**
  * it sets coordinates of the left up and right down corners of the result map
  * 
  * @param Map $resultMap
  */
 protected function _setUpResultMapCorners(Map $resultMap)
 {
     $leftUpCorner = $this->_mapData->getLeftUpCornerPoint();
     $resultMap->setLeftUpCorner($leftUpCorner['lon'], $leftUpCorner['lat']);
     $rightDownCorner = $this->_mapData->getRightDownCornerPoint();
     $resultMap->setRightDownCorner($rightDownCorner['lon'], $rightDownCorner['lat']);
 }
 /**
  * it sets coordinates of the left up and right down corners of the result map
  * 
  * @param Map $resultMap
  */
 protected function _setUpResultMapCorners(Map $resultMap)
 {
     $centerPoint = $this->_mapData->getCenterPoint();
     $centerPointInPixels = $this->_worldMap->getPixelXY($centerPoint['lon'], $centerPoint['lat']);
     $leftUpPointInPixels = array('x' => $centerPointInPixels['x'] - round($this->_mapData->getWidth() / 2), 'y' => $centerPointInPixels['y'] - round($this->_mapData->getHeight() / 2));
     $resultMap->setLeftUpCorner($this->_worldMap->getLon($leftUpPointInPixels['x']), $this->_worldMap->getLat($leftUpPointInPixels['y']));
     $rightDownPointInPixels = array('x' => $centerPointInPixels['x'] + round($this->_mapData->getWidth() / 2), 'y' => $centerPointInPixels['y'] + round($this->_mapData->getHeight() / 2));
     $resultMap->setRightDownCorner($this->_worldMap->getLon($rightDownPointInPixels['x']), $this->_worldMap->getLat($rightDownPointInPixels['y']));
 }
 /**
  * concatenate tiles to one map
  *
  * @param array $tiles
  * @return Map
  */
 protected function _concatenateTiles($tiles)
 {
     $height = count($tiles) * $this->_tileSource->getTileWidth();
     $width = count($tiles[0]) * $this->_tileSource->getTileHeight();
     $imageHandler = $this->_tileSource->getImageHandler();
     $mapImage = $imageHandler->createImage($width, $height);
     $y = 0;
     $firstTile = $tiles[0][0];
     foreach ($tiles as $rowKey => $row) {
         $x = 0;
         foreach ($row as $tileKey => $tile) {
             imagecopy($mapImage, $tile->getImage(), $x, $y, 0, 0, $this->_tileSource->getTileWidth(), $this->_tileSource->getTileHeight());
             $x += $this->_tileSource->getTileWidth();
         }
         $y += $this->_tileSource->getTileHeight();
     }
     $map = new Map($mapImage);
     $leftUp = $firstTile->getLeftUpCorner();
     $map->setLeftUpCorner($leftUp['lon'], $leftUp['lat']);
     $map->setWorldMap($this->_worldMap);
     $map->setImageHandler($this->_tileSource->getImageHandler());
     return $map;
 }