public function updateRoutes() { //Build an array of Route objects $routeArray = array(); $position = 0; $vehicleTypeOverrides = $this->getVehicleTypeOverride(); foreach ($this->xml->route as $r) { $route = new Route(); $routeTag = (string) $r['tag']; $vehicleType = isset($vehicleTypeOverrides[$routeTag]) ? $vehicleTypeOverrides[$routeTag] : "bus"; $position++; $route->setAgency($this->agency); $route->setTag($routeTag); $route->setTitle((string) $r['title']); $route->setShortTitle((string) $r['shortTitle']); $route->setPosition($position); $route->setVehicleType($vehicleType); $route->setColor((string) $r['color']); $route->setLatMin(isset($r['latMin']) ? (string) $r['latMin'] : ""); $route->setLatMax(isset($r['latMax']) ? (string) $r['latMax'] : ""); $route->setLonMin(isset($r['lonMin']) ? (string) $r['lonMin'] : ""); $route->setLonMax(isset($r['lonMax']) ? (string) $r['lonMax'] : ""); $routeArray[$routeTag] = $route; } try { //Pass it to the base RouteUpdate class $routeUpdate = new RouteUpdate($this->agency, $routeArray); $routeUpdate->updateDB(); } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }
/** * For BART, the color value is the main identifier for a route */ public function updateRoutes() { //Build an array of Route objects $routeArray = array(); $position = 0; foreach ($this->xml->routes->route as $r) { $position++; $route = new Route(); $routeColor = substr((string) $r->color, 1); // We don't want the # $routeTag = BartColorCodes::getBartColor($routeColor); $route->setAgency($this->agency); $route->setTag($routeTag); $route->setTitle($routeTag); $route->setShortTitle($routeTag); $route->setColor($routeColor); $route->setVehicleType("train"); $route->setPosition($position); $routeArray[$routeTag] = $route; } try { //Pass it to the base RouteUpdate class $routeUpdate = new RouteUpdate($this->agency, $routeArray); $routeUpdate->updateDB(); } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }