Skip to content

Commit

Permalink
Import GTFS using onebusaway library and map into OTP model. Find the…
Browse files Browse the repository at this point in the history
… best place to map between the to models. (Refactor OTP to have new OTP classes to replace the OBA GTFS classes #2494)
  • Loading branch information
Thomas Gran committed Sep 12, 2017
1 parent d04ac42 commit 4812e2e
Show file tree
Hide file tree
Showing 31 changed files with 1,187 additions and 482 deletions.
9 changes: 2 additions & 7 deletions pom.xml
Expand Up @@ -641,15 +641,10 @@
<version>1</version> <version>1</version>
</dependency> </dependency>
<!-- OBA GTFS loader --> <!-- OBA GTFS loader -->
<!--<dependency>-->
<!--<groupId>org.onebusaway</groupId>-->
<!--<artifactId>onebusaway-gtfs</artifactId>-->
<!--<version>1.3.5-conveyal-SNAPSHOT-2</version>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>org.onebusaway</groupId> <groupId>org.onebusaway</groupId>
<artifactId>onebusaway-csv-entities</artifactId> <artifactId>onebusaway-gtfs</artifactId>
<version>1.1.5-SNAPSHOT</version> <version>1.3.5-conveyal-SNAPSHOT-2</version>
</dependency> </dependency>


<!-- Processing is used for the debug GUI (though we could probably use just Java2D) --> <!-- Processing is used for the debug GUI (though we could probably use just Java2D) -->
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/org/onebusaway2/gtfs/impl/GtfsDaoImpl.java
Expand Up @@ -49,21 +49,24 @@ public class GtfsDaoImpl extends GenericDaoImpl implements GtfsMutableDao {


private boolean packShapePoints = false; private boolean packShapePoints = false;



public boolean isPackStopTimes() { public boolean isPackStopTimes() {
return packStopTimes; return packStopTimes;
} }


public void setPackStopTimes(boolean packStopTimes) { // TODO TGR - The mapping from GTFS to OTP model do not support this - ok?
this.packStopTimes = packStopTimes; // public void setPackStopTimes(boolean packStopTimes) {
} // this.packStopTimes = packStopTimes;
// }


public boolean isPackShapePoints() { public boolean isPackShapePoints() {
return packShapePoints; return packShapePoints;
} }


public void setPackShapePoints(boolean packShapePoints) { // TODO TGR - The mapping from GTFS to OTP model do not support this - ok?
this.packShapePoints = packShapePoints; // public void setPackShapePoints(boolean packShapePoints) {
} // this.packShapePoints = packShapePoints;
// }


/*** /***
* {@link GtfsDao} Interface * {@link GtfsDao} Interface
Expand Down
53 changes: 40 additions & 13 deletions src/main/java/org/onebusaway2/gtfs/impl/GtfsRelationalDaoImpl.java
Expand Up @@ -29,18 +29,7 @@
import org.onebusaway.csv_entities.exceptions.EntityInstantiationException; import org.onebusaway.csv_entities.exceptions.EntityInstantiationException;
import org.onebusaway.csv_entities.schema.BeanWrapper; import org.onebusaway.csv_entities.schema.BeanWrapper;
import org.onebusaway.csv_entities.schema.BeanWrapperFactory; import org.onebusaway.csv_entities.schema.BeanWrapperFactory;
import org.onebusaway2.gtfs.model.Agency; import org.onebusaway2.gtfs.model.*;
import org.onebusaway2.gtfs.model.AgencyAndId;
import org.onebusaway2.gtfs.model.FareAttribute;
import org.onebusaway2.gtfs.model.FareRule;
import org.onebusaway2.gtfs.model.Frequency;
import org.onebusaway2.gtfs.model.Route;
import org.onebusaway2.gtfs.model.ServiceCalendar;
import org.onebusaway2.gtfs.model.ServiceCalendarDate;
import org.onebusaway2.gtfs.model.ShapePoint;
import org.onebusaway2.gtfs.model.Stop;
import org.onebusaway2.gtfs.model.StopTime;
import org.onebusaway2.gtfs.model.Trip;
import org.onebusaway2.gtfs.services.GtfsMutableRelationalDao; import org.onebusaway2.gtfs.services.GtfsMutableRelationalDao;


/** /**
Expand Down Expand Up @@ -82,7 +71,45 @@ public class GtfsRelationalDaoImpl extends GtfsDaoImpl implements


private Map<FareAttribute, List<FareRule>> _fareRulesByFareAttribute = null; private Map<FareAttribute, List<FareRule>> _fareRulesByFareAttribute = null;


public void clearAllCaches() { public GtfsRelationalDaoImpl(
Collection<Agency> agencies,
Collection<ServiceCalendarDate> calendarDates,
Collection<ServiceCalendar> calendars,
Collection<FareAttribute> fareAttributes,
Collection<FareRule> fareRules,
Collection<FeedInfo> feedInfos,
Collection<Frequency> frequencies,
Collection<Pathway> pathways,
Collection<Route> routes,
Collection<ShapePoint> shapePoints,
Collection<Stop> stops,
Collection<StopTime> stopTimes,
Collection<Transfer> transfers,
Collection<Trip> trips
) {
saveAll(agencies);
saveAll(calendarDates);
saveAll(calendars);
saveAll(fareAttributes);
saveAll(fareRules);
saveAll(feedInfos);
saveAll(frequencies);
saveAll(pathways);
saveAll(routes);
saveAll(shapePoints);
saveAll(stops);
saveAll(stopTimes);
saveAll(transfers);
saveAll(trips);
}

private void saveAll(Collection<?> entities) {
for (Object it : entities) {
saveEntity(it);
}
}

public void clearAllCaches() {
_tripAgencyIdsByServiceId = clearMap(_tripAgencyIdsByServiceId); _tripAgencyIdsByServiceId = clearMap(_tripAgencyIdsByServiceId);
_routesByAgency = clearMap(_routesByAgency); _routesByAgency = clearMap(_routesByAgency);
_stopsByStation = clearMap(_stopsByStation); _stopsByStation = clearMap(_stopsByStation);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/onebusaway2/gtfs/impl/StopTimeArray.java
Expand Up @@ -156,7 +156,8 @@ public void remove() {
} }
} }


private class StopTimeProxyImpl implements StopTimeProxy { private class StopTimeProxyImpl implements
StopTimeProxy {


private final int index; private final int index;


Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/onebusaway2/gtfs/model/Agency.java
Expand Up @@ -47,7 +47,6 @@ public final class Agency extends IdentityBean<String> {
private String brandingUrl; private String brandingUrl;


public Agency() { public Agency() {

} }


public Agency(Agency a) { public Agency(Agency a) {
Expand Down

0 comments on commit 4812e2e

Please sign in to comment.