Projet

Général

Profil

« Précédent | Suivant » 

Révision a1063f68

IDa1063f687155fd8440c79de3943b6af9935db401
Parent c621f296
Enfant 6156a9b6

Ajouté par Jocelyn Delande il y a environ 10 ans

The one-step upload now handles as well the tiles generation and stops on generation errors if needed

Fichiers

  • ajouté
  • modifié
  • copié
  • renommé
  • supprimé

Voir les différences

Révisions

class/TilesGenerator.php
29 29
			}
30 30
		} else {
31 31
      if (file_exists($pano_path)) {
32
         $pano_files = scandir($pano_path);
33
        foreach($pano_files as $filename) {
34
          if (preg_match('/.*\.jpg/', $filename)) {
35
			      $err = sprintf("\"%s\" contient déjà un découpage de panorama.",
36
                           $pano_path);
37
            break;
38
          }
32
        if ($this->panorama->has_tiles()) {
33
			    $err = sprintf("\"%s\" contient déjà un découpage de panorama.",
34
                         $pano_path);
39 35
        }
40 36
		  } else {
41 37
			  mkdir($pano_path);
class/site_point.class.php
96 96
	                $p['altitude'], $p['titre']));
97 97
  }
98 98

  
99
  public function has_tiles(){
100
	  if (file_exists($this->tiles_path())) {
101
         $pano_files = scandir($this->tiles_path());
102
        foreach($pano_files as $filename) {
103
          if (preg_match('/.*\.jpg/', $filename)) {
104
	          return true;
105
          }
106
        }
107
      } else {
108
	      return false;
109
      }
110
  }
111

  
99 112
  public function get_name() {
100 113
    return basename($this->base_dir);
101 114
  }
......
151 164
    return array($d, $cap*180/M_PI, $e*180/M_PI);   // les résultats sont en degrés
152 165
  }
153 166

  
167
  public function get_generate_url($source_file) {
168
	  /**
169
	   * @param $source_file : the name of the source file within the upload dir.
170
	   */
171
	  return sprintf('genererPano.php?wizard=1&name='.$source_file);
172
  }
173

  
174
  public function src_path(){
175
	  /** @returns the basename of the src image, or false if it's no longer available
176
	   */
177
	  $extensions = array('jpg', 'tif', 'png', 'bmp', 'jpeg', 'pnm',
178
	                      'JPG', 'TIF', 'PNG', 'BMP', 'JPEG', 'PNM');
179

  
180
	  foreach ($extensions as $ext) {
181
		  $tried_name = sprintf('%s/%s.%s', UPLOAD_PATH, $this->get_name(),$ext);
182
		  if (file_exists($tried_name)) {
183
			  return $tried_name;
184
		  }
185
	  }
186
	  return false;
187
  }
188

  
154 189
  public function get_url($cap=false, $ele=false) {
155 190
	  $o = sprintf('panorama.php?dir=%s&panorama=%s',
156 191
	                  PANORAMA_FOLDER, $this->get_name());
......
160 195
	  return $o;
161 196
  }
162 197

  
198
  public function get_map_url($cap=0) {
199
	  $encoded_title = base64_encode($this->get_name());
200
	  $script_name = 'show_capline.php';
201
	  $lat = $this->get_params()['latitude'];
202
	  $lon = $this->get_params()['longitude'];
203

  
204
	  $o = sprintf('%s?title=%s&cap=%s&org_lat=%.5f&org_lon=%.5f&dist=120000',
205
	               $script_name, $encoded_title, $cap, $lat, $lon);
206
	  return $o;
207
  }
208

  
163 209
  public function set_reference($ref_point, $x, $y) {
164 210
	  /**
165 211
	   * Registers (for saving) the position of a reference point within a
class/utils.class.php
84 84
    }
85 85
  }
86 86

  
87
  public static function relative_redirect($extra) {
88
    $host  = $_SERVER['HTTP_HOST'];
89
    $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
90
    header("Location: http://$host$uri/$extra");
91
  }
87 92
}
88 93

  
89 94
?>
genererPano.php
38 38
    print("<p>Pour acceder à la liste des panoramas <a href=\".\">cliquer ici</a></p>\n") ;
39 39

  
40 40

  
41
    // Redirect in js to sumary page
42
    if ($_GET['wizard']) {
43
      printf('<script>window.location=\'panoInfo.php?name=%s\'</script>\n', $pano_name);
44
    }
45

  
41 46
  } catch (TilesGeneratorRightsException $e) {
42 47
    printf("<p class=\"error\">%s</p>\n", $e->getMessage());
43 48
  } catch (TilesGeneratorScriptException $e) {
panoInfo.php
1
<?php
2
require_once 'class/site_point.class.php';
3

  
4

  
5
$pano = site_point::get($_GET['name']);
6

  
7
if ($pano->has_params()) {
8
  $params = $pano->get_params();
9
  $title = $params['titre'];
10
  $lat = $params['latitude'];
11
  $lon = $params['longitude'];
12
} else {
13
  $title = $__GET['name'];
14
}
15

  
16

  
17
$has_tiles = $pano->has_tiles();//TODO
18
$has_params = $pano->has_params();
19
$src_path = $pano->src_path();
20
 ?>
21

  
22
<!DOCTYPE html>
23
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
24
  <head>
25
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
26
    <title>Liste des panoramas</title>
27
    <link rel="stylesheet" media="screen" href="css/base.css"/>
28
  </head>
29
  <body>
30
    <header>
31
      <h1><img src="images/tetaneutral.svg" alt="tetaneutral.net"/></h1>
32
    </header>
33
    <section id="main">
34
      <h2><?php echo $title ?></h2>
35
      <ul id="pano-list">
36
        <li>
37
          <?php if ($has_tiles) { ?>
38
          <a href="<?php echo $pano->get_url();?>">Visualiser</a>
39
          (généré)
40
          <?php } else { ?>
41
          Tuiles non générées 
42
            <?php if ($src_path) {?>
43
              <a href="<?php echo $pano->get_generate_url(basename($src_path))?>">Générer</a>
44
            <?php } else  {?>
45
              (la source n'est plus disponible)
46
            <?php } ?>
47
          <?php } ?>
48
        </li>
49
        <li>
50
          <?php if ($has_params) { ?>
51
          <a href="<?php echo $pano->get_map_url();?>">Voir sur la carte</a>
52
          (<?php printf('%.5f,%.5f', $lat, $lon) ?>)
53
          <?php } else { ?>
54
          Non paramétré
55
            <?php if ($has_tiles) {?>
56
              <a href="<?php echo $pano->get_url();?>">Paramétrer</a>
57
            <?php } ?>
58
          <?php } ?>
59
        </li>
60
      </ul>
61
    </section>
62
    <footer class="validators"><samp>
63
      page validée par
64
      <a href="http://validator.w3.org/check?uri=referer"><img src="images/valid_xhtml.svg"
65
							       alt="Valid XHTML" title="xHTML validé !"/></a>
66
      <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="images/valid_css.svg"
67
								      alt="CSS validé !" title="CSS validé !"/></a>
68
    </samp></footer>
69
  </body>
70
</html>
uploadReceive.php
103 103
}
104 104

  
105 105

  
106
////// STEP 3 : TILES ////////
107

  
108
// We do it in a redirection
109

  
110
if ($upload_success) {
111
  utils::relative_redirect(
112
    $panorama->get_generate_url(basename($uploaded_filepath)));
113
}
106 114
?>
107 115

  
108 116
<!DOCTYPE html>