Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 1064 Rev 1066
Line 30... Line 30...
30
	private $parametres = array();
30
	private $parametres = array();
31
	private $bdd = null;
31
	private $bdd = null;
Line 32... Line 32...
32
 
32
 
33
	private $lat = null;
33
	private $lat = null;
-
 
34
	private $lon = null;
Line 34... Line 35...
34
	private $lon = null;
35
	private $zone = null;
35
 
36
 
36
	public function __construct(Bdd $bdd) {
37
	public function __construct(Bdd $bdd) {
Line 37... Line 38...
37
		$this->bdd = $bdd;
38
		$this->bdd = $bdd;
38
	}
39
	}
39
 
40
 
40
	public function consulter($ressources, $parametres) {
41
	public function consulter($ressources, $parametres) {
41
		$this->parametres = $parametres;
42
		$this->parametres = $parametres;
-
 
43
		$this->verifierParametres();
Line 42... Line 44...
42
		$this->verifierParametres();
44
		$this->lat = $this->parametres['lat'];
43
		$this->lat = $this->parametres['lat'];
45
		$this->lon = $this->parametres['lon'];
Line 44... Line 46...
44
		$this->lon = $this->parametres['lon'];
46
		$this->zone = isset($this->parametres['zone']) ? $this->parametres['zone'] : null;
Line 90... Line 92...
90
		return $retour;
92
		return $retour;
91
	}
93
	}
Line 92... Line 94...
92
 
94
 
93
	private function localiserPointLatLon() {
95
	private function localiserPointLatLon() {
-
 
96
		$osmIdsInClause = $this->getOsmIdsDesCentresAProximites();
Line 94... Line 97...
94
		$osmIdsInClause = $this->getOsmIdsDesCentresAProximites();
97
		$zone = isset($this->zone) ? $this->bdd->proteger($this->zone) : null;
95
 
98
 
96
		$requete = 'SELECT id_zone_geo AS codeZoneGeo, intitule, code_iso_3166_1 AS codeIso31661, '.
99
		$requete = 'SELECT id_zone_geo AS codeZoneGeo, intitule, code_iso_3166_1 AS codeIso31661, '.
97
			'code_iso_3166_2 AS codeIso31662, code_insee AS codeInsee, code_nuts as codeNuts, '.
100
			'code_iso_3166_2 AS codeIso31662, code_insee AS codeInsee, code_nuts as codeNuts, '.
98
			'nom_en AS nomEn, nom_es AS nomEs, wikipedia, niveau '.
101
			'nom_en AS nomEn, nom_es AS nomEs, wikipedia, niveau '.
-
 
102
			'FROM osm_zones_admin '.
99
			'FROM osm_zones_admin '.
103
			"WHERE st_within(GEOMFROMTEXT('POINT($this->lon $this->lat)'), polygone) = 1 ".
100
			"WHERE st_within(GEOMFROMTEXT('POINT($this->lon $this->lat)'), polygone) = 1 ".
104
			(isset($zone) ? "AND zone = $zone " : '').
101
			"AND osm_id IN ($osmIdsInClause) ".
105
			"AND osm_id IN ($osmIdsInClause) ".
102
			' -- '.__FILE__.' : '.__LINE__;
106
			' -- '.__FILE__.' : '.__LINE__;
103
		$resultat = $this->bdd->recupererTous($requete);
107
		$resultat = $this->bdd->recupererTous($requete);
Line 124... Line 128...
124
		$osmIdsInClause = implode(',', $this->bdd->proteger($osmIds));
128
		$osmIdsInClause = implode(',', $this->bdd->proteger($osmIds));
125
		return $osmIdsInClause;
129
		return $osmIdsInClause;
126
	}
130
	}
Line 127... Line 131...
127
 
131
 
-
 
132
	private function construireRequeteUnion() {
128
	private function construireRequeteUnion() {
133
		$zone = isset($this->zone) ? $this->bdd->proteger($this->zone) : null;
129
		$requeteTpl = 'SELECT osm_id, '.
134
		$requeteTpl = 'SELECT osm_id, '.
130
			"(($this->lon - centre_lng) * ($this->lon -centre_lng) + ($this->lat - centre_lat) * ($this->lat - centre_lat)) AS distance ".
135
			"(($this->lon - centre_lng) * ($this->lon -centre_lng) + ($this->lat - centre_lat) * ($this->lat - centre_lat)) AS distance ".
131
			'FROM osm_zones_admin '.
136
			'FROM osm_zones_admin '.
-
 
137
			'WHERE niveau = %s '.
132
			'WHERE niveau = %s '.
138
			(isset($zone) ? "AND zone = $zone " : '').
133
			'ORDER BY distance ASC '.
139
			'ORDER BY distance ASC '.
134
			"LIMIT %s ";
140
			"LIMIT %s ";
135
		$niveaux = array(2,3,4,5,6,7,8);
141
		$niveaux = array(2,3,4,5,6,7,8);
136
		$requetesAUnir = array();
142
		$requetesAUnir = array();