public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) $this->_identifier["id"];
     }
     $this->__load();
     return parent::getId();
 }
 /**
  * take the user polygons, run a point election, and save the points in the db
  **/
 public function buildAndSaveHeatmapPoints($user_polygons, Neighborhood $n, $grid_resolution)
 {
     $timer = Timer::start("heatmap_builder");
     $electionCollection = $this->m()->pointElectionMapper()->getCollection($user_polygons, $n->getId(), $grid_resolution);
     $heatmap_points = $electionCollection->heatMapPointsByNeighborhood($n);
     if (!empty($heatmap_points)) {
         $this->m()->heatMapPoint()->deleteByNeighborhood($n);
         $this->m()->heatMapPoint()->savePoints($heatmap_points);
         $this->m()->heatMapPoint()->detach($heatmap_points);
         $this->infoLog(sprintf("saved %s heatmap points from %s points elapsed=%s", count($heatmap_points), count($electionCollection->getPointElections()), $timer->elapsedReadableString()));
     } else {
         $this->infoLog("\t\tno heatmap_points generated to save");
     }
     return $heatmap_points;
 }
 public function createByNeighborhoodQuery(Neighborhood $neighborhood)
 {
     $dql = "SELECT up FROM Whathood\\Entity\\UserPolygon up\n            WHERE up.neighborhood = :neighborhood ORDER BY up.id ASC";
     return $this->em->createQuery($dql)->setParameter(':neighborhood', $neighborhood->getId());
 }
 /**
  * @description returns all the NeighborhoodBoundary objects associated with the given neighborhood
  *
  * @return array - an array of NeighborhoodBoundary entities
  */
 public function byNeighborhood(Neighborhood $neighborhood)
 {
     $dql = "SELECT np FROM Whathood\\Entity\\NeighborhoodBoundary np\n            WHERE np.neighborhood = :neighborhood";
     $query = $this->em->createQuery($dql)->setParameter(':neighborhood', $neighborhood->getId());
     return $query->getResult();
 }
 public function __invoke(Neighborhood $n)
 {
     $url = $this->root . '?id=' . $n->getId();
     return $url;
 }
Example #6
0
 public function isWinner(Neighborhood $neighborhood)
 {
     foreach ($this->getWinningCandidates() as $cn) {
         if ($neighborhood->getId() == $cn->getNeighborhood()->getId()) {
             return true;
         }
     }
     return false;
 }
Example #7
0
 public function deleteByNeighborhood(Neighborhood $neighborhood)
 {
     $sql = "DELETE FROM Whathood\\Entity\\HeatMapPoint hmp WHERE hmp.neighborhood = :neighborhood_id";
     $this->em->createQuery($sql)->setParameter(':neighborhood_id', $neighborhood->getId())->execute();
 }