/** * Given index of a mosaic image, and a pixel position on that image handle a zoom * If the zoom level is 2, this needs to perform a redirect to the gridsquare page * otherwise, it reconfigures the instance for the zoomed in map * @access public */ function zoomIn($i, $j, $x, $y) { //so where did we click? list($clickx, $clicky) = $this->getClickCoordinates($i, $j, $x, $y); $zoomindex = array_search($this->pixels_per_km, $this->scales); if ($zoomindex === FALSE) { $zoomindex = 0; } $zoomindex++; if ($zoomindex > count($this->scales) || $this->pixels_per_km > 40) { //we're going to zoom into a grid square $square = new GridSquare(); if ($square->loadFromPosition($clickx, $clicky)) { $images = $square->getImages(false, '', 'order by moderation_status+0 desc,seq_no limit 2'); //if the image count is 1, we'll go straight to the image if (count($images) == 1) { $url = "http://" . $_SERVER['HTTP_HOST'] . '/photo/' . $images[0]->gridimage_id; } else { //lets go to the grid reference $url = "http://" . $_SERVER['HTTP_HOST'] . '/gridref/' . $square->grid_reference; } } else { require_once 'geograph/conversions.class.php'; $conv = new Conversions(); list($gr, $len) = $conv->internal_to_gridref($clickx, $clicky, 0); $url = "http://" . $_SERVER['HTTP_HOST'] . '/gridref/' . $gr; } header("Location:{$url}"); exit; } else { $scale = $this->scales[$zoomindex]; } //store the clicked position to make a better estimate at the required grid $this->old_centrex = $clickx; $this->old_centrey = $clicky; //size of new map in km $mapw = $this->image_w / $scale; $maph = $this->image_h / $scale; //here's the perfect origin $bestoriginx = $clickx - $mapw / 2; $bestoriginy = $clicky - $maph / 2; $this->setScale($scale); $this->setMosaicFactor(2); $this->setAlignedOrigin($bestoriginx, $bestoriginy); }