Subversion Repositories eFlore/Applications.moissonnage

Rev

Rev 29 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 29 Rev 30
Line 49... Line 49...
49
	}
49
	}
Line 50... Line 50...
50
	
50
	
51
	private function genererTuilage() {
51
	private function genererTuilage() {
52
		if (!$this->estTableCreee()) {
52
		if (!$this->estTableCreee()) {
-
 
53
			$this->creerStructureTable();
53
			$this->creerStructureTable();
54
			print("Table créée");
54
		}
55
		}
55
		$niveauxZoom = range(Config::get('zoom_minimal'), Config::get('zoom_maximal'), 1);
56
		$niveauxZoom = range(Config::get('zoom_minimal'), Config::get('zoom_maximal'), 1);
56
		foreach ($niveauxZoom as $zoom) {
57
		foreach ($niveauxZoom as $zoom) {
57
			print("Génération des mailles au niveau de zoom {$zoom}...\n");
58
			print("Génération des mailles au niveau de zoom {$zoom}...\n");
58
			$this->resolution = $this->resolutionInitiale / pow(2, $zoom);
59
			$this->resolution = $this->resolutionInitiale / pow(2, $zoom);
59
			$coordonneesLng = $this->calculerCoordonneesLimitesTuiles($zoom, 'lng');
60
			$coordonneesLng = $this->calculerCoordonneesLimitesTuiles($zoom, 'lng');
-
 
61
			$coordonneesLat = $this->calculerCoordonneesLimitesTuiles($zoom, 'lat');
60
			$coordonneesLat = $this->calculerCoordonneesLimitesTuiles($zoom, 'lat');
62
			print("mailles calculées\n");
61
			$this->ajouterMaillesDansBdd($zoom, $coordonneesLng, $coordonneesLat);
63
			$this->ajouterMaillesDansBdd($zoom, $coordonneesLng, $coordonneesLat);
62
		}
64
		}
Line 63... Line 65...
63
	}
65
	}
-
 
66
	
64
	
67
	private function estTableCreee() {
65
	private function estTableCreee() {
68
		print("test table");
66
		$tables = $this->getBdd()->recupererTous("SHOW TABLES FROM ".Config::get('bdd_nom'));
69
		$tables = $this->getBdd()->recupererTous("SHOW TABLES FROM ".Config::get('bdd_nom'));
67
		$table = Config::get('eflore_table_mailles');
70
		$table = Config::get('eflore_table_mailles');
68
		for ($index = 0; $index < count($tables) && $tables[$index]['Tables_in_tb_eflore'] != $table; $index ++);
71
		for ($index = 0; $index < count($tables) && $tables[$index]['Tables_in_tb_eflore_test'] != $table; $index ++);
Line 69... Line 72...
69
		return $index < count($tables);
72
		return $index < count($tables);
70
	}
73
	}
Line 111... Line 114...
111
	private function ajouterMaillesDansBdd($zoom, $coordonneesLng, $coordonneesLat) {
114
	private function ajouterMaillesDansBdd($zoom, $coordonneesLng, $coordonneesLat) {
112
		$table = Config::get('eflore_table_mailles');
115
		$table = Config::get('eflore_table_mailles');
113
		$nomsChamps = Config::get('eflore_champs_table');
116
		$nomsChamps = Config::get('eflore_champs_table');
114
		$this->getBdd()->requeter("DELETE FROM {$table} WHERE zoom=$zoom");
117
		$this->getBdd()->requeter("DELETE FROM {$table} WHERE zoom=$zoom");
115
		$insertions = array();
118
		$insertions = array();
-
 
119
		$j = 10000; 
-
 
120
		if (count($coordonneesLng) > $j) {
-
 
121
			for ($i=0; $i < count($coordonneesLng); $i=$i+$j) {
-
 
122
				$insertions = array();print($i." ".$j." ");
-
 
123
				if ($i+$j > count($coordonneesLng)) {
-
 
124
					$k =count($coordonneesLng) - 1;
-
 
125
				} else {
-
 
126
					$k = $i+$j;
-
 
127
				} print_r($k."\n");
-
 
128
				for ($index = $i; $index < $k; $index ++) {
-
 
129
					$insertions[] = "({$zoom},'lng',{$index},".$coordonneesLng[$index].",".$coordonneesLng[$index+1].")";
-
 
130
				}
-
 
131
				for ($index = $i; $index < $k; $index ++) {
-
 
132
					$insertions[] = "({$zoom},'lat',{$index},".$coordonneesLat[$index].",".$coordonneesLat[$index+1].")";
-
 
133
				}
-
 
134
				$requete = "INSERT INTO {$table}({$nomsChamps}) VALUES ".implode(',', $insertions);
-
 
135
				$this->getBdd()->requeter($requete);
-
 
136
			}
-
 
137
		} else {
116
		for ($index = 0; $index < count($coordonneesLng)-1; $index ++) {
138
			for ($index = 0; $index < count($coordonneesLng)-1; $index ++) {
117
			$insertions[] = "({$zoom},'lng',{$index},".$coordonneesLng[$index].",".$coordonneesLng[$index+1].")";
139
				$insertions[] = "({$zoom},'lng',{$index},".$coordonneesLng[$index].",".$coordonneesLng[$index+1].")";
-
 
140
			}
-
 
141
			for ($index = 0; $index < count($coordonneesLat)-1; $index ++) {
-
 
142
				$insertions[] = "({$zoom},'lat',{$index},".$coordonneesLat[$index].",".$coordonneesLat[$index+1].")";
-
 
143
			}
-
 
144
			$requete = "INSERT INTO {$table}({$nomsChamps}) VALUES ".implode(',', $insertions);
-
 
145
			$this->getBdd()->requeter($requete);
118
		}
146
		}
119
		for ($index = 0; $index < count($coordonneesLat)-1; $index ++) {
-
 
120
			$insertions[] = "({$zoom},'lat',{$index},".$coordonneesLat[$index].",".$coordonneesLat[$index+1].")";
-
 
121
		}
147
		
122
		$requete = "INSERT INTO {$table}({$nomsChamps}) VALUES ".implode(',', $insertions);
-
 
123
		$this->getBdd()->requeter($requete);
-
 
124
	}
148
	}
Line 125... Line 149...
125
	
149
	
126
	private function getBdd() {
150
	private function getBdd() {
127
		if (is_null($this->bdd)) {
151
		if (is_null($this->bdd)) {