Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 2454 → Rev 2455

/trunk/jrest/services/CelRadiusPoints.php
1,10 → 1,16
<?php
class CelRadiusPoints extends Cel {
private $champs = array("id_observation", "nom_sel", "latitude", "longitude", "COUNT(id_observation) as nb_obs");
private $champs_min = array("latitude", "longitude");
private $champs_mode = null;
/**
* Méthode appelée avec une requête de type GET.
*/
public function getRessource() {
public function getRessource() {
$this->champs_mode = $this->champs_min;
return $this->getElement(array());
}
29,7 → 35,7
 
public function obtenirPointsPourCentreEtRadius($lat_centre, $lon_centre, $radius) {
$requete = "SELECT ".
"id_observation, nom_sel, latitude, longitude, COUNT(id_observation) as nb_obs ".
implode(", ", $this->champs_mode)." ".
"FROM cel_obs ".
"WHERE latitude != 0 AND longitude != 0 ".
"AND ".$this->renvoyerDistanceSql($lat_centre, $lon_centre)." < ".$radius." ".
54,15 → 60,15
}
public function obtenirPointPlusProche($lat_centre, $lon_centre) {
// TODO: faire moins moche et plus efficace
$requete = "SELECT ".
"id_observation, nom_sel, ".$this->renvoyerDistanceSql($lat_centre, $lon_centre)." AS distance, ".
"latitude, longitude, COUNT(id_observation) as nb_obs ".
implode(", ", $this->champs_mode).", ".$this->renvoyerDistanceSql($lat_centre, $lon_centre)." AS distance ".
"FROM cel_obs ".
"WHERE latitude != 0 AND longitude != 0 ".
"GROUP BY latitude, longitude ".
"HAVING distance = MIN(distance) ".
"ORDER BY distance ";
"ORDER BY distance ".
"LIMIT 1";
 
$point = Cel::db()->requeterLigne($requete);
return $point;
}