mirror of
https://github.com/klokantech/tileserver-php.git
synced 2025-07-16 12:26:19 +02:00
Empty tiles should have for @2x layers 512x512px Fixes #39
This commit is contained in:
@ -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);
|
$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();
|
$data = $result->fetchColumn();
|
||||||
if (!isset($data) || $data === FALSE) {
|
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 {
|
} else {
|
||||||
$result = $this->db->query('select value from metadata where name="format"');
|
$result = $this->db->query('select value from metadata where name="format"');
|
||||||
$resultdata = $result->fetchColumn();
|
$resultdata = $result->fetchColumn();
|
||||||
@ -330,19 +334,26 @@ class Server {
|
|||||||
fpassthru($fp);
|
fpassthru($fp);
|
||||||
die;
|
die;
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
echo 'Server: Unknown or not specified dataset';
|
echo 'Serverr: Unknown or not specified dataset "'.$tileset.'"';
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns clean tile
|
* Returns clean tile
|
||||||
|
* @param integer $scale Default 1
|
||||||
*/
|
*/
|
||||||
public function getCleanTile() {
|
public function getCleanTile($scale = 1) {
|
||||||
$png = imagecreatetruecolor(256, 256);
|
$tileSize = 256 * $scale;
|
||||||
|
$png = imagecreatetruecolor($tileSize, $tileSize);
|
||||||
imagesavealpha($png, true);
|
imagesavealpha($png, true);
|
||||||
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
|
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
|
||||||
imagefill($png, 0, 0, $trans_colour);
|
imagefill($png, 0, 0, $trans_colour);
|
||||||
|
Reference in New Issue
Block a user