/** * @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))); }