/**
  * can handle queries of:
  *  - x and y
  */
 public function getListAction()
 {
     $neighborhood_id = $this->params()->fromRoute('neighborhood_id');
     $neighborhood = $this->m()->neighborhood()->byId($neighborhood_id);
     $heatmap_points = $this->m()->heatMapPoint()->byNeighborhood($neighborhood);
     return new JsonModel(HeatMapPoint::pointsToArray($heatmap_points));
 }
 public function heatMapPointsByNeighborhood(Neighborhood $neighborhood)
 {
     $heatmap_point_elections = array();
     $peakNumForPoints = $this->getPeakNumUserNeighborhoods($neighborhood);
     foreach ($this->getPointElections() as $ep) {
         $cn = $ep->candidateNeighborhood($neighborhood);
         $percentage = $cn->getNumVotes() / $peakNumForPoints;
         array_push($heatmap_point_elections, HeatMapPoint::build(array('neighborhood' => $neighborhood, 'electionPoint' => $ep, 'point' => $ep->getPoint(), 'percentage' => $percentage)));
     }
     return $heatmap_point_elections;
 }
Exemple #3
0
 public static function build(array $array)
 {
     $hmp = new HeatMapPoint($array);
     $hmp->setCreatedAt(new \DateTime());
     return $hmp;
 }