mirror of
https://github.com/klokantech/tileserver-php.git
synced 2025-01-17 22:28:37 +01:00
Empty tiles should have for @2x layers 512x512px Fixes #39
This commit is contained in:
parent
2bf8bf6d4b
commit
53b379cd67
@ -309,7 +309,11 @@ class Server {
|
||||
$result = $this->db->query('select tile_data as t from tiles where zoom_level=' . $z . ' and tile_column=' . $x . ' and tile_row=' . $y);
|
||||
$data = $result->fetchColumn();
|
||||
if (!isset($data) || $data === FALSE) {
|
||||
$this->getCleanTile();
|
||||
//scale of tile (for retina tiles)
|
||||
$result = $this->db->query('select value from metadata where name="scale"');
|
||||
$resultdata = $result->fetchColumn();
|
||||
$scale = isset($resultdata) && $resultdata !== FALSE ? $resultdata : 1;
|
||||
$this->getCleanTile($scale);
|
||||
} else {
|
||||
$result = $this->db->query('select value from metadata where name="format"');
|
||||
$resultdata = $result->fetchColumn();
|
||||
@ -330,19 +334,26 @@ class Server {
|
||||
fpassthru($fp);
|
||||
die;
|
||||
} else {
|
||||
$this->getCleanTile();
|
||||
//scale of tile (for retina tiles)
|
||||
$meta = json_decode(file_get_contents($tileset.'/metadata.json'));
|
||||
if(!isset($meta->scale)){
|
||||
$meta->scale = 1;
|
||||
}
|
||||
$this->getCleanTile($meta->scale);
|
||||
}
|
||||
} else {
|
||||
echo 'Server: Unknown or not specified dataset';
|
||||
echo 'Serverr: Unknown or not specified dataset "'.$tileset.'"';
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns clean tile
|
||||
* @param integer $scale Default 1
|
||||
*/
|
||||
public function getCleanTile() {
|
||||
$png = imagecreatetruecolor(256, 256);
|
||||
public function getCleanTile($scale = 1) {
|
||||
$tileSize = 256 * $scale;
|
||||
$png = imagecreatetruecolor($tileSize, $tileSize);
|
||||
imagesavealpha($png, true);
|
||||
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
|
||||
imagefill($png, 0, 0, $trans_colour);
|
||||
|
Loading…
x
Reference in New Issue
Block a user