Project

General

Profile

« Previous | Next » 

Revision 1aebc2ec

ID1aebc2ec043553d931d21d0319bb8cbebf3cc323
Parent 405ba17b
Child 812f173f

Added by Jocelyn Delande about 9 years ago

has_params and get_all for site_point

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences

Changesets

class/site_point.class.php
1 1
<?php
2
require_once(dirname(__FILE__).'/../constants.inc.php');
2 3
class site_point {
3
  private $base_dir;
4
	/** Defines a point, with a panorama
5
	 */
6
	private $base_dir;        // dir of tiles for that panorama
4 7
  private $name = false;
5 8
  private $prefix = false;
6 9
  private $params = false;
......
15 18
    while (false !== ($file = readdir($dir_fd))) {
16 19

  
17 20
       if (preg_match('/(.*)_[0-9]+_[0-9]+_[0-9]+\.jpg$/', $file, $reg)) {
18
	 $this->prefix = $reg[1];
21
	       $this->prefix = $reg[1];
19 22

  
20
	 break;
23
	       break;
21 24
       }
22 25
    }
23 26
    closedir($dir_fd);
......
44 47
	  }
45 48
  }
46 49

  
50
  public function has_params(){
51
	  $p = $this->get_params();
52
	  return (isset($prm['latitude'], $prm['longitude'],
53
	                $prm['altitude'], $prm['titre']))
54
  }
55
   if ($oname != $name && ) {
56

  
57

  
47 58
  public function get_name() {
48 59
    return basename($this->base_dir);
49 60
  }
......
102 113
	  return sprintf('panorama.php?dir=%s&amp;panorama=%s',
103 114
	                 'tiles', $this->get_name());
104 115
  }
116

  
117
  public static function get($name) {
118
	  /** Instantiate a site_point, given its name
119
	   */
120
	  $pano_dir = PANORAMA_PATH.'/'.$name;
121
	  return new site_point($pano_dir);
122
  }
123

  
124
  public static function get_all() {
125
	  $panos = array_diff(scandir(PANORAMA_PATH), array('..', '.'));
126
	  $pano_instances = array();
127
	  foreach ($panos as $pano_name) {
128
		  $pano_instances[] = site_point::get($pano_name);
129
	  }
130
	  return $pano_instances;
131
  }
105 132
}
panorama.php
67 67
   foreach($dir_list->get_sites() as $opt) {
68 68
     $prm = $opt->get_params();
69 69
     $oname = $opt->get_name();
70
     if ($oname != $name && isset($prm['latitude']) && isset($prm['longitude']) && isset($prm['altitude']) && isset($prm['titre'])) {
70
     if ($oname != $name && $opt->has_params()) {
71 71
       list($dist, $cap, $ele) = $pt->coordsToCap($prm['latitude'], $prm['longitude'], $prm['altitude']);
72 72
       $lnk = sprintf("%s?dir=%s&panorama=%s&to_cap=%.3f&to_ele=%.3f", $scrname, $dir, $oname, $cap + 180, -$ele);
73 73
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "%s");'."\n", $ipt++, $prm['titre'], $dist, $cap, $ele, $lnk);