Beispiel #1
0
 /**
  * Recherche le sommet de la route le plus proche du $point dans un rayon
  * de $rayonRecherche
  * @param array $point
  * @param $perimRecherche
  * @param PgMapTable $map
  * @return string
  * @throws EtapeException
  * @throws \Exception
  */
 public static function getNearestPoint(array $point, $perimRecherche, PgMapTable $map)
 {
     if (array_key_exists("x", $point) && array_key_exists("y", $point) && array_key_exists("z", $point)) {
         $reqNearestPoint = $map->getConnexion()->query("select id from {$map->getVerticesTableName()}\n                WHERE st_dwithin(st_makepoint({$point['x']}, {$point['z']}), the_geom, {$perimRecherche})\n                LIMIT 1");
         if (!is_bool($reqNearestPoint) && $reqNearestPoint->rowCount() > 0) {
             $nearestPoint = $reqNearestPoint->fetchColumn(0);
             return intval($nearestPoint);
         } else {
             throw new EtapeException("Aucun sommet du réseau routier ne se trouve à proximité.");
         }
     } else {
         throw new \Exception("Le tableau doit contenir les coordonnées x y z.");
     }
 }
Beispiel #2
0
 public static function checkDestinationExists($nom, PgMapTable $map)
 {
     if (is_string($nom)) {
         // Récupération du point
         $reqNom = $map->getConnexion()->query("SELECT vert.id FROM {$map->getVerticesTableName()} vert\n                                            INNER JOIN {$map->getDestinationsTableName()} dest ON dest.the_geom = vert.the_geom\n                                             WHERE dest.nom = '{$nom}'");
         if ($reqNom->rowCount() > 0) {
             $id = $reqNom->fetchColumn(0);
             return intval($id);
         } else {
             throw new EtapeException("Le point '{$nom}' n'a pas été trouvé");
         }
     } else {
         throw new \Exception("le nom doit être une chaine de caractère");
     }
 }