diff --git a/onebusaway-gtfs-hibernate/src/main/resources/org/onebusaway/gtfs/model/GtfsMapping.hibernate.xml b/onebusaway-gtfs-hibernate/src/main/resources/org/onebusaway/gtfs/model/GtfsMapping.hibernate.xml index 7dc9c6fa7..530cd9773 100644 --- a/onebusaway-gtfs-hibernate/src/main/resources/org/onebusaway/gtfs/model/GtfsMapping.hibernate.xml +++ b/onebusaway-gtfs-hibernate/src/main/resources/org/onebusaway/gtfs/model/GtfsMapping.hibernate.xml @@ -44,6 +44,9 @@ + + + @@ -61,6 +64,7 @@ + diff --git a/onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/FareRuleMergeStrategy.java b/onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/FareRuleMergeStrategy.java index 152cbc1dc..ef6b7038b 100644 --- a/onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/FareRuleMergeStrategy.java +++ b/onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/FareRuleMergeStrategy.java @@ -46,6 +46,9 @@ protected boolean entitiesAreIdentical(FareRule fareRuleA, FareRule fareRuleB) { if (!equals(fareRuleA.getContainsId(), fareRuleB.getContainsId())) { return false; } + if (!equals(fareRuleA.getUnitsTraveled(), fareRuleB.getUnitsTraveled())) { + return false; + } return true; } diff --git a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareAttribute.java b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareAttribute.java index 358612b5f..44d76c283 100644 --- a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareAttribute.java +++ b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareAttribute.java @@ -47,6 +47,15 @@ public final class FareAttribute extends IdentityBean { @CsvField(optional = true) private int journeyDuration = MISSING_VALUE; + @CsvField(name = "distance_mode", optional = true, defaultValue = "0") + private int distanceMode = MISSING_VALUE; + + @CsvField(name = "distance_unit_price", optional = true) + private float distanceUnitPrice = MISSING_VALUE; + + @CsvField(name = "distance_unit_start_offset", optional = true) + private float distanceUnitStartOffset = MISSING_VALUE; + public FareAttribute() { } @@ -59,6 +68,9 @@ public FareAttribute(FareAttribute fa) { this.transfers = fa.transfers; this.transferDuration = fa.transferDuration; this.journeyDuration = fa.journeyDuration; + this.distanceMode = fa.distanceMode; + this.distanceUnitPrice = fa.distanceUnitPrice; + this.distanceUnitStartOffset = fa.distanceUnitStartOffset; } @Override @@ -143,6 +155,42 @@ public void clearJourneyDuration() { this.journeyDuration = MISSING_VALUE; } + public int getDistanceMode() { + return distanceMode; + } + + public void setDistanceMode(int distanceMode) { + this.distanceMode = distanceMode; + } + + public void clearDistanceMode() { + this.distanceMode = MISSING_VALUE; + } + + public float getDistanceUnitPrice() { + return distanceUnitPrice; + } + + public void setDistanceUnitPrice(float distanceUnitPrice) { + this.distanceUnitPrice = distanceUnitPrice; + } + + public void clearDistanceUnitPrice() { + this.distanceUnitPrice = MISSING_VALUE; + } + + public float getDistanceUnitStartOffset() { + return distanceUnitStartOffset; + } + + public void setDistanceUnitStartOffset(float distanceUnitStartOffset) { + this.distanceUnitStartOffset = distanceUnitStartOffset; + } + + public void clearDistanceUnitStartOffset() { + this.distanceUnitStartOffset = MISSING_VALUE; + } + public String toString() { return ""; } diff --git a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareRule.java b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareRule.java index 797e54701..7070c7e52 100644 --- a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareRule.java +++ b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareRule.java @@ -42,6 +42,9 @@ public final class FareRule extends IdentityBean { @CsvField(optional = true) private String containsId; + @CsvField(name = "units_traveled", optional = true) + private float unitsTraveled; + public FareRule() { } @@ -53,6 +56,7 @@ public FareRule(FareRule fr) { this.originId = fr.originId; this.destinationId = fr.destinationId; this.containsId = fr.containsId; + this.unitsTraveled = fr.unitsTraveled; } @Override @@ -105,6 +109,14 @@ public void setContainsId(String containsId) { this.containsId = containsId; } + public float getUnitsTraveled() { + return unitsTraveled; + } + + public void setUnitsTraveled(float unitsTraveled) { + this.unitsTraveled = unitsTraveled; + } + public String toString() { return ""; } diff --git a/onebusaway-gtfs/src/test/java/org/onebusaway/gtfs/serialization/GtfsReaderTest.java b/onebusaway-gtfs/src/test/java/org/onebusaway/gtfs/serialization/GtfsReaderTest.java index e0b837e0e..430d71aa5 100644 --- a/onebusaway-gtfs/src/test/java/org/onebusaway/gtfs/serialization/GtfsReaderTest.java +++ b/onebusaway-gtfs/src/test/java/org/onebusaway/gtfs/serialization/GtfsReaderTest.java @@ -99,11 +99,11 @@ public void testAllFields() throws IOException { "WEEK,20120304,2"); gtfs.putLines( "fare_attributes.txt", - "fare_id,price,currency_type,payment_method,transfers,transfer_duration,journey_duration", - "FA1,2.0,USD,1,2,60,61"); + "fare_id,price,currency_type,payment_method,transfers,transfer_duration,journey_duration,distance_mode,distance_unit_price,distance_unit_start_offset", + "FA1,2.0,USD,1,2,60,61,1,2.00,3.0"); gtfs.putLines("fare_rules.txt", - "fare_id,route_id,origin_id,destination_id,contains_id", - "FA1,R1,Z1,Z2,Z3"); + "fare_id,route_id,origin_id,destination_id,contains_id,units_traveled", + "FA1,R1,Z1,Z2,Z3,1.0"); gtfs.putLines( "shapes.txt", "shape_id,shape_pt_sequence,shape_pt_lat,shape_pt_lon,shape_dist_traveled", @@ -219,6 +219,9 @@ public void testAllFields() throws IOException { assertEquals(2, fareAttribute.getTransfers()); assertEquals(60, fareAttribute.getTransferDuration()); assertEquals(61, fareAttribute.getJourneyDuration()); + assertEquals(1, fareAttribute.getDistanceMode()); + assertEquals(2.00, fareAttribute.getDistanceUnitPrice(), 1.0); + assertEquals(3.0, fareAttribute.getDistanceUnitStartOffset(), 1.0); List rules = dao.getFareRulesForFareAttribute(fareAttribute); FareRule fareRule = rules.get(0); @@ -227,6 +230,7 @@ public void testAllFields() throws IOException { assertEquals("Z1", fareRule.getOriginId()); assertEquals("Z2", fareRule.getDestinationId()); assertEquals("Z3", fareRule.getContainsId()); + assertEquals(1.0, fareRule.getUnitsTraveled(), 1.0); List shapePoints = dao.getShapePointsForShapeId(new AgencyAndId( "1", "SHP1"));