/** * @return int */ private function getBoundsZoom() { $zoom = $this->autoMaxZoom; // area in pixels that markers/polygons occupy $w = $this->bounds->getWidth(); $h = $this->bounds->getHeight(); // map image size in pixels while ($zoom > 1) { $scale = $this->proj->scale($zoom); $newW = (int) ($w * $scale + $this->hMargin); $newH = (int) ($h * $scale + $this->vMargin); if ($newW < $this->width && $newH < $this->height) { break; } $zoom--; } return $zoom; }
/** * Translate point (pyr) from src (fyros) * to dst (fyros in world map) * * All arrays are in [ [left,bottom], [right,top] ] * * @param Point $point * @param Bounds $src * @param Bounds $dst * * @return Point */ protected function translate(Point $point, Bounds $src, Bounds $dst) { $px = ($point->x - $src->left) / $src->getWidth(); $py = ($point->y - $src->top) / $src->getHeight(); $left = $dst->left + $px * $dst->getWidth(); $top = $dst->bottom - $py * $dst->getHeight(); return new Point($left, $top); }
/** * @param Point $point * @param Bounds $bbox * * @return Bounds */ protected function getTileBounds(Point $point, Bounds $bbox) { $hw = $bbox->getWidth() / 2; $hh = $bbox->getHeight(); $px1 = $point->x - $hw; $py1 = $point->y - $hh; $px2 = $point->x + $hw; $py2 = $point->y + $hh; $this->debug(" txtbox [{$px1}, {$py1}, {$px2}, {$py2}] -> "); $tx1 = floor($px1 / TileStorageInterface::TILE_SIZE); $tx2 = floor($px2 / TileStorageInterface::TILE_SIZE); $ty1 = floor($py1 / TileStorageInterface::TILE_SIZE); $ty2 = floor($py2 / TileStorageInterface::TILE_SIZE); $this->debug(" tile [{$tx1}, {$ty1}], [{$tx2}, {$ty2}]"); //$xTiles = ($tx2 - $tx1) + 1; //$yTiles = ($ty2 - $ty1) + 1; //$this->debug(" nb tiles ($xTiles, $yTiles)\n"); //return [$tx1, $ty1, $xTiles, $yTiles]; return new Bounds($tx1, $ty2, $tx2, $ty1); }