public function getId() { if ($this->__isInitialized__ === false) { return (int) $this->_identifier["id"]; } $this->__load(); return parent::getId(); }
public function getNeighborhoodPolygonsAsGeoJsonByRegion(Region $region) { if (empty($region->getId())) { throw new \InvalidArgumentException("region.id must not be null"); } $sql = "SELECT whathood.latest_neighborhoods_geojson(:regionId) as geojson"; $rsm = new ResultSetMapping(); $rsm->addScalarResult('geojson', 'geojson'); $query = $this->em->createNativeQuery($sql, $rsm); $query->setParameter('regionId', $region->getId()); $result = $query->getSingleResult(); $geojson = $result['geojson']; if (preg_match('/"features":null/', $geojson)) { throw new \Exception("no neighborhood polygons returned for region '" . $region->getName() . "'"); } else { return $geojson; } }
private function getBoundaryAsGeoJsonFromDb(Region $region) { $sql = "SELECT whathood.latest_neighborhoods_geojson(:regionId) as geojson"; $rsm = new ResultSetMapping(); $rsm->addScalarResult('geojson', 'geojson'); $query = $this->em->createNativeQuery($sql, $rsm); $query->setParameter('regionId', $region->getId()); $result = $query->getSingleResult(); $geojson = $result['geojson']; if (preg_match('/"features":null/', $geojson)) { throw new \Exception("no neighborhood polygons returned for region '" . $region->getName() . "'"); } return $geojson; }