Subversion Repositories Sites.obs-saisons.fr

Rev

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

Rev 193 Rev 207
Line 64... Line 64...
64
		$infos_communes_formatees = $this->formaterTableauInformationsCommunePourEnvoi($infos_communes);   	
64
		$infos_communes_formatees = $this->formaterTableauInformationsCommunePourEnvoi($infos_communes);   	
Line 65... Line 65...
65
    	
65
    	
66
    	return $infos_communes_formatees;
66
    	return $infos_communes_formatees;
Line -... Line 67...
-
 
67
    }
-
 
68
    
-
 
69
    private function getEstUneCommunePhenoclim() {
-
 
70
    	return $this->estUneCommunePhenoclim($_GET);
-
 
71
    }
-
 
72
    
-
 
73
    private function estUneCommunePhenoclim($params) {
-
 
74
    	
-
 
75
    	$code_insee = null;
-
 
76
    	$code_postal = null;
-
 
77
    	
-
 
78
    	if(!isset($params['code_postal']) && !isset($params['code_insee'])) {
-
 
79
    		return false;
-
 
80
    	}
-
 
81
    	
-
 
82
    	if(isset($params['code_postal'])) {
-
 
83
    		$code_postal = $params['code_postal'];
-
 
84
    	}
-
 
85
    	
-
 
86
    	if(isset($params['code_insee'])) {
-
 
87
    		$code_insee = $params['code_insee'];
-
 
88
    	}
-
 
89
    	
-
 
90
    	if($code_postal != null) {
-
 
91
    		$requete_commune_phenoclim = 'SELECT occ_code_insee FROM ods_communes_crea WHERE occ_code_postal = '.$this->proteger($code_postal);
-
 
92
    	} else {
-
 
93
    		$requete_commune_phenoclim = 'SELECT occ_code_insee FROM ods_communes_crea WHERE occ_code_insee = '.$this->proteger($code_insee);
-
 
94
    	}
-
 
95
    	
-
 
96
    	$resultat_requete_phenoclim = $this->executerRequete($requete_commune_phenoclim);
-
 
97
    	
-
 
98
    	if(!empty($resultat_requete_phenoclim)) {
-
 
99
    		return true;
-
 
100
    	} 
-
 
101
    	
-
 
102
    	return false;
67
    }
103
    }
68
    
104
    
69
    private function remplacerNomCommunePourRecherche($nom) {
105
    private function remplacerNomCommunePourRecherche($nom) {
70
    	$nom = str_replace(' ','_',$nom);
106
    	$nom = str_replace(' ','_',$nom);
Line 90... Line 126...
90
    	
126
    	
91
    	$cp_recherche = $dpt;
127
    	$cp_recherche = $dpt;
92
		if(strlen($cp_recherche) == 4) {
128
		if(strlen($cp_recherche) == 4) {
93
			$cp_recherche = '0'.$cp_recherche;
129
			$cp_recherche = '0'.$cp_recherche;
-
 
130
		}
-
 
131
		
Line 94... Line 132...
94
		}
132
		$commune_phenoclim = $this->estUneCommunePhenoclim(array('code_postal' => $cp_recherche));
Line 95... Line 133...
95
 
133
 
96
		$cp_recherche = substr($cp_recherche,0,2);
134
		$cp_recherche = substr($cp_recherche,0,2);
97
    	
135
    	
98
		$code_insee = '';
136
		$code_insee = '';
Line 99... Line 137...
99
		if($commune != null) {
137
		if($commune != null) {
100
    		$code_insee = $this->obtenirCodeInseeCommune($commune, $cp_recherche);
138
    		$code_insee = $this->obtenirCodeInseeCommune($commune, $cp_recherche);
101
		}
139
		}
102
    	
140
    	
103
    	return array( 
141
    	$infos_communes = array( 
104
    	    'commune' => $commune,
142
    	    'commune' => $commune,
105
    		'dpt' => $dpt,
143
    		'dpt' => $dpt,
-
 
144
            'lat' => $lat,
106
            'lat' => $lat,
145
            'lon' => $lon,
-
 
146
            'alt' => $altitude,
-
 
147
    		'code_insee' => $code_insee,
Line 107... Line 148...
107
            'lon' => $lon,
148
    		'commune_phenoclim' => $commune_phenoclim
Line 108... Line 149...
108
            'alt' => $altitude,
149
        );
Line 127... Line 168...
127
			
168
			
128
			if($limite == 1) {
169
			if($limite == 1) {
129
				$dpt = '0'.$dpt;
170
				$dpt = '0'.$dpt;
Line -... Line 171...
-
 
171
			}
-
 
172
			
130
			}
173
			$commune_phenoclim = $this->estUneCommunePhenoclim(array('code_insee' => $commune['oc_code_insee']));
131
			
174
			
132
			$infos_formatees[] = array(
175
			$infos_formatees[] = array(
133
    			'commune' => $commune['oc_nom'],
-
 
134
    			'dpt' => $dpt,
176
    			'commune' => $commune['oc_nom'],
135
			    'code_insee' => $commune['oc_code_insee'],
177
    			'dpt' => $dpt,
-
 
178
    			'lat' => $commune['oc_latitude'],
-
 
179
				'lon' => $commune['oc_longitude'],
-
 
180
			    'alt' => $commune['oc_altitude'],
136
    			'lat' => $commune['oc_latitude'],
181
				'code_insee' => $commune['oc_code_insee'],
137
				'lon' => $commune['oc_longitude']
182
				'commune_phenoclim' => $commune_phenoclim
138
    		);
183
    		);
139
		}
184
		}
Line -... Line 185...
-
 
185
    	return $infos_formatees;
-
 
186
    }
-
 
187
    
-
 
188
	public function obtenirNomCommuneParCodeInsee($code_insee_commune) {
-
 
189
		
-
 
190
		if(!is_numeric($code_insee_commune)) {
-
 
191
			return '';
-
 
192
		}
-
 
193
    	
-
 
194
    	$requete_infos_commune = 'SELECT * FROM ods_communes WHERE oc_code_insee = '.$this->proteger($code_insee_commune);
-
 
195
    	$infos_commune = $this->executerRequete($requete_infos_commune);
140
    	return $infos_formatees;
196
		return $infos_commune[0]['oc_nom'];
Line 141... Line 197...
141
    }
197
    }
142
    
198
    
143
    private function obtenirCodeInseeCommune($commune, $cp) {
199
    private function obtenirCodeInseeCommune($commune, $cp) {