Пример #1
0
 /**
  * recursively search whole array and create array from each quads
  *
  * @param array $nestedCoords nested array -> nesting = quad segmentation
  */
 private function iterateArray($nestedCoords)
 {
     foreach ($nestedCoords as $c) {
         if (is_array($c) && !ArrayUtil::isAssoc($c)) {
             $this->iterateArray($c);
         } else {
             $this->generatedCoords[] = $c;
         }
     }
 }
Пример #2
0
 /**
  * @param float $lat1
  * @param float $lat2
  * @param float $lon1
  * @param float $lon2
  * @param int $sourceDownloadFrom
  * @throws \Nette\Application\AbortException
  */
 public function renderTime2down($lat1, $lat2, $lon1, $lon2, $sourceDownloadFrom)
 {
     $coords = new Coords($lat1, $lat2, $lon1, $lon2);
     $sourceDownloadFrom = (int) $sourceDownloadFrom;
     $request = $this->getHttpRequest();
     $filter = $request->getQuery("filter");
     $filterSet = ArrayUtil::arrayHasSomeKey($filter, array("ssidmac", "channel", "source", "security", "ssid"));
     if ($filterSet) {
         $text = "<strong>Máte nastavený filtr, vytvoří se požadavek přímo na vyfiltrované body</strong><br />";
         $mode = isset($filter["mode"]) ? $filter["mode"] : WifiPresenter::MODE_ALL;
         $params = $this->getParamsArray($coords, $mode, $filter);
         $nets = $this->oWifiManager->getNetsByParams($params, array('id,mac'));
         $netsCount = count($nets);
         $macAddresses = array();
         foreach ($nets as $net) {
             $macAddresses[$net['mac']] = $net;
         }
         $beforeMinutes = 0;
         $afterMinutes = 0;
         switch ($sourceDownloadFrom) {
             case Service\WigleDownload::ID_SOURCE:
                 $beforeMinutes = $this->wigleDownload->getWigleApsCount(2) * Service\BaseService::CRON_TIME_DOWNLOAD_WIGLE_OBSERVATIONS;
                 $afterMinutes = count($macAddresses) * Service\BaseService::CRON_TIME_DOWNLOAD_WIGLE_OBSERVATIONS;
                 break;
             case Service\GoogleDownload::ID_SOURCE:
                 $beforeMinutes = $this->wigleDownload->getWigleApsCount(2) * Service\BaseService::CRON_TIME_DOWNLOAD_WIGLE_OBSERVATIONS + $this->googleDownload->getGoogleRequestsCount(2) * Service\BaseService::CRON_TIME_DOWNLOAD_GOOGLE;
                 $afterMinutes = count($macAddresses) * Service\BaseService::CRON_TIME_DOWNLOAD_WIGLE_OBSERVATIONS + count($macAddresses) * Service\BaseService::CRON_TIME_DOWNLOAD_GOOGLE;
                 break;
         }
         $hodin1 = floor($beforeMinutes / 60);
         $minut1 = $beforeMinutes - $hodin1 * 60;
         $hodin2 = floor($afterMinutes / 60);
         $minut2 = $afterMinutes - $hodin2 * 60;
         $celkemHodin = $hodin1 + $hodin2;
         $celkemMinut = $minut1 + $minut2;
         $celkemHodin += floor($celkemMinut / 60);
         $celkemMinut = $celkemMinut - floor($celkemMinut / 60) * 60;
         $text .= "Vyfiltrovaných sítí je " . $netsCount . ".<br />";
         if ($netsCount > 0) {
             $text .= "Získání dat bude trvat<br /><strong>";
             if ($hodin2 > 0) {
                 $text .= $hodin2 . "hodin";
             }
             if ($hodin2 > 0 && $minut2 > 0) {
                 $text .= " a ";
             }
             if ($minut2 > 0) {
                 $text .= $minut2 . "minut";
             }
             if ($hodin1 > 0 || $minut1 > 0) {
                 $text .= "<br /> + ";
             }
             if ($hodin1 > 0) {
                 $text .= $hodin1 . "hodin";
             }
             if ($hodin1 > 0 && $minut1 > 0) {
                 $text .= " a ";
             }
             if ($minut1 > 0) {
                 $text .= $minut1 . "minut";
             }
             $text .= "</strong><br />celkem: <strong>";
             if ($celkemHodin > 0) {
                 $text .= $celkemHodin . " hodin";
             }
             if ($celkemHodin > 0 && $celkemMinut > 0) {
                 $text .= " a ";
             }
             if ($celkemMinut > 0) {
                 $text .= $celkemMinut . " minut";
             }
             $text .= "</strong>";
         }
         if ($netsCount == 0) {
             echo "\$('#createDownloadRequest').hide();";
         } else {
             echo "\$('#createDownloadRequest').show();";
         }
         if ($celkemHodin > self::MAX_HOURS_FILTERED_REQUEST) {
             echo "\$('#createDownloadRequest').hide();";
         } else {
             echo "\$('#createDownloadRequest').show();";
         }
         $text .= '<br /><label for="notify_email">Až budou data získana informujte mě na email:</label><input type="email" name="notify_email" id="notify_email" ' . (isset($_COOKIE['notify_email']) ? 'value="' . $_COOKIE['notify_email'] . '"' : '') . ' />';
         echo "\$('#time2down').html('" . $text . "');";
     }
     $this->terminate();
 }