Exemplo n.º 1
0
 public function radarConcatTypesInOne($queryData)
 {
     // String for request
     $this->gSearchURL .= $queryData->{'geometry'}->{'location'}->{'lat'} . "," . $queryData->{'geometry'}->{'location'}->{'lng'} . "&radius=1500" . "&types=" . $queryData->{'types'}[0] . "|" . $queryData->{'types'}[8] . "|" . $queryData->{'types'}[12] . "|" . $queryData->{'types'}[13] . "|" . $queryData->{'types'}[16] . "|";
     $this->gSearchURL = addAPIkey($this->gSearchURL);
     $info = json_decode(file_get_contents($this->gSearchURL));
     foreach ($info->results as $poi) {
         array_push($this->pois, $poi);
     }
     echo ControlFunctions::tagIt("h2", "<span style=\"font-family: monospace;\">radarConcatTypesInOne()</span><br />" . "Radar Anfrage für meherere Types in einer Anfrage: <span style=\"color: blue;\">" . $queryData->{'types'}[0] . ", " . $queryData->{'types'}[8] . ", " . $queryData->{'types'}[12] . ", " . $queryData->{'types'}[13] . ", " . $queryData->{'types'}[16] . ", " . "</span> Query " . $this->gSearchURL);
     echo ControlFunctions::tagIt("h3", "Einträge: <b>" . count($this->pois) . "</b>");
     $fpois = ControlFunctions::checkDuplicatePID($this->pois);
     echo ControlFunctions::tagIt("h3", "Gefilterte Einträge: <b>" . count($fpois) . "</b>");
     ControlFunctions::formatResultArray($fpois);
     ControlFunctions::forDebug($fpois, "Gefilterte Pois");
 }
Exemplo n.º 2
0
 public function getData($maxRandValues = 5)
 {
     global $secKeys;
     // Conect to DB an get the
     try {
         DataBase::connect('localhost', $secKeys->cakeVars->{'dbUsr'}, $secKeys->cakeVars->{'dbPw'}, $secKeys->cakeVars->{'dbCake'});
         // Get pois
         $sql = "SELECT * FROM pois";
         $this->pois = DataBase::fire($sql);
         // Get components
         $sql = "SELECT * FROM components";
         $this->components = DataBase::fire($sql);
         DataBase::close();
     } catch (Exception $e) {
         die('Fehler bei .... Fehler: ' . $e->getMessage());
     }
     $this->createRandStages($this->pois, $this->components, $maxRandValues);
     echo ControlFunctions::tagIt("h1", "Es wurden: " . $this->savedStagesCount . " Stages gespeichert");
 }
Exemplo n.º 3
0
 public function callAddToken($nextPageToken)
 {
     $gAddSearchURL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?pagetoken=" . $nextPageToken;
     $gAddSearchURL = addAPIkey($gAddSearchURL);
     // Wait 1 second, because next page token must be valid at google first!
     usleep(1000000);
     $addInfo = json_decode(file_get_contents($gAddSearchURL));
     // Check if request with next_page_token result is OK
     if ($addInfo->status != "INVALID_REQUEST") {
         // if not INVALID -> Save Data
         foreach ($addInfo->results as $poi) {
             array_push($this->pois, $poi);
         }
         echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\">Zusätzliche Suchergebnisseite <span style=\"color: green;\">gespeichert</span></span>");
         // Check if another next_page_token is set
         if (isset($addInfo->next_page_token)) {
             echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\"><span style=\"color: orange;\">Weiteren Next Page Token gefunden. Call again callAddToken()</span></span>");
             $anotherNextPageToken = $addInfo->next_page_token;
             // unset($GLOBALS['addInfo']);
             $this->callAddToken($anotherNextPageToken);
         } else {
             echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\"><span style=\"color: green\">Crawled all pages</span>: No Next Page Token left!</span>");
         }
     } else {
         echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\"><span style=\"color: red;\">Next Page Token not yet valid!</span> <span style=\"color: orange;\">Start recall callAddToken()</span></span>");
         $this->callAddToken($nextPageToken);
     }
 }
Exemplo n.º 4
0
 public function saveToDB($filterdQueryData)
 {
     global $secKeys;
     ControlFunctions::forDebug($filterdQueryData, "Gefilterte Pois");
     // for ($i = 0; $i < 5; $i++) {
     for ($i = 0; $i < count($filterdQueryData); $i++) {
         $now = date("Y-m-d H:i:s");
         try {
             DataBase::connect('localhost', $secKeys->cakeVars->{'dbUsr'}, $secKeys->cakeVars->{'dbPw'}, $secKeys->cakeVars->{'dbCake'});
             $sql = "INSERT INTO pois (created, modified, name, lat, lng, google_place, icon, rating, vicinity) VALUES (:tstamp, :tstamp, :name, :lat, :lng, :google_place, :icon, :rating, :vicinity)";
             $para = array('tstamp' => $now, 'name' => $filterdQueryData[$i]->name, 'lat' => $filterdQueryData[$i]->geometry->location->lat, 'lng' => $filterdQueryData[$i]->geometry->location->lng, 'google_place' => $filterdQueryData[$i]->place_id, 'icon' => $filterdQueryData[$i]->icon, 'rating' => isset($filterdQueryData[$i]->rating) ? $filterdQueryData[$i]->rating : null, 'vicinity' => $filterdQueryData[$i]->vicinity);
             DataBase::fire($sql, $para);
             $lastPoisId = DataBase::lastInsertId();
             echo ControlFunctions::tagIt("h1", "Letzter Eintrag: " . $lastPoisId);
             foreach ($filterdQueryData[$i]->types as $tag) {
                 $tagId = null;
                 // Check if tag is already present
                 $sql = "SELECT EXISTS(SELECT 1 FROM tags WHERE title LIKE '%" . $tag . "%')";
                 $rows = DataBase::fire($sql);
                 $tagPresent = current(current($rows)) == "1" ? true : false;
                 ControlFunctions::forDebug($rows, "Ausgabe für Tag {$tag}");
                 echo $tagPresent ? "Wert für {$tag} ist: vorhanden" : "Wert für {$tag} ist: Nicht existent!";
                 if ($tagPresent) {
                     $sql = "SELECT id FROM tags WHERE title LIKE '%" . $tag . "%'";
                     $rows = DataBase::fire($sql);
                     $tagId = current(current($rows));
                     ControlFunctions::forDebug($rows, "Ausgabe für Tag {$tag}, tag ID: ");
                     echo ControlFunctions::tagIt("h1", "{$tag} ID: {$tagId}");
                 } else {
                     // Paste Tag
                     $sql = "INSERT INTO tags (title, created, modified) VALUES (:title, :tstamp, :tstamp)";
                     $para = array('title' => $tag, 'tstamp' => $now);
                     DataBase::fire($sql, $para);
                     // Save ID
                     $tagId = DataBase::lastInsertId();
                 }
                 // Paste Relation
                 $sql = "INSERT INTO pois_tags (poi_id, tag_id) VALUES (:poi_id, :tag_id)";
                 $para = array('poi_id' => $lastPoisId, 'tag_id' => $tagId);
                 DataBase::fire($sql, $para);
                 echo ControlFunctions::tagIt("h1", "Letzter Eintrag: " . DataBase::lastInsertId());
             }
             DataBase::close();
         } catch (Exception $e) {
             die('Fehler bei .... Fehler: ' . $e->getMessage());
         }
     }
 }