/** * accuracy page */ public function renderAccuracy() { if ($this->getHttpRequest()->getQuery("mac") != "" && $this->getHttpRequest()->getQuery("r_latitude") != "" && $this->getHttpRequest()->getQuery("r_longitude") != "" && MyUtils::isMacAddress($this->getHttpRequest()->getQuery("mac"))) { $mac = MyUtils::macSeparator2Colon($this->getHttpRequest()->getQuery("mac")); $tableData = $this->wifiManager->getDistanceFromOriginalGPS($mac, doubleval($this->getHttpRequest()->getQuery("r_latitude")), doubleval($this->getHttpRequest()->getQuery("r_longitude"))); $data = array(); foreach ($tableData as $td) { $coords = new Coords($td["latitude"], $this->getHttpRequest()->getQuery("r_latitude"), $td["longitude"], $this->getHttpRequest()->getQuery("r_longitude")); $inM = $coords->getDistanceInMetres(); $arr = $td; $arr["inM"] = $inM; $data[] = $arr; } usort($data, "self::Sort"); $chWigleMin = PHP_INT_MAX; $chWigleMax = 0; $chWigleTotal = 0; $chGoogleMin = PHP_INT_MAX; $chGoogleMax = 0; $chGoogleTotal = 0; $chWigleAvg = 0; $wigleCount = 0; $wifileaksCount = 0; $wifileaksTotal = 0; $googleCount = 0; foreach ($data as $d) { if ($d["id_source"] == WifileaksDownload::ID_SOURCE) { $wifileaksCount++; $wifileaksTotal += $d["inM"]; } if ($d["id_source"] == WigleDownload::ID_SOURCE) { $wigleCount++; if ($chWigleMin > $d["inM"]) { $chWigleMin = $d["inM"]; } if ($chWigleMax < $d["inM"]) { $chWigleMax = $d["inM"]; } $chWigleTotal += $d["inM"]; if ($d["calculated"] == 1) { $chWigleAvg = $d["inM"]; } } if ($d["id_source"] == GoogleDownload::ID_SOURCE) { $googleCount++; if ($chGoogleMin > $d["inM"]) { $chGoogleMin = $d["inM"]; } if ($chGoogleMax < $d["inM"]) { $chGoogleMax = $d["inM"]; } $chGoogleTotal += $d["inM"]; } } if ($chWigleAvg == 0) { $chWigleAvg = $chWigleTotal / $wigleCount; } $chGoogleAvg = $chGoogleTotal / $googleCount; $chWifileaks = $wifileaksTotal / $wifileaksCount; $this->template->chWifileaks = $chWifileaks; $this->template->chWigleMin = $chWigleMin; $this->template->chWigleMax = $chWigleMax; $this->template->chWigleAvg = $chWigleAvg; $this->template->chGoogleMin = $chGoogleMin; $this->template->chGoogleMax = $chGoogleMax; $this->template->chGoogleAvg = $chGoogleAvg; $this->template->table = $data; } }