Search in sources :

Example 1 with Stop

use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.

the class GenerateNarrativesTask method generateStopNarratives.

public void generateStopNarratives(NarrativeProviderImpl provider) {
    Map<AgencyAndId, List<ProjectedPoint>> shapePointCache = new HashMap<AgencyAndId, List<ProjectedPoint>>();
    int index = 0;
    Collection<Stop> allStops = _gtfsDao.getAllStops();
    Map<AgencyAndId, Stop> stopsById = MappingLibrary.mapToValue(allStops, "id");
    int logInterval = LoggingIntervalUtil.getAppropriateLoggingInterval(allStops.size());
    for (StopEntry stopEntry : _transitGraphDao.getAllStops()) {
        if (index % logInterval == 0)
            _log.info("stops=" + index);
        index++;
        Stop stop = stopsById.get(stopEntry.getId());
        StopNarrative.Builder narrative = StopNarrative.builder();
        narrative.setCode(deduplicate(stop.getCode()));
        narrative.setDescription(deduplicate(stop.getDesc()));
        narrative.setName(deduplicate(stop.getName()));
        narrative.setUrl(deduplicate(stop.getUrl()));
        String direction = computeStopDirection(provider, shapePointCache, stop, stopEntry);
        narrative.setDirection(deduplicate(direction));
        provider.setNarrativeForStop(stopEntry.getId(), narrative.create());
    }
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) HashMap(java.util.HashMap) Stop(org.onebusaway.gtfs.model.Stop) ProjectedPoint(org.onebusaway.transit_data_federation.model.ProjectedPoint) ProjectedPoint(org.onebusaway.transit_data_federation.model.ProjectedPoint) DoubleArrayList(cern.colt.list.DoubleArrayList) List(java.util.List) ArrayList(java.util.ArrayList) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) StopNarrative(org.onebusaway.transit_data_federation.model.narrative.StopNarrative)

Example 2 with Stop

use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.

the class StopVerificationDistanceTask method verifyStops.

protected void verifyStops(String rootStopId, List<String> consolidatedStops) {
    AgencyAndId agencyAndId = AgencyAndIdLibrary.convertFromString(rootStopId);
    Stop expectedStop = _dao.getStopForId(agencyAndId);
    for (String consolidatedStop : consolidatedStops) {
        Stop unexpectedStop = _dao.getStopForId(AgencyAndIdLibrary.convertFromString(consolidatedStop));
        if (unexpectedStop != null) {
            if (expectedStop != null) {
                double distance = SphericalGeometryLibrary.distanceFaster(expectedStop.getLat(), expectedStop.getLon(), unexpectedStop.getLat(), unexpectedStop.getLon());
                if (distance > STOP_DISTANCE_THRESHOLD) {
                    _logger.log("stop_verification_distance.csv", rootStopId, consolidatedStop, distance, toOrd(expectedStop.getLat(), expectedStop.getLon()), toOrd(unexpectedStop.getLat(), unexpectedStop.getLon()));
                }
            }
        }
    }
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop)

Example 3 with Stop

use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.

the class StopVerificationTask method verifyStops.

protected void verifyStops(String rootStopId, List<String> consolidatedStops) {
    AgencyAndId agencyAndId = AgencyAndIdLibrary.convertFromString(rootStopId);
    Stop expectedStop = _dao.getStopForId(agencyAndId);
    boolean pass = expectedStop != null;
    String missingStopId = (pass ? "" : rootStopId);
    String unexpectedStopIds = "";
    for (String consolidatedStop : consolidatedStops) {
        Stop unexpectedStop = _dao.getStopForId(AgencyAndIdLibrary.convertFromString(consolidatedStop));
        if (unexpectedStop != null) {
            pass = false;
            unexpectedStopIds += consolidatedStop + " ";
        }
    }
    if (!pass) {
        _logger.log("stop_verification.csv", rootStopId, String.valueOf(pass), missingStopId, unexpectedStopIds);
    }
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop)

Example 4 with Stop

use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.

the class EntityReplacementLoggerImpl method updateStore.

// we've been called (potentially again).  see if there is anything
// worth updating.
private void updateStore(Serializable id, Serializable replacementId, Double originLat, Double originLon, Double replacementLat, Double replacementLon) {
    Serializable key = hash(id, replacementId);
    EntityStore store = _replacements.get(key);
    if (store == null) {
        if (originLat == null && _rejectionDao != null) {
            Stop stop = _rejectionDao.getEntityForId(Stop.class, id);
            if (stop != null) {
                originLat = stop.getLat();
                originLon = stop.getLon();
            }
        }
        store = new EntityStore(id, replacementId, originLat, originLon, replacementLat, replacementLon);
        _replacements.put(key, store);
    } else {
        store.update(originLat, originLon, replacementLat, replacementLon);
    }
}
Also used : Serializable(java.io.Serializable) Stop(org.onebusaway.gtfs.model.Stop)

Example 5 with Stop

use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.

the class HastusGtfsFactory method processStops.

private void processStops() throws Exception {
    File stopsShapeFile = new File(_gisInputPath, "CTBusStops.shp");
    FeatureCollection<SimpleFeatureType, SimpleFeature> features = ShapefileLibrary.loadShapeFile(stopsShapeFile);
    FeatureIterator<SimpleFeature> it = features.features();
    logger.header(csv("stops"), "stop_id,primary_name,cross_name,computed_name,lat,lon");
    while (it.hasNext()) {
        SimpleFeature feature = it.next();
        Long stopId = (Long) feature.getProperty("STOP_ID").getValue();
        String primaryName = (String) feature.getProperty("PRIMARY").getValue();
        String crossName = (String) feature.getProperty("CROSS").getValue();
        Point point = (Point) feature.getDefaultGeometry();
        String stopName = computeStopName(primaryName, crossName);
        Stop stop = new Stop();
        stop.setId(id(stopId.toString()));
        stop.setName(stopName);
        stop.setLat(point.getY());
        stop.setLon(point.getX());
        logger.log(csv("stops"), stopId, primaryName, crossName, stopName, point.getY(), point.getX());
        _dao.saveEntity(stop);
    }
    try {
        it.close();
    } catch (Exception e) {
        _log.error("issue closing feature.  Exception will be ignored.", e);
    }
}
Also used : SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Stop(org.onebusaway.gtfs.model.Stop) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) PttTimingPoint(org.onebusaway.admin.service.bundle.hastus.xml.PttTimingPoint) Point(com.vividsolutions.jts.geom.Point) ShapePoint(org.onebusaway.gtfs.model.ShapePoint) File(java.io.File) SimpleFeature(org.opengis.feature.simple.SimpleFeature) ParseException(java.text.ParseException) SAXException(org.xml.sax.SAXException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

Stop (org.onebusaway.gtfs.model.Stop)160 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)75 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)49 Trip (org.onebusaway.gtfs.model.Trip)40 Test (org.junit.Test)39 ArrayList (java.util.ArrayList)33 StopTime (org.onebusaway.gtfs.model.StopTime)33 Route (org.onebusaway.gtfs.model.Route)28 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)23 Agency (org.onebusaway.gtfs.model.Agency)19 Vertex (org.opentripplanner.routing.graph.Vertex)18 HashMap (java.util.HashMap)14 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)13 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)11 LineString (com.vividsolutions.jts.geom.LineString)10 List (java.util.List)10 GET (javax.ws.rs.GET)10 ShapePoint (org.onebusaway.gtfs.model.ShapePoint)10 GraphPath (org.opentripplanner.routing.spt.GraphPath)10 Coordinate (com.vividsolutions.jts.geom.Coordinate)9