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);
}
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);
}
}
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);
}
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();
}
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);
}
Aggregations