Subversion Repository Public Repository

Nextrek

Diff Revisions 593 vs 604 for /Android/SmartCharging/endPoints/repositories/LocalRepository.php

Diff revisions: vs.
  @@ -326,15 +326,21 @@
326 326 public function getCloseLocals($tipologia, $lat, $lon, $distance) {
327 327 $local_list = array();
328 328
329 + $harvesinFormulaSQL;
330 +
329 331 $whereClause = ($tipologia>=0) ? "WHERE tipologia='".$tipologia."'" : "";
330 332
331 - $harvesinFormulaSQL = "SELECT id, id_utente_owner, lat, lon, indirizzo, tipologia, nomelocale, telefono, email, sito, n_punti_ricarica,
333 + if ($lat==="" || $lon==="") {
334 + $harvesinFormulaSQL = "SELECT * FROM locale";
335 + } else {
336 + $harvesinFormulaSQL = "SELECT id, id_utente_owner, lat, lon, indirizzo, tipologia, nomelocale, telefono, email, sito, n_punti_ricarica,
332 337 ( 6371 * acos( cos( radians(".$lat.") ) * cos( radians( lat ) ) * cos( radians( lon ) - radians(".$lon.") ) + sin( radians(".$lat.") ) * sin( radians( lat ) ) ) ) AS distance
333 338 FROM locale
334 339 ".$whereClause."
335 340 HAVING distance < ".$distance/1000.0."
336 341 ORDER BY distance";
337 342 //ORDER BY distance LIMIT 0 , 20"; //nel caso in cui si voglia introdurre il limite di locali vicini
343 + }
338 344
339 345 //echo "<br/>".$harvesinFormulaSQL."<br/>";
340 346