Projet

Général

Profil

Paste
Télécharger (906 octets) Statistiques
| Branche: | Révision:

root / class / Tile.class.php @ 5bfbdfb4

1
<?php
2

    
3
class Tile {
4
  /** Defines a Tile from a panorama
5
   */
6

    
7
    private $point;
8
    private $zoom;
9
    public $x;
10
    public $y;
11

    
12
    public function __construct($site_point, $zoom, $x, $y) {
13
        $this->point = $site_point;
14
        $this->zoom = $zoom;
15
        $this->x = $x;
16
        $this->y = $y;
17
    }
18

    
19
    public function path() {
20
        return sprintf('%s/%03d_%03d_%03d.jpg', $this->point->tiles_path(),
21
                       $this->zoom, $this->x, $this->y);
22
    }
23

    
24
    /** Returns tile size (x,y)
25
     */
26
    public function dimensions() {
27
        return getimagesize($this->path());
28
    }
29

    
30
    public static function from_file($file_path, $site_point) {
31
        preg_match('/([0-9]+)_([0-9]+)_([0-9]+)\.jpg$/', $file_path, $groups);
32
        $zoom = (int)($groups[1]);
33
                $x = (int)($groups[2]);
34
                $y = (int)($groups[3]);
35
        return new Tile($site_point, $zoom, $x, $y);
36
    }
37
  };
38
?>