/**
  * @api {get} /neighborhood-border/debug-build/:region/:neighborhood/:grid_resolution
  *
  * @apiName getBorderDebugBuild
  * @apiGroup NeighborhoodBoundary
  *
  * @apiParam {String} regionName the name of the region
  * @apiParam {String} neighborhoodName the name of the neighborhood
  * @apiParam {String} gridResolution the desired grid resolution
  *
  * @apiSuccess {Object} boundary - the boundary geometry
  * @apiSuccess {Array} neighborhood election points
  */
 public function debugBuildAction()
 {
     $neighborhood_name = $this->getRequestParameter('neighborhood');
     $region_name = $this->getRequestParameter('region');
     $grid_resolution = $this->getRequestParameter('grid_res');
     if (empty($neighborhood_name)) {
         throw new \InvalidArgumentException("neighborhood must be defined");
     }
     if (empty($grid_resolution)) {
         throw new \InvalidArgumentException("grid_res must be defined");
     }
     $neighborhood = $this->m()->neighborhoodMapper()->byName($neighborhood_name, $region_name);
     $userPolygons = $this->m()->userPolygonMapper()->byNeighborhood($neighborhood);
     $pointElectionCollection = $this->m()->pointElectionMapper()->getCollection($userPolygons, $neighborhood->getId(), $grid_resolution);
     $neighborhoodWinningPointElections = $pointElectionCollection->byNeighborhood($neighborhood);
     $boundary_polygon = $this->getServiceLocator()->get('Whathood\\Spatial\\Neighborhood\\Boundary\\BoundaryBuilder')->build($pointElectionCollection, $neighborhood);
     $points = $this->m()->testPointMapper()->createByUserPolygons($userPolygons, $grid_resolution);
     $multi_point = new MultiPoint($points);
     return new JsonModel(array('boundary' => $boundary_polygon->toArray(), 'all_point_elections' => PointElection::allToArrays($pointElectionCollection->getPointElections()), 'neighborhood_election_points' => PointElection::allToArrays($neighborhoodWinningPointElections), 'test_points' => \Whathood\Spatial\Util::toGeoJsonArray($multi_point)));
 }
 /**
  * return geojson representation of test points given either
  *
  *  - neighborhood name and region name
  */
 public function getList()
 {
     $neighborhood_name = $this->getRequestParameter('neighborhood_name');
     $region_name = $this->getRequestParameter('region_name');
     $grid_resolution = $this->getRequestParameter('grid_res');
     if (empty($neighborhood_name) or empty($region_name) or empty($grid_resolution)) {
         return $this->badRequestJson("neighborhood_name,region_name and grid_res must all be defined");
     }
     $neighborhood = $this->m()->neighborhoodMapper()->byName($neighborhood_name, $region_name);
     if (empty($neighborhood)) {
         return $this->badRequestJson("no neighborhood found");
     }
     $user_polygons = $this->m()->userPolygonMapper()->byNeighborhood($neighborhood);
     if (empty($user_polygons)) {
         return $this->badRequestJson("no user polygons found for neighborhood");
     }
     $points = $this->m()->testPointMapper()->createByUserPolygons($user_polygons, $grid_resolution);
     if (empty($points)) {
         return $this->badRequestJson("no points returned with grid_resolution {$grid_resolution}");
     }
     $multi_point = new MultiPoint($points);
     return new JsonModel(\Whathood\Spatial\Util::toGeoJsonArray($multi_point));
 }