} else { set_time_limit(0); $imgWidth = G_TILE_SIZE; $imgHeight = G_TILE_SIZE; $image = imagecreate($imgWidth, $imgHeight); // Allocate the color map InterpolateRGB($colorScale, RGB(0, 0, 110), RGB(0, 0, 110), 0, 255); InterpolateRGB($colorScale, RGB(0, 100, 0), RGB(180, 180, 50), 1, 60); InterpolateRGB($colorScale, RGB(180, 180, 50), RGB(150, 110, 50), 60, 100); InterpolateRGB($colorScale, RGB(150, 110, 50), RGB(150, 150, 150), 100, 150); InterpolateRGB($colorScale, RGB(150, 150, 150), RGB(255, 255, 255), 150, 200); InterpolateRGB($colorScale, RGB(255, 255, 255), RGB(255, 255, 255), 200, 253); InterpolateRGB($colorScale, RGB(0, 0, 0), RGB(0, 0, 0), 254, 255); AllocateColorMap($image, $colorScale, $cMap); MakeTile($image, $x, $y, $z); $cache->set(PngToString($image), $id); header('Content-type: image/png'); imagepng($image); imagedestroy($image); } } else { header('Content-type: text/plain'); echo 'Invalid URL'; } // Tile handling function MakeTile($image, $x, $y, $zoom) { $proj = new Mercator($zoom, G_TILE_SIZE); $lonL = $proj->Lon($x * G_TILE_SIZE); $lonR = $proj->Lon(($x + 1) * G_TILE_SIZE); $lonBound[0] = $lonL;
private function makeTile() { set_time_limit(0); $dstImg = imagecreatetruecolor(256, 256); $lats[0] = $latB = $this->proj->Lat($this->y + 1); $latT = $this->proj->Lat($this->y); foreach ($this->latLimits as $lat) { if ($lat > $latB && $lat < $latT) { $lats[] = $lat; } } $lats[] = $latT; $lons[0] = $lonL = $this->proj->Lon($this->x); $lonR = $this->proj->Lon($this->x + 1); foreach ($this->lonLimits as $lon) { if ($lon > $lonL && $lon < $lonR) { $lons[] = $lon; } } $lons[] = $lonR; for ($x = 0; $x < count($lons) - 1; $x++) { for ($y = 0; $y < count($lats) - 1; $y++) { $this->makeBlock($dstImg, $lats, $y, $lons, $x); } } return PngToString($dstImg); }