-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse additional TransitLine info from GTFS (#252)
add additional line info to gtfs conversion (agency, type, etc) and add tests authored-by: Tobias Kohl <[email protected]>
- Loading branch information
1 parent
2d895e2
commit b43b440
Showing
23 changed files
with
760 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,5 @@ pt2matsim.iml | |
test/gtfs-feed-rewrite/ | ||
|
||
test/stib-mivb-gtfs/ | ||
|
||
test/Gtfs2TransitScheduleIT/output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/main/java/org/matsim/pt2matsim/gtfs/AdditionalTransitLineInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* *********************************************************************** * | ||
* project: org.matsim.* | ||
* *********************************************************************** * | ||
* * | ||
* copyright : (C) 2024 by the members listed in the COPYING, * | ||
* LICENSE and WARRANTY file. * | ||
* email : info at matsim dot org * | ||
* * | ||
* *********************************************************************** * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* See also COPYING, LICENSE and WARRANTY file * | ||
* * | ||
* *********************************************************************** */ | ||
package org.matsim.pt2matsim.gtfs; | ||
|
||
import org.matsim.pt2matsim.gtfs.lib.GtfsDefinitions; | ||
import org.matsim.pt2matsim.gtfs.lib.Route; | ||
|
||
/** | ||
* Simple container class for useful but not necessary info extracted from the gtfs schedule | ||
* | ||
* @author tkohl (Royal2Flush) | ||
*/ | ||
public class AdditionalTransitLineInfo { | ||
public static final String INFO_COLUMN_ID = "lineId"; | ||
public static final String INFO_COLUMN_SHORTNAME = "shortName"; | ||
public static final String INFO_COLUMN_LONGNAME = "longName"; | ||
public static final String INFO_COLUMN_TYPE = "type"; | ||
public static final String INFO_COLUMN_DESCRIPTION = "description"; | ||
public static final String INFO_COLUMN_AGENCY_ID = "agencyId"; | ||
public static final String INFO_COLUMN_AGENCY_NAME = "agencyName"; | ||
public static final String INFO_COLUMN_AGENCY_URL = "agencyURL"; | ||
public static final String INFO_COLUMN_NUM_TRANSIT_ROUTES = "numTransitRoutes"; | ||
public static final String INFO_COLUMN_NUM_TOTAL_DEPARTURES = "totalDepartures"; | ||
|
||
private final String id; | ||
private final String shortName; | ||
private final String longName; | ||
|
||
private final GtfsDefinitions.RouteType routeType; | ||
private final String routeDescription; | ||
private final String agencyId; | ||
private final String agencyName; | ||
private final String agencyURL; | ||
private int numberOfTransitRoutes = 0; | ||
private int totalNumberOfDepartures = 0; | ||
|
||
AdditionalTransitLineInfo(Route gtfsRoute) { | ||
this.id = gtfsRoute.getId(); | ||
this.shortName = gtfsRoute.getShortName(); | ||
this.longName = gtfsRoute.getLongName(); | ||
this.routeType = gtfsRoute.getRouteType(); | ||
this.routeDescription = gtfsRoute.getDescription(); | ||
this.agencyId = gtfsRoute.getAgency().getId(); | ||
this.agencyName = gtfsRoute.getAgency().getAgencyName(); | ||
this.agencyURL = gtfsRoute.getAgency().getAgencyUrl(); | ||
} | ||
|
||
void countRoute(int numRouteDepartures) { | ||
this.numberOfTransitRoutes++; | ||
this.totalNumberOfDepartures += numRouteDepartures; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getShortName() { | ||
return this.shortName; | ||
} | ||
|
||
public String getLongName() { | ||
return longName; | ||
} | ||
|
||
public GtfsDefinitions.RouteType getRouteType() { | ||
return routeType; | ||
} | ||
|
||
public String getRouteDescription() { | ||
return routeDescription; | ||
} | ||
|
||
public String getAgencyId() { | ||
return agencyId; | ||
} | ||
|
||
public String getAgencyName() { | ||
return agencyName; | ||
} | ||
|
||
public String getAgencyURL() { | ||
return agencyURL; | ||
} | ||
|
||
public int getNumberOfTransitRoutes() { | ||
return numberOfTransitRoutes; | ||
} | ||
|
||
public int getTotalNumberOfDepartures() { | ||
return totalNumberOfDepartures; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/org/matsim/pt2matsim/gtfs/lib/AgencyImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* *********************************************************************** * | ||
* project: org.matsim.* | ||
* *********************************************************************** * | ||
* * | ||
* copyright : (C) 2024 by the members listed in the COPYING, * | ||
* LICENSE and WARRANTY file. * | ||
* email : info at matsim dot org * | ||
* * | ||
* *********************************************************************** * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* See also COPYING, LICENSE and WARRANTY file * | ||
* * | ||
* *********************************************************************** */ | ||
package org.matsim.pt2matsim.gtfs.lib; | ||
|
||
/** | ||
* @author tkohl (Royal2Flush) | ||
*/ | ||
public class AgencyImpl implements Agency { | ||
|
||
private final String id; | ||
private final String name; | ||
private final String url; | ||
private final String timezone; | ||
|
||
public AgencyImpl(String id, String name, String url, String timezone) { | ||
this.id = id; | ||
this.name = name; | ||
this.url = url; | ||
this.timezone = timezone; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.id; | ||
} | ||
|
||
@Override | ||
public String getAgencyName() { | ||
return this.name; | ||
} | ||
|
||
@Override | ||
public String getAgencyUrl() { | ||
return this.url; | ||
} | ||
|
||
@Override | ||
public String getAgencyTimeZone() { | ||
return this.timezone; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if(this == o) return true; | ||
if(o == null || getClass() != o.getClass()) return false; | ||
|
||
AgencyImpl other = (AgencyImpl) o; | ||
|
||
if(!this.id.equals(other.id)) return false; | ||
if(!this.name.equals(other.name)) return false; | ||
if(!this.url.equals(other.url)) return false; | ||
return this.timezone.equals(other.timezone); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = id.hashCode(); | ||
result = 31 * result + name.hashCode(); | ||
result = 31 * result + url.hashCode(); | ||
result = 31 * result + timezone.hashCode(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[agency:" + id + ", \"" + name + "\"]"; | ||
} | ||
|
||
} |
Oops, something went wrong.