Project

General

Profile

« Previous | Next » 

Revision 7096d2f9

ID7096d2f9afa60e9a356634713de276bc4de37adf
Parent ffebe856
Child def96176

Added by Jocelyn Dealande almost 8 years ago

Refacto of Tiles handling and simplified a bit file naming for tiles/params.
By the way, fixes #297

THIS COMMIT BREAKS FILE LAYOUT AND REQUIRES MIGRATION (SEE BELLOW).

To migrate data :

cd tiles
find . '*.jpg' -exec rename 's/[^\/]*_(([0-9]{3}_){2}([0-9]{3}))/$1/' {} \;
rename 's/(.*\/).*\.params/$1site.params/' */*.params

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences

Changesets

ajax/all_points.php
1 1
<?php
2
header("Content-type: application/json");
3

  
2 4
require_once('../class/site_point.class.php');
3 5

  
4 6
function get_ref_points() {
class/Tile.class.php
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
?>
class/TilesGenerator.php
40 40
		if ($err) {
41 41
			throw (new TilesGeneratorRightsException($err));
42 42
		}
43

  
44 43
	}
45 44

  
46 45
	public function mk_command() {
47 46
		/** Returns the command to execute
48 47
		 */
49
		$c = sprintf('%s/%s -p "%s" "%s"',
48
		$c = sprintf('%s/%s -p "%s/" "%s"',
50 49
		             CELUTZ_PATH, $this::SCRIPT_RELATIVE_PATH,
51
		             $this->panorama->tiles_prefix(), $this->img_path);
50
		             $this->panorama->tiles_path(), $this->img_path);
52 51
		return escapeshellcmd($c);
53 52
	}
54 53

  
class/site_point.class.php
2 2
require_once(dirname(__FILE__).'/../constants.inc.php');
3 3
require_once(dirname(__FILE__).'/utils.class.php');
4 4
require_once(dirname(__FILE__).'/GeoPoint.class.php');
5
require_once(dirname(__FILE__).'/Tile.class.php');
6

  
5 7
//
6 8
class PanoramaFormatException extends Exception {
7 9
	/** If the files organization is not correct for a panorama, we can't let it go...
......
25 27
  }
26 28

  
27 29
  public function params_path() {
28
	  return $this->base_dir.'/'.$this->prefix.'.params';
30
	  return $this->base_dir.'/site.params';
31
  }
32

  
33
  /** Look for a *.params file in the base_dir
34
   *
35
   *  Tries first the site.params, then a globbing *.params.
36
   *
37
   *  May be deprecated at a certain time (if we consider all files should be
38
   *  named site.params)
39
   *
40
   *  @returns false if not found, an abs path else.
41
   */
42
  private function look_for_params() {
43
	if (is_file($this->params_path())) {
44
	  return $this->params_path();
45
	}
46
	$matches = glob($this->base_dir.'/*.params');
47
	if ($matches and count($matches) > 0) {
48
	  return $matches[0];
49
	} else {
50
	  return false;
51
	}
29 52
  }
30 53

  
31 54
  public function tiles_url_prefix() {
32
	  return PANORAMA_FOLDER.'/'.$this->prefix;
55
	  return PANORAMA_FOLDER;
33 56
  }
34 57

  
35 58
  public function tiles_path() {
36 59
	  return $this->base_dir;
37 60
  }
38 61

  
39
  public function tiles_prefix() {
40
	  return $this->base_dir.'/'.$this->get_prefix();
41
  }
42

  
43 62
  private function parse_and_cache_params() {
44
    if (is_file($this->params_path())) {
45
	    $params = parse_ini_file($this->params_path());
63
	$params_path = $this->look_for_params();
64

  
65
    if ($params_path) {
66
	    $params = parse_ini_file($params_path);
46 67
	    if ($params) {
47 68
		    $this->params = $params;
48 69
		    if (isset($params[self::$REF_KEY])) {
......
133 154
  }
134 155

  
135 156
  public function get_magnifications() {
136
    $dir_fd = opendir($this->base_dir);
157
    //$dir_fd = opendir($this->base_dir);
137 158
    $zoom_array = array();
138
    while (false !== ($file = readdir($dir_fd))) {                // extraction des paramètres de grossissement par le serveur
139
       //echo $file;
140
       if (preg_match('/(.*)_([0-9]+)_([0-9]+)_([0-9]+)\.jpg$/', $file, $reg)) {
141
	 $prefix = $reg[1];
142
	 if ($prefix == $this->prefix) {
143
	   $zoom = (int)$reg[2];
144
	   $posx = (int)$reg[3]+1;
145
	   $posy = (int)$reg[4]+1;
146
	   if (!isset($zoom_array[$zoom]['nx']) || $zoom_array[$zoom]['nx'] < $posx) $zoom_array[$zoom]['nx'] = $posx;
147
	   if (!isset($zoom_array[$zoom]['ny']) || $zoom_array[$zoom]['ny'] < $posy) $zoom_array[$zoom]['ny'] = $posy;
148
	 }
149
       }
150
    }
159

  
160
	// extraction des paramètres de grossissement par le serveur
161
	$stop = false;
162
	$zoom_level = 0;
163

  
164
	while (! $stop) {
165
	  $files = glob(sprintf('%s/%03d_*.jpg', $this->base_dir, $zoom_level));
166
	  sort($files);
167
	  $last_file = end($files);
168
	  if ($last_file) {
169
		$last_tile = Tile::from_file($last_file, $this);
170
		$zoom_array[$zoom_level] = array('nx' => $last_tile->x + 1,
171
										 'ny' => $last_tile->y + 1);
172
		$zoom_level++;
173
	  } else {
174
		$stop = true;
175
	  }
176
	}
151 177
    $this->zooms = $zoom_array;
152 178
    return $this->zooms;
153 179
  }
js/pano.js
264 264
    putImage(last.x, last.y);
265 265
}
266 266

  
267
/** Returns a 3-width zero-padded version of an int
268
 * ex: 3 -> "003"
269
 */
270
function zero_pad(number) {
271
	var temp = number.toString(10);
272
	while (temp.length < 3) {
273
		temp = '0' + temp;
274
	}
275
	return temp;
276
}
277

  
267 278
function get_file_name(x, y, z) { // recherche du fichier correspondant au zoom et à la position
268
    var prm = [z, x, y];
269
    var fname = img_prefix;
270
    for (var i = 0; i < prm.length; i++) {
271
	fname += '_';
272
	if (prm[i] < 10) fname += '00';
273
	else if (prm[i] < 100) fname += '0';
274
	fname += prm[i];
275
    }
276
    fname += '.jpg';
277
    return fname;
279
	return img_prefix+'/'+zero_pad(z)+'_'+zero_pad(x)+'_'+zero_pad(y)+'.jpg';
278 280
}
279 281

  
280 282
function get_base_name() {
......
483 485
    this.is_updated = false;
484 486

  
485 487
    this.refresh = function() {
486
	this.im.visible_width = this.tile.width*(this.ntiles.x-1)+this.last_tile.width;
487
	this.is_updated = true;
488

  
489
	this.im.width = this.im.visible_width;
490
	this.im.height = this.tile.height*(this.ntiles.y-1)+this.last_tile.height;
491
	if (this.last_tile.width > this.tile.width) this.max_tile.width = this.im.last_tile.width;
492
	else this.max_tile.width = this.tile.width;
493
	if (this.last_tile.height > this.tile.height) this.max_tile.height = this.im.last_tile.height;
494
	else this.max_tile.height = this.tile.height;
495

  
496
	var ord_pts = new Array();
497
	i=0;
498
	for(var label in ref_points) {
499
	    ord_pts[i++] = ref_points[label]
500
	}
501
	ord_pts = ord_pts.sort(tri_ref_points);
502
	is_located = i > 1 || image_loop && i > 0;
488
	    this.im.visible_width = this.tile.width*(this.ntiles.x-1)+this.last_tile.width;
489
	    this.is_updated = true;
503 490

  
504
	var alpha_domain = {start:0, end:360};
505
	this.pixel_y_ratio = this.im.width/360;
506
	if (is_located) {
507
	    this.ref_pixels = new Array;
508
	    this.ref_pixels[0] = new Array();    // Attention il faut compter un intervalle de plus !
509
	    for (var i=0; i < ord_pts.length; i++) { // premier parcours pour les paramètres cap/x
510
		this.ref_pixels[i+1] = new Array();
511
		this.ref_pixels[i+1].x = Math.floor(ord_pts[i].x*this.im.width);
512
		this.ref_pixels[i+1].cap = fmodulo(ord_pts[i].cap, 360);
513
		if (i != ord_pts.length-1) {
514
		    this.ref_pixels[i+1].ratio_x = (ord_pts[i+1].x - ord_pts[i].x)/fmodulo(ord_pts[i+1].cap - ord_pts[i].cap, 360)*this.im.width;
515
		}
516
	    }
517
	    if (image_loop == true) {
518
		var dpix = this.im.width;
519
		var dangle = 360;
520
		if (ord_pts.length > 1) {
521
		    dpix = this.im.width - this.ref_pixels[this.ref_pixels.length-1].x + this.ref_pixels[1].x;
522
		    dangle = fmodulo(this.ref_pixels[1].cap - this.ref_pixels[this.ref_pixels.length-1].cap, 360);
523
		}
524
		this.ref_pixels[0].ratio_x = dpix/dangle;
525
		this.ref_pixels[ord_pts.length].ratio_x = this.ref_pixels[0].ratio_x;
526
		dpix = this.im.width - this.ref_pixels[ord_pts.length].x;
527
		this.ref_pixels[0].cap = fmodulo(this.ref_pixels[ord_pts.length].cap + dpix / this.ref_pixels[0].ratio_x, 360);
491
	    this.im.width = this.im.visible_width;
492
	    this.im.height = this.tile.height*(this.ntiles.y-1)+this.last_tile.height;
493
	    if (this.last_tile.width > this.tile.width) {
494
		    this.max_tile.width = this.im.last_tile.width;
528 495
	    } else {
529
		this.ref_pixels[0].ratio_x = this.ref_pixels[1].ratio_x;
530
		this.ref_pixels[ord_pts.length].ratio_x = this.ref_pixels[ord_pts.length-1].ratio_x;
531
		this.ref_pixels[0].cap = fmodulo(this.ref_pixels[1].cap - this.ref_pixels[1].x / this.ref_pixels[1].ratio_x, 360);
532
		alpha_domain.start = this.ref_pixels[0].cap;
533
		alpha_domain.end = fmodulo(this.ref_pixels[ord_pts.length].cap+(this.im.width-this.ref_pixels[ord_pts.length].x)/this.ref_pixels[ord_pts.length].ratio_x, 360);
534
		this.pixel_y_ratio = this.im.width/fmodulo(alpha_domain.end-alpha_domain.start, 360);
496
		    this.max_tile.width = this.tile.width;
535 497
	    }
536
	    this.ref_pixels[0].x = 0;
537

  
538
	    for (var i=0; i < ord_pts.length; i++) { // second parcours pour les paramètres elevation/y
539
		this.ref_pixels[i+1].shift_y = Math.floor(this.pixel_y_ratio*ord_pts[i].ele - ord_pts[i].y*this.im.height);
540
		if (i != ord_pts.length-1) {
541
		    var next_shift = Math.floor(this.pixel_y_ratio*ord_pts[i+1].ele - ord_pts[i+1].y*this.im.height);
542
		    this.ref_pixels[i+1].dshft_y = (next_shift - this.ref_pixels[i+1].shift_y)/(this.ref_pixels[i+2].x - this.ref_pixels[i+1].x);
543
		}
498
	    if (this.last_tile.height > this.tile.height) {
499
		    this.max_tile.height = this.im.last_tile.height;
500
	    } else {
501
		    this.max_tile.height = this.tile.height;
544 502
	    }
545 503

  
546
	    if (image_loop == true) {
547
		var dpix  = this.im.width;
548
		var delt = 0;
549
		if (ord_pts.length > 1) {
550
		    dpix  = this.im.width - this.ref_pixels[this.ref_pixels.length-1].x + this.ref_pixels[1].x;
551
		    delt = this.ref_pixels[this.ref_pixels.length-1].shift_y - this.ref_pixels[1].shift_y;
552
		}
553
		this.ref_pixels[0].dshft_y = -delt/dpix;
554
		this.ref_pixels[ord_pts.length].dshft_y = this.ref_pixels[0].dshft_y;
555
		dpix = this.im.width - this.ref_pixels[ord_pts.length].x;
556
		this.ref_pixels[0].shift_y = this.ref_pixels[ord_pts.length].shift_y + dpix*this.ref_pixels[0].dshft_y;
557
	    } else {
558
		this.ref_pixels[0].shift_y = this.ref_pixels[1].shift_y;
559
		this.ref_pixels[0].dshft_y = 0;
560
		this.ref_pixels[ord_pts.length].dshft_y = 0;
504
	    var ord_pts = new Array();
505
	    for(var label in ref_points) {
506
		    ord_pts.push(ref_points[label]);
561 507
	    }
508
	    ord_pts = ord_pts.sort(tri_ref_points);
509
	    is_located = i > 1 || image_loop && i > 0;
510

  
511
	    var alpha_domain = {start:0, end:360};
512
	    this.pixel_y_ratio = this.im.width/360;
513
	    if (is_located) {
514
		    this.ref_pixels = new Array;
515
		    this.ref_pixels[0] = new Array();    // Attention il faut compter un intervalle de plus !
516
		    for (var i=0; i < ord_pts.length; i++) { // premier parcours pour les paramètres cap/x
517
			    this.ref_pixels[i+1] = new Array();
518
			    this.ref_pixels[i+1].x = Math.floor(ord_pts[i].x*this.im.width);
519
			    this.ref_pixels[i+1].cap = fmodulo(ord_pts[i].cap, 360);
520
			    if (i != ord_pts.length-1) {
521
				    this.ref_pixels[i+1].ratio_x = (ord_pts[i+1].x - ord_pts[i].x) /
522
					    fmodulo(ord_pts[i+1].cap - ord_pts[i].cap, 360)*this.im.width;
523
			    }
524
		    }
525
		    if (image_loop == true) {
526
			    var dpix = this.im.width;
527
			    var dangle = 360;
528
			    if (ord_pts.length > 1) {
529
				    dpix = this.im.width - this.ref_pixels[this.ref_pixels.length-1].x + this.ref_pixels[1].x;
530
				    dangle = fmodulo(this.ref_pixels[1].cap - this.ref_pixels[this.ref_pixels.length-1].cap, 360);
531
			    }
532
			    this.ref_pixels[0].ratio_x = dpix/dangle;
533
			    this.ref_pixels[ord_pts.length].ratio_x = this.ref_pixels[0].ratio_x;
534
			    dpix = this.im.width - this.ref_pixels[ord_pts.length].x;
535
			    this.ref_pixels[0].cap = fmodulo(this.ref_pixels[ord_pts.length].cap + dpix / this.ref_pixels[0].ratio_x, 360);
536
		    } else {
537
			    this.ref_pixels[0].ratio_x = this.ref_pixels[1].ratio_x;
538
			    this.ref_pixels[ord_pts.length].ratio_x = this.ref_pixels[ord_pts.length-1].ratio_x;
539
			    this.ref_pixels[0].cap = fmodulo(this.ref_pixels[1].cap - this.ref_pixels[1].x / this.ref_pixels[1].ratio_x, 360);
540
			    alpha_domain.start = this.ref_pixels[0].cap;
541
			    alpha_domain.end = fmodulo(this.ref_pixels[ord_pts.length].cap+(this.im.width-this.ref_pixels[ord_pts.length].x)/this.ref_pixels[ord_pts.length].ratio_x, 360);
542
			    this.pixel_y_ratio = this.im.width/fmodulo(alpha_domain.end-alpha_domain.start, 360);
543
		    }
544
		    this.ref_pixels[0].x = 0;
562 545

  
563
	    if (debug_mode) {
564
		var res = document.getElementById('res');
565
		res.innerHTML = 'liste des '+this.ref_pixels.length+' valeurs de correction (image = '+this.im.width+'x'+this.im.height+') zoom = '+this.value+':<br/>';
566
		for (var i=0; i < this.ref_pixels.length; i++) { // pour le debug
567
		    res.innerHTML += '<p>point '+i+' :</p><ul>';
568
		    for (var key in this.ref_pixels[i]) { // pour le debug
569
			res.innerHTML += '<li>'+key + '['+i+'] = '+this.ref_pixels[i][key]+'</li>';
546
		    for (var i=0; i < ord_pts.length; i++) { // second parcours pour les paramètres elevation/y
547
			    this.ref_pixels[i+1].shift_y = Math.floor(this.pixel_y_ratio*ord_pts[i].ele - ord_pts[i].y*this.im.height);
548
			    if (i != ord_pts.length-1) {
549
				    var next_shift = Math.floor(this.pixel_y_ratio*ord_pts[i+1].ele - ord_pts[i+1].y*this.im.height);
550
				    this.ref_pixels[i+1].dshft_y = (next_shift - this.ref_pixels[i+1].shift_y)/(this.ref_pixels[i+2].x - this.ref_pixels[i+1].x);
551
			    }
570 552
		    }
571
		    if (i != this.ref_pixels.length-1) {
572
			var tx0 = this.ref_pixels[i+1].x-1;
573
			//var ty0 = this.ref_pixels[i+1].shift_y;
574
			var ty0 = 0;
553

  
554
		    if (image_loop == true) {
555
			    var dpix  = this.im.width;
556
			    var delt = 0;
557
			    if (ord_pts.length > 1) {
558
				    dpix  = this.im.width - this.ref_pixels[this.ref_pixels.length-1].x + this.ref_pixels[1].x;
559
				    delt = this.ref_pixels[this.ref_pixels.length-1].shift_y - this.ref_pixels[1].shift_y;
560
			    }
561
			    this.ref_pixels[0].dshft_y = -delt/dpix;
562
			    this.ref_pixels[ord_pts.length].dshft_y = this.ref_pixels[0].dshft_y;
563
			    dpix = this.im.width - this.ref_pixels[ord_pts.length].x;
564
			    this.ref_pixels[0].shift_y = this.ref_pixels[ord_pts.length].shift_y + dpix*this.ref_pixels[0].dshft_y;
575 565
		    } else {
576
			var tx0 = this.im.width-1;
577
			var ty0 = 0;
566
			    this.ref_pixels[0].shift_y = this.ref_pixels[1].shift_y;
567
			    this.ref_pixels[0].dshft_y = 0;
568
			    this.ref_pixels[ord_pts.length].dshft_y = 0;
569
		    }
570

  
571
		    if (debug_mode) {
572
			    var res = document.getElementById('res');
573
			    res.innerHTML = 'liste des '+this.ref_pixels.length+' valeurs de correction (image = '+this.im.width+'x'+this.im.height+') zoom = '+this.value+':<br/>';
574
			    for (var i=0; i < this.ref_pixels.length; i++) { // pour le debug
575
				    res.innerHTML += '<p>point '+i+' :</p><ul>';
576
				    for (var key in this.ref_pixels[i]) { // pour le debug
577
					    res.innerHTML += '<li>'+key + '['+i+'] = '+this.ref_pixels[i][key]+'</li>';
578
				    }
579
				    if (i != this.ref_pixels.length-1) {
580
					    var tx0 = this.ref_pixels[i+1].x-1;
581
					    //var ty0 = this.ref_pixels[i+1].shift_y;
582
					    var ty0 = 0;
583
				    } else {
584
					    var tx0 = this.im.width-1;
585
					    var ty0 = 0;
586
				    }
587
				    res.innerHTML += '</ul><p>test sur : '+tx0+','+ty0+'</p>';
588
				    var tst = this.get_cap_ele(tx0, ty0);
589
				    res.innerHTML += '<p>cap:'+tst.cap+', ele:'+tst.ele+'</p>';
590
				    var tst2 = this.get_pos_xy(tst.cap, tst.ele);
591
				    res.innerHTML += '</ul><p>x:'+tst2.x+', y:'+tst2.y+'</p>';
592
			    }
578 593
		    }
579
		    res.innerHTML += '</ul><p>test sur : '+tx0+','+ty0+'</p>';
580
		    var tst = this.get_cap_ele(tx0, ty0);
581
		    res.innerHTML += '<p>cap:'+tst.cap+', ele:'+tst.ele+'</p>';
582
		    var tst2 = this.get_pos_xy(tst.cap, tst.ele);
583
		    res.innerHTML += '</ul><p>x:'+tst2.x+', y:'+tst2.y+'</p>';
584
		}
585 594
	    }
586
	}
587 595

  
588
	this.pt_list = new Array();
589
	for (var i=0; i<point_list.length; i++) {
590
	    var lbl = point_list[i][0];
591
	    var dst = point_list[i][1];
592
	    var cap = point_list[i][2];
593
	    var ele = point_list[i][3];
594
	    var lnk = point_list[i][4];
595
	    var typ = 'unlocated';
596
	    var rxy = this.get_pos_xy(cap, ele);
597
	    var is_visible = fmodulo(cap - alpha_domain.start, 360) <= fmodulo(alpha_domain.end - alpha_domain.start -0.0001, 360)+0.0001 && is_located;
598

  
599
	    this.pt_list[i] = new Array();
600
	    if (ref_points[lbl] != undefined) {
601
		typ = 'ref_point';
602
		if (!is_located) rxy = {x:ref_points[lbl].x*this.im.width, y:ref_points[lbl].y*this.im.height}
603
	    } else if(lnk == '' && is_visible && lbl != 'point temporaire') {
604
		typ = 'loc_point';
605
	    }else if(is_visible && lbl =='point temporaire') {
606
	    typ = 'temporary';
607

  
608
	    } else if(is_visible) {
609
		typ = 'pano_point';
610
		lnk += '&to_zoom='+this.value;
596
	    this.pt_list = new Array();
597
	    for (var i=0; i<point_list.length; i++) {
598
		    var lbl = point_list[i][0];
599
		    var dst = point_list[i][1];
600
		    var cap = point_list[i][2];
601
		    var ele = point_list[i][3];
602
		    var lnk = point_list[i][4];
603
		    var typ = 'unlocated';
604
		    var rxy = this.get_pos_xy(cap, ele);
605
		    var is_visible = fmodulo(cap - alpha_domain.start, 360) <= fmodulo(alpha_domain.end - alpha_domain.start -0.0001, 360)+0.0001 && is_located;
606

  
607
		    this.pt_list[i] = new Array();
608
		    if (ref_points[lbl] != undefined) {
609
			    typ = 'ref_point';
610
			    if (!is_located) rxy = {x:ref_points[lbl].x*this.im.width, y:ref_points[lbl].y*this.im.height}
611
		    } else if(lnk == '' && is_visible && lbl != 'point temporaire') {
612
			    typ = 'loc_point';
613
		    }else if(is_visible && lbl =='point temporaire') {
614
			    typ = 'temporary';
615

  
616
		    } else if(is_visible) {
617
			    typ = 'pano_point';
618
			    lnk += '&to_zoom='+this.value;
619
		    }
620
		    this.pt_list[i]['type'] = typ;
621
		    this.pt_list[i]['cap'] = cap;
622
		    this.pt_list[i]['ele'] = ele;
623
		    this.pt_list[i]['dist'] = dst;
624
		    this.pt_list[i]['label'] = lbl;
625
		    this.pt_list[i]['lnk'] = lnk;
626
		    this.pt_list[i]['xc'] = rxy.x;
627
		    this.pt_list[i]['yc'] = Math.floor(this.im.height/2 - rxy.y);
611 628
	    }
612
	    this.pt_list[i]['type'] = typ;
613
	    this.pt_list[i]['cap'] = cap;
614
	    this.pt_list[i]['ele'] = ele;
615
	    this.pt_list[i]['dist'] = dst;
616
	    this.pt_list[i]['label'] = lbl;
617
	    this.pt_list[i]['lnk'] = lnk;
618
	    this.pt_list[i]['xc'] = rxy.x;
619
	    this.pt_list[i]['yc'] = Math.floor(this.im.height/2 - rxy.y);
620
	}
621
    }
629
    },
622 630

  
623 631
    this.get_tile_size = function(nx, ny) {
624 632
	var res = {width:0, height:0};
panorama.php
3 3
<head>
4 4
  <?php
5 5
   require 'class/utils.class.php';
6
   require_once('class/Tile.class.php');
7

  
6 8
   require_once 'constants.inc.php';
7 9

  
8 10
  $fields_spec = array(
......
67 69
  <script>
68 70
  <?php
69 71
     $zoom_array = $pt->get_magnifications();
70

  
71 72
     foreach($zoom_array as $zoom => $val) {
73
       $first_tile = new Tile($pt, $zoom, 0, 0);
74
       $last_tile = new Tile($pt, $zoom, $val['nx']-1, $val['ny']-1);
75

  
72 76
       echo "zooms[$zoom] = new tzoom($zoom);\n";
73 77
       echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n";
74 78
       echo "zooms[$zoom].ntiles.y = ".$val['ny'].";\n";
75
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, 0, 0));
79
       $size = $first_tile->dimensions();
76 80
       echo "zooms[$zoom].tile.width = ".$size[0].";\n";
77 81
       echo "zooms[$zoom].tile.height = ".$size[1].";\n";
78
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, $val['nx']-1, $val['ny']-1));
79
       echo "zooms[$zoom].last_tile.width = ".$size[0].";\n";
80
       echo "zooms[$zoom].last_tile.height = ".$size[1].";\n";
82
       // Last tile usually have a "remainder" size
83
       $last_size = $last_tile->dimensions();
84
       echo "zooms[$zoom].last_tile.width = ".$last_size[0].";\n";
85
       echo "zooms[$zoom].last_tile.height = ".$last_size[1].";\n";
81 86
     }
82

  
83 87
   $dir_list = new sites_dir($dir);
84 88

  
85 89
   $ipt = 0;
to_tiles/gen_tiles.sh
71 71

  
72 72
for ((z=$min_scale; z <= $max_scale; z++))
73 73
do
74
    fprefix=${prefix}_00$z
74
    fprefix=${prefix}00$z
75 75
    printf -v ratio %1.4lf $(echo "1 / (2^$z)" | bc -l)
76 76
    echo génération du ratio $ratio
77 77
    zwfname=$tmp_file
......
112 112
if ! $test_mode; then
113 113
## les lignes ci dessous sont destinnées à mettre des 0 en debut des numéros de ligne et de colonnes
114 114
## Il y a certainement plus simple mais là c'est du rapide et efficace.
115
    rename 's/_(\d\d)_(\d+\.jpg)$/_0$1_$2/' ${prefix}_*
116
    rename 's/_(\d)_(\d+\.jpg)$/_00$1_$2/' ${prefix}_*
117
    rename 's/_(\d+)_(\d\d)(\.jpg)$/_$1_0$2$3/' ${prefix}_*
118
    rename 's/_(\d+)_(\d)(\.jpg)$/_$1_00$2$3/' ${prefix}_*
115
    rename 's/_(\d\d)_(\d+\.jpg)$/_0$1_$2/' ${prefix}*
116
    rename 's/_(\d)_(\d+\.jpg)$/_00$1_$2/' ${prefix}*
117
    rename 's/_(\d+)_(\d\d)(\.jpg)$/_$1_0$2$3/' ${prefix}*
118
    rename 's/_(\d+)_(\d)(\.jpg)$/_$1_00$2$3/' ${prefix}*
119 119
fi