- //Create image instance
- $image = new \Imagick();
-
- //Add new image
- $image->newImage($width, $height, new \ImagickPixel('transparent'), 'jpeg');
-
- //Create tile instance
- $tile = new \Imagick();
-
- //Get tile xy
- $centerX = $this->map->longitudeToX($longitude, $zoom);
- $centerY = $this->map->latitudeToY($latitude, $zoom);
-
- //Calculate start xy
- $startX = floor(floor($centerX) - $width / MapUtil::tz);
- $startY = floor(floor($centerY) - $height / MapUtil::tz);
-
- //Calculate end xy
- $endX = ceil(ceil($centerX) + $width / MapUtil::tz);
- $endY = ceil(ceil($centerY) + $height / MapUtil::tz);
-
- for($x = $startX; $x <= $endX; $x++) {
- for($y = $startY; $y <= $endY; $y++) {
- //Set cache path
- $cache = $this->cache.'/'.$zoom.'/'.$x.'/'.$y.'.png';
-
- //Without cache image
- if (!is_file($cache)) {
- //Set tile url
- $tileUri = str_replace(['{Z}', '{X}', '{Y}'], [$zoom, $x, $y], $this->url);
-
- //Without cache path
- if (!is_dir($dir = dirname($cache))) {
- //Create filesystem object
- $filesystem = new Filesystem();
-
- try {
- //Create path
- //XXX: set as 0775, symfony umask (0022) will reduce rights (0755)
- $filesystem->mkdir($dir, 0775);
- } catch (IOExceptionInterface $e) {
- //Throw error
- throw new \Exception(sprintf('Output directory "%s" do not exists and unable to create it', $dir), 0, $e);
+ //Create image instance
+ $image = new \Imagick();
+
+ //Add new image
+ $image->newImage($width, $height, new \ImagickPixel('transparent'), 'jpeg');
+
+ //Create tile instance
+ $tile = new \Imagick();
+
+ //Get tile xy
+ $centerX = $this->map->longitudeToX($longitude, $zoom);
+ $centerY = $this->map->latitudeToY($latitude, $zoom);
+
+ //Calculate start xy
+ $startX = floor(floor($centerX) - $width / MapUtil::tz);
+ $startY = floor(floor($centerY) - $height / MapUtil::tz);
+
+ //Calculate end xy
+ $endX = ceil(ceil($centerX) + $width / MapUtil::tz);
+ $endY = ceil(ceil($centerY) + $height / MapUtil::tz);
+
+ for($x = $startX; $x <= $endX; $x++) {
+ for($y = $startY; $y <= $endY; $y++) {
+ //Set cache path
+ $cache = $this->cache.'/'.$this->prefix.'/'.$zoom.'/'.$x.'/'.$y.'.png';
+
+ //Without cache image
+ if (!is_file($cache)) {
+ //Set tile url
+ $tileUri = str_replace(['{Z}', '{X}', '{Y}'], [$zoom, $x, $y], $this->url);
+
+ //Without cache path
+ if (!is_dir($dir = dirname($cache))) {
+ //Create filesystem object
+ $filesystem = new Filesystem();
+
+ try {
+ //Create path
+ //XXX: set as 0775, symfony umask (0022) will reduce rights (0755)
+ $filesystem->mkdir($dir, 0775);
+ } catch (IOExceptionInterface $e) {
+ //Throw error
+ throw new \Exception(sprintf('Output directory "%s" do not exists and unable to create it', $dir), 0, $e);
+ }