Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 1060 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1056 jpm 1
<?php
2
/**
3
 * Création de la table osm_communes.
4
 * /opt/lampp/bin/php cli.php osm -a communes -m manuel
5
 *
6
 */
7
class FranceCommunes {
8
 
9
	private $conteneur;
10
	private $bdd;
11
	private $messages;
12
	private $mode;
13
 
14
	private $bddOsmNom;
15
 
16
	public function __construct($conteneur) {
17
		$this->conteneur = $conteneur;
18
		$this->bdd = $this->conteneur->getBdd();
19
		$this->bddOsmNom = $this->conteneur->getParametre('bdd_osm_nom');
20
		$this->messages = $this->conteneur->getMessages();
21
		$this->mode = $this->conteneur->getParametre('m');
22
	}
23
 
24
	public function executer() {
25
		// Lancement de l'action demandée
26
		$cmd = $this->conteneur->getParametre('a');
27
		switch ($cmd) {
28
			case 'cm' :
29
				$this->creerTableOsmCommunes();
30
				break;
31
			case 'cmSupprimer' :
32
				$this->supprimerTableOsmCommunes();
33
				break;
34
			default :
35
				$this->messages->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
36
		}
37
 
38
	}
39
 
40
	private function supprimerTableOsmCommunes() {
41
		$requete = 'DROP TABLE IF EXISTS osm_communes '.
42
			' -- '.__FILE__.' : '.__LINE__;
43
		$this->bdd->requeter($requete);
44
	}
45
 
46
	private function creerTableOsmCommunes() {
47
		$requete = 'INSERT INTO osm_communes '.
48
			"SELECT osm_id, osm_version, osm_timestamp, name, ref_insee, shape, shape_centroid, wikipedia ".
49
			"FROM {$this->bddOsmNom}.multipolygons_ref ".
50
			"WHERE zone = 'france' AND admin_level = 8 ".
51
			' -- '.__FILE__.' : '.__LINE__;
52
		$this->bdd->requeter($requete);
53
	}
54
}