Search in sources :

Example 86 with Stop

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

the class DeferredValueSupportTest method testResolveAgencyAndId_ExistingAgencyId.

@Test
public void testResolveAgencyAndId_ExistingAgencyId() {
    Stop stop = new Stop();
    stop.setId(new AgencyAndId("a1", "2"));
    BeanWrapper bean = BeanWrapperFactory.wrap(stop);
    AgencyAndId id = _support.resolveAgencyAndId(bean, "id", "1");
    assertEquals(new AgencyAndId("a1", "1"), id);
}
Also used : BeanWrapper(org.onebusaway.csv_entities.schema.BeanWrapper) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) Test(org.junit.Test)

Example 87 with Stop

use of org.onebusaway.gtfs.model.Stop in project OpenTripPlanner by opentripplanner.

the class LuceneIndex method index.

/**
 * Index stations, stops, intersections, streets, and addresses by name and location.
 */
private void index() {
    try {
        long startTime = System.currentTimeMillis();
        /* Create or re-open a disk-backed Lucene Directory under the OTP server base filesystem directory. */
        directory = FSDirectory.open(new File(basePath, "lucene"));
        // TODO reuse the index if it exists?
        // directory = new RAMDirectory(); // only a little faster
        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_47, analyzer).setOpenMode(OpenMode.CREATE);
        final IndexWriter writer = new IndexWriter(directory, config);
        for (Stop stop : graphIndex.stopForId.values()) {
            addStop(writer, stop);
        }
        graphIndex.clusterStopsAsNeeded();
        for (StopCluster stopCluster : graphIndex.stopClusterForId.values()) {
            addCluster(writer, stopCluster);
        }
        for (StreetVertex sv : Iterables.filter(graphIndex.vertexForId.values(), StreetVertex.class)) {
            addCorner(writer, sv);
        }
        writer.close();
        long elapsedTime = System.currentTimeMillis() - startTime;
        LOG.info("Built Lucene index in {} msec", elapsedTime);
        // Make the IndexSearcher necessary for querying.
        searcher = new IndexSearcher(DirectoryReader.open(directory));
    } catch (Exception ex) {
        throw new RuntimeException("Lucene indexing failed.", ex);
    }
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) Stop(org.onebusaway.gtfs.model.Stop) StopCluster(org.opentripplanner.profile.StopCluster) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) File(java.io.File) IOException(java.io.IOException) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 88 with Stop

use of org.onebusaway.gtfs.model.Stop in project OpenTripPlanner by opentripplanner.

the class StopAdapter method unmarshal.

@Override
public Stop unmarshal(StopType arg) throws Exception {
    if (arg == null) {
        return null;
    }
    Stop a = new Stop();
    a.setId(arg.id);
    a.setName(arg.stopName);
    a.setCode(arg.stopCode);
    a.setDesc(arg.stopDesc);
    a.setLat(arg.stopLat);
    a.setLon(arg.stopLon);
    a.setZoneId(arg.zoneId);
    a.setUrl(arg.stopUrl);
    a.setLocationType(arg.locationType);
    a.setParentStation(arg.parentStation);
    a.setWheelchairBoarding(arg.wheelchairBoarding);
    a.setDirection(arg.direction);
    return new Stop(a);
}
Also used : Stop(org.onebusaway.gtfs.model.Stop)

Example 89 with Stop

use of org.onebusaway.gtfs.model.Stop in project OpenTripPlanner by opentripplanner.

the class StopCluster method computeCenter.

public void computeCenter() {
    double lonSum = 0, latSum = 0;
    for (Stop stop : children) {
        lonSum += stop.getLon();
        latSum += stop.getLat();
    }
    lon = lonSum / children.size();
    lat = latSum / children.size();
}
Also used : TransitStop(org.opentripplanner.routing.vertextype.TransitStop) Stop(org.onebusaway.gtfs.model.Stop)

Example 90 with Stop

use of org.onebusaway.gtfs.model.Stop in project OpenTripPlanner by opentripplanner.

the class TimetableFilterTest method setUp.

@Override
protected void setUp() {
    agency = new Agency();
    agency.setId("AGENCY");
    route = new Route();
    route.setType(com.conveyal.gtfs.model.Route.BUS);
    route.setShortName("T");
    route.setLongName("TEST");
    route.setAgency(agency);
    route.setId(new AgencyAndId(agency.getId(), "TEST"));
    metro = new Route();
    metro.setType(com.conveyal.gtfs.model.Route.SUBWAY);
    metro.setShortName("M");
    metro.setLongName("METRO");
    metro.setAgency(agency);
    metro.setId(new AgencyAndId(agency.getId(), "METRO"));
    trip = new Trip();
    trip.setRoute(route);
    trip.setId(new AgencyAndId(agency.getId(), "TRIP"));
    trip2 = new Trip();
    trip2.setRoute(route);
    trip2.setId(new AgencyAndId(agency.getId(), "TRIP2"));
    stops = new Stop[4];
    for (int i = 0; i < stops.length; i++) {
        Stop s = new Stop();
        s.setLat(-122.123);
        s.setLon(37.363 + i * 0.001);
        s.setId(new AgencyAndId(agency.getId(), "" + i));
        stops[i] = s;
    }
    List<StopTime> stopTimes = makeStopTimes(trip);
    StopPattern sp = new StopPattern(stopTimes);
    pattern = new TripPattern(route, sp);
    // make a triptimes
    times = makeTripTimes(trip, stopTimes);
    pattern.scheduledTimetable.addTripTimes(times);
    pattern.scheduledTimetable.addTripTimes(makeTripTimes(trip2, makeStopTimes(trip2)));
    // ten-minute frequency
    frequencyEntry = new FrequencyEntry(7 * 3600, 12 * 3600, 600, false, makeTripTimes(trip, makeStopTimes(trip)));
    pattern.scheduledTimetable.addFrequencyEntry(frequencyEntry);
    pattern.scheduledTimetable.addFrequencyEntry(new FrequencyEntry(7 * 3600, 12 * 3600, 600, false, makeTripTimes(trip2, makeStopTimes(trip2))));
    metroTrip = new Trip();
    metroTrip.setRoute(metro);
    metroTrip.setId(new AgencyAndId(agency.getId(), "TRIP"));
    stopTimes = makeStopTimes(metroTrip);
    sp = new StopPattern(stopTimes);
    metroPattern = new TripPattern(metro, sp);
    metroTimes = makeTripTimes(metroTrip, stopTimes);
    metroPattern.scheduledTimetable.addTripTimes(metroTimes);
}
Also used : StopPattern(org.opentripplanner.model.StopPattern) Trip(org.onebusaway.gtfs.model.Trip) Agency(org.onebusaway.gtfs.model.Agency) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) FrequencyEntry(org.opentripplanner.routing.trippattern.FrequencyEntry) Route(org.onebusaway.gtfs.model.Route) TripPattern(org.opentripplanner.routing.edgetype.TripPattern) StopTime(org.onebusaway.gtfs.model.StopTime)

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