public function crawl()
 {
     $logger = Logger::getInstance();
     $logger->setUsername(null);
     $post_dao = DAOFactory::getDAO('PostDAO');
     $crawler = new GeoEncoderCrawler();
     $posts_to_geoencode = $post_dao->getPostsToGeoencode(2000);
     $logger->logUserInfo("There are " . count($posts_to_geoencode) . " posts to geoencode.", __METHOD__ . ',' . __LINE__);
     foreach ($posts_to_geoencode as $post_data) {
         if ($post_data['geo'] != '') {
             $crawler->performReverseGeoencoding($post_dao, $post_data);
         } else {
             $crawler->performGeoencoding($post_dao, $post_data);
         }
     }
     $logger->logUserSuccess("Post geoencoding complete.", __METHOD__ . ',' . __LINE__);
 }
 public function crawl()
 {
     $logger = Logger::getInstance();
     $pdao = DAOFactory::getDAO('PostDAO');
     $crawler = new GeoEncoderCrawler();
     $posts_to_geoencode = $pdao->getPostsToGeoencode(2000);
     $logger->logStatus(count($posts_to_geoencode) . " posts to geoencode", "GeoEncoder Plugin");
     foreach ($posts_to_geoencode as $post_data) {
         if ($post_data['geo'] != '') {
             $crawler->performReverseGeoencoding($pdao, $post_data);
         } else {
             $crawler->performGeoencoding($pdao, $post_data);
         }
     }
     $logger->logStatus("Geoencoding posts complete", "GeoEncoderPlugin");
     $logger->close();
     # Close logging
 }
 public function crawl()
 {
     $logger = Logger::getInstance();
     $logger->setUsername(null);
     $post_dao = DAOFactory::getDAO('PostDAO');
     $crawler = new GeoEncoderCrawler();
     $posts_to_geoencode = $post_dao->getPostsToGeoencode(2000);
     $logger->logUserSuccess("Starting to collect lat/long points for " . count($posts_to_geoencode) . " posts.", __METHOD__ . ',' . __LINE__);
     $total_api_requests_fulfilled = 0;
     foreach ($posts_to_geoencode as $post_data) {
         if ($post_data['geo'] != '') {
             if ($crawler->performReverseGeoencoding($post_dao, $post_data)) {
                 $total_api_requests_fulfilled++;
             }
         } else {
             if ($crawler->performGeoencoding($post_dao, $post_data)) {
                 $total_api_requests_fulfilled++;
             }
         }
     }
     $logger->logUserSuccess("Post geoencoding complete. " . $total_api_requests_fulfilled . " API requests fulfilled successfully.", __METHOD__ . ',' . __LINE__);
 }
 /**
  * Method to Update post if validation of geo-location data of post results in failure
  * @param PostDAO $post_dao
  * @param int $post_id
  * @param str $network
  * @param str $is_geo_encoded
  * @return NULL
  */
 public function failedToGeoencode($post_dao, $post_id, $network, $is_geo_encoded)
 {
     switch ($is_geo_encoded) {
         case 'ZERO_RESULTS':
             $post_dao->setGeoencodedPost($post_id, $network, self::ZERO_RESULTS);
             break;
         case 'OVER_QUERY_LIMIT':
             self::$is_api_available = false;
             $post_dao->setGeoencodedPost($post_id, $network, self::OVER_QUERY_LIMIT);
             break;
         case 'REQUEST_DENIED':
             $post_dao->setGeoencodedPost($post_id, $network, self::REQUEST_DENIED);
             break;
         case 'INVALID_REQUEST':
             $post_dao->setGeoencodedPost($post_id, $network, self::INVALID_REQUEST);
     }
 }
 /**
  * Method to Update post if validation of geo-location data of post results in failure
  * @var PostDAO $pdao
  * @var int $post_id
  * @var string $is_geo_encoded
  * @return NULL
  */
 public function failedToGeoencode($pdao, $post_id, $is_geo_encoded) {
     switch ($is_geo_encoded) {
         case 'ZERO_RESULTS':
             $pdao->setGeoencodedPost($post_id, self::ZERO_RESULTS);
             break;
         case 'OVER_QUERY_LIMIT':
             self::$is_api_available = false;
             $pdao->setGeoencodedPost($post_id, self::OVER_QUERY_LIMIT);
             $logger = Logger::getInstance();
             $logger->logUserError('Reached Google Maps\' query limit for now.', __METHOD__.','.__LINE__);
             break;
         case 'REQUEST_DENIED':
             $pdao->setGeoencodedPost($post_id, self::REQUEST_DENIED);
             break;
         case 'INVALID_REQUEST':
             $pdao->setGeoencodedPost($post_id, self::INVALID_REQUEST);
     }
 }