Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 148 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 148 Rev 150
Line 17... Line 17...
17
 * @version		$Id$
17
 * @version		$Id$
18
 */
18
 */
19
class Lion1906 extends EfloreScript {
19
class Lion1906 extends EfloreScript {
Line 20... Line 20...
20
 
20
 
-
 
21
	public function executer() {
21
	public function executer() {
22
		try {
Line 22... Line 23...
22
		$this->initialiserProjet('lion1906');
23
			$this->initialiserProjet('lion1906');
23
 
24
 
24
		// Lancement de l'action demandée
25
			// Lancement de l'action demandée
25
		$cmd = $this->getParametre('a');
26
			$cmd = $this->getParametre('a');
26
	    switch ($cmd) {
27
			switch ($cmd) {
27
	    	case 'chargerTous' :
28
				case 'chargerTous' :
28
	    		$this->chargerStructureSql();
29
					$this->chargerStructureSql();
29
	    		$this->chargerMetaDonnees();
30
					$this->chargerMetaDonnees();
30
	    		$this->chargerLion1906();
31
					$this->chargerLion1906();
31
	    		$this->preparerTable();
32
					$this->preparerTable();
32
	    		$this->convertirRadianEnDegre();
33
					$this->convertirRadianEnDegre();
33
	    		break;
34
					break;
34
	    	case 'convertir' :
35
				case 'convertir' :
35
				$this->preparerTable();
36
					$this->preparerTable();
36
	    		$this->convertirRadianEnDegre();
37
					$this->convertirRadianEnDegre();
37
				break;
38
					break;
38
			case 'supprimerTous' :
39
				case 'supprimerTous' :
39
				$this->supprimerTous();
40
					$this->supprimerTous();
40
				break;
41
					break;
-
 
42
				default :
-
 
43
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
-
 
44
			}
41
			default :
45
		} catch (Exception $e) {
42
				$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
46
			$this->traiterErreur($e->getMessage());
-
 
47
		}
-
 
48
	}
-
 
49
 
-
 
50
	protected function chargerMetaDonnees() {
-
 
51
		$contenuSql = $this->recupererContenu(Config::get('chemins.lion1906Meta'));
Line 43... Line -...
43
		}
-
 
44
    }
-
 
45
 
-
 
46
    protected function chargerMetaDonnees() {
-
 
47
    	$contenuSql = $this->recupererContenu(Config::get('chemins.lion1906Meta'));
-
 
48
    	$this->executerScripSql($contenuSql);
52
		$this->executerScripSql($contenuSql);
49
    }
53
	}
50
 
54
 
51
    private function chargerLion1906() {
55
	private function chargerLion1906() {
52
    	$chemin = Config::get('chemins.lion1906');
56
		$chemin = Config::get('chemins.lion1906');
53
    	$table = Config::get('tables.lion1906');
57
		$table = Config::get('tables.lion1906');
54
    	$requete = "LOAD DATA INFILE '$chemin' ".
58
		$requete = "LOAD DATA INFILE '$chemin' ".
55
    				"REPLACE INTO TABLE $table ".
59
					"REPLACE INTO TABLE $table ".
56
    				'CHARACTER SET latin1 '.
60
					'CHARACTER SET latin1 '.
57
    				'FIELDS '.
61
					'FIELDS '.
58
    				"	TERMINATED BY ';' ".
62
					"	TERMINATED BY ';' ".
59
    				"	ENCLOSED BY '' ".
63
					"	ENCLOSED BY '' ".
60
    				"	ESCAPED BY '\\\' ".
64
					"	ESCAPED BY '\\\' ".
Line 61... Line 65...
61
    				'IGNORE 1 LINES';
65
					'IGNORE 1 LINES';
62
    	$this->getBdd()->requeter($requete);
66
		$this->getBdd()->requeter($requete);
63
    }
67
	}
64
 
68
 
Line 80... Line 84...
80
	}
84
	}
Line 81... Line 85...
81
 
85
 
82
	private function preparerTable() {
86
	private function preparerTable() {
83
		$table = Config::get('tables.lion1906');
87
		$table = Config::get('tables.lion1906');
84
		$requete = 	"ALTER TABLE $table ".
88
		$requete = 	"ALTER TABLE $table ".
85
  					'DROP latitude_degre, '.
89
					'DROP latitude_degre, '.
86
  					'DROP longitude_degre, '.
90
					'DROP longitude_degre, '.
87
  					'DROP centroide, '.
91
					'DROP centroide, '.
88
  					'DROP INDEX insee ';
92
					'DROP INDEX insee ';
Line 89... Line 93...
89
		$this->getBdd()->requeter($requete);
93
		$this->getBdd()->requeter($requete);
90
 
94
 
91
		$requete = 	"ALTER TABLE $table ".
95
		$requete = 	"ALTER TABLE $table ".
Line 102... Line 106...
102
	private function formerPointCentre($latitude_degre, $longitude_degre, $insee) {
106
	private function formerPointCentre($latitude_degre, $longitude_degre, $insee) {
103
		$centre = "$latitude_degre $longitude_degre" ;
107
		$centre = "$latitude_degre $longitude_degre" ;
104
		$table = Config::get('tables.lion1906');
108
		$table = Config::get('tables.lion1906');
105
		$requete = "UPDATE $table ".
109
		$requete = "UPDATE $table ".
106
					"SET latitude_degre = '$latitude_degre', longitude_degre = '$longitude_degre', ".
110
					"SET latitude_degre = '$latitude_degre', longitude_degre = '$longitude_degre', ".
107
        			"	centroide = POINTFROMTEXT('POINT($centre)') ".
111
					"	centroide = POINTFROMTEXT('POINT($centre)') ".
108
        			"WHERE insee = '$insee' ";
112
					"WHERE insee = '$insee' ";
109
		$this->getBdd()->requeter($requete);
113
		$this->getBdd()->requeter($requete);
110
	}
114
	}
Line 111... Line 115...
111
 
115
 
112
	private function supprimerTous() {
116
	private function supprimerTous() {