From a80c73641bd1e95a7f75caa36a20c6fd79eaad3b Mon Sep 17 00:00:00 2001 From: Tobias Kohl Date: Thu, 19 Dec 2024 17:13:04 +0100 Subject: [PATCH 1/3] remove trailing separator in header --- test/gtfs-feed-cal/routes.txt | 2 +- test/gtfs-feed/routes.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/gtfs-feed-cal/routes.txt b/test/gtfs-feed-cal/routes.txt index 10a88a3..375fa7f 100755 --- a/test/gtfs-feed-cal/routes.txt +++ b/test/gtfs-feed-cal/routes.txt @@ -1,4 +1,4 @@ -route_id,route_short_name,route_long_name,route_type,agency_id, +route_id,route_short_name,route_long_name,route_type,agency_id lineA,Line A,Bus Line A,3,S42 lineB,Line B,Tram Line B,0,P2M lineC,Line C,Something else,907,P2M \ No newline at end of file diff --git a/test/gtfs-feed/routes.txt b/test/gtfs-feed/routes.txt index 10a88a3..375fa7f 100755 --- a/test/gtfs-feed/routes.txt +++ b/test/gtfs-feed/routes.txt @@ -1,4 +1,4 @@ -route_id,route_short_name,route_long_name,route_type,agency_id, +route_id,route_short_name,route_long_name,route_type,agency_id lineA,Line A,Bus Line A,3,S42 lineB,Line B,Tram Line B,0,P2M lineC,Line C,Something else,907,P2M \ No newline at end of file From 0bd70fffceda1917a6d795e5717cae8b19ab4049 Mon Sep 17 00:00:00 2001 From: Tobias Kohl Date: Thu, 19 Dec 2024 17:14:10 +0100 Subject: [PATCH 2/3] - make only one of route_short_name and route_long_name required - implement the optionality of agency if there only is one --- .../matsim/pt2matsim/gtfs/GtfsFeedImpl.java | 35 +++++++-- .../pt2matsim/gtfs/lib/GtfsDefinitions.java | 8 +- .../pt2matsim/gtfs/GtfsMinimalCaseTest.java | 74 +++++++++++++++++++ test/gtfs-feed-min/agency.txt | 2 + test/gtfs-feed-min/calendar.txt | 5 ++ test/gtfs-feed-min/calendar_dates.txt | 6 ++ test/gtfs-feed-min/frequencies.txt | 4 + .../gtfs-feed-min/multipleAgencies/agency.txt | 3 + .../multipleAgencies/calendar.txt | 5 ++ .../multipleAgencies/calendar_dates.txt | 6 ++ .../multipleAgencies/frequencies.txt | 4 + .../gtfs-feed-min/multipleAgencies/routes.txt | 4 + .../gtfs-feed-min/multipleAgencies/shapes.txt | 22 ++++++ .../multipleAgencies/stop_times.txt | 27 +++++++ test/gtfs-feed-min/multipleAgencies/stops.txt | 7 ++ .../multipleAgencies/transfers.txt | 7 ++ test/gtfs-feed-min/multipleAgencies/trips.txt | 7 ++ test/gtfs-feed-min/noAgencyId/agency.txt | 2 + test/gtfs-feed-min/noAgencyId/calendar.txt | 5 ++ .../noAgencyId/calendar_dates.txt | 6 ++ test/gtfs-feed-min/noAgencyId/frequencies.txt | 4 + test/gtfs-feed-min/noAgencyId/routes.txt | 4 + test/gtfs-feed-min/noAgencyId/shapes.txt | 22 ++++++ test/gtfs-feed-min/noAgencyId/stop_times.txt | 27 +++++++ test/gtfs-feed-min/noAgencyId/stops.txt | 7 ++ test/gtfs-feed-min/noAgencyId/transfers.txt | 7 ++ test/gtfs-feed-min/noAgencyId/trips.txt | 7 ++ test/gtfs-feed-min/noLongName/agency.txt | 3 + test/gtfs-feed-min/noLongName/calendar.txt | 5 ++ .../noLongName/calendar_dates.txt | 6 ++ test/gtfs-feed-min/noLongName/frequencies.txt | 4 + test/gtfs-feed-min/noLongName/routes.txt | 4 + test/gtfs-feed-min/noLongName/shapes.txt | 22 ++++++ test/gtfs-feed-min/noLongName/stop_times.txt | 27 +++++++ test/gtfs-feed-min/noLongName/stops.txt | 7 ++ test/gtfs-feed-min/noLongName/transfers.txt | 7 ++ test/gtfs-feed-min/noLongName/trips.txt | 7 ++ test/gtfs-feed-min/noNameAtAll/agency.txt | 3 + test/gtfs-feed-min/noNameAtAll/calendar.txt | 5 ++ .../noNameAtAll/calendar_dates.txt | 6 ++ .../gtfs-feed-min/noNameAtAll/frequencies.txt | 4 + test/gtfs-feed-min/noNameAtAll/routes.txt | 4 + test/gtfs-feed-min/noNameAtAll/shapes.txt | 22 ++++++ test/gtfs-feed-min/noNameAtAll/stop_times.txt | 27 +++++++ test/gtfs-feed-min/noNameAtAll/stops.txt | 7 ++ test/gtfs-feed-min/noNameAtAll/transfers.txt | 7 ++ test/gtfs-feed-min/noNameAtAll/trips.txt | 7 ++ test/gtfs-feed-min/noShortName/agency.txt | 3 + test/gtfs-feed-min/noShortName/calendar.txt | 5 ++ .../noShortName/calendar_dates.txt | 6 ++ .../gtfs-feed-min/noShortName/frequencies.txt | 4 + test/gtfs-feed-min/noShortName/routes.txt | 4 + test/gtfs-feed-min/noShortName/shapes.txt | 22 ++++++ test/gtfs-feed-min/noShortName/stop_times.txt | 27 +++++++ test/gtfs-feed-min/noShortName/stops.txt | 7 ++ test/gtfs-feed-min/noShortName/transfers.txt | 7 ++ test/gtfs-feed-min/noShortName/trips.txt | 7 ++ test/gtfs-feed-min/routes.txt | 4 + test/gtfs-feed-min/shapes.txt | 22 ++++++ test/gtfs-feed-min/stop_times.txt | 27 +++++++ test/gtfs-feed-min/stops.txt | 7 ++ test/gtfs-feed-min/transfers.txt | 7 ++ test/gtfs-feed-min/trips.txt | 7 ++ 63 files changed, 657 insertions(+), 10 deletions(-) create mode 100644 src/test/java/org/matsim/pt2matsim/gtfs/GtfsMinimalCaseTest.java create mode 100644 test/gtfs-feed-min/agency.txt create mode 100644 test/gtfs-feed-min/calendar.txt create mode 100644 test/gtfs-feed-min/calendar_dates.txt create mode 100644 test/gtfs-feed-min/frequencies.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/agency.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/calendar.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/calendar_dates.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/frequencies.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/routes.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/shapes.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/stop_times.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/stops.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/transfers.txt create mode 100644 test/gtfs-feed-min/multipleAgencies/trips.txt create mode 100644 test/gtfs-feed-min/noAgencyId/agency.txt create mode 100644 test/gtfs-feed-min/noAgencyId/calendar.txt create mode 100644 test/gtfs-feed-min/noAgencyId/calendar_dates.txt create mode 100644 test/gtfs-feed-min/noAgencyId/frequencies.txt create mode 100644 test/gtfs-feed-min/noAgencyId/routes.txt create mode 100644 test/gtfs-feed-min/noAgencyId/shapes.txt create mode 100644 test/gtfs-feed-min/noAgencyId/stop_times.txt create mode 100644 test/gtfs-feed-min/noAgencyId/stops.txt create mode 100644 test/gtfs-feed-min/noAgencyId/transfers.txt create mode 100644 test/gtfs-feed-min/noAgencyId/trips.txt create mode 100644 test/gtfs-feed-min/noLongName/agency.txt create mode 100644 test/gtfs-feed-min/noLongName/calendar.txt create mode 100644 test/gtfs-feed-min/noLongName/calendar_dates.txt create mode 100644 test/gtfs-feed-min/noLongName/frequencies.txt create mode 100644 test/gtfs-feed-min/noLongName/routes.txt create mode 100644 test/gtfs-feed-min/noLongName/shapes.txt create mode 100644 test/gtfs-feed-min/noLongName/stop_times.txt create mode 100644 test/gtfs-feed-min/noLongName/stops.txt create mode 100644 test/gtfs-feed-min/noLongName/transfers.txt create mode 100644 test/gtfs-feed-min/noLongName/trips.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/agency.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/calendar.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/calendar_dates.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/frequencies.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/routes.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/shapes.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/stop_times.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/stops.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/transfers.txt create mode 100644 test/gtfs-feed-min/noNameAtAll/trips.txt create mode 100644 test/gtfs-feed-min/noShortName/agency.txt create mode 100644 test/gtfs-feed-min/noShortName/calendar.txt create mode 100644 test/gtfs-feed-min/noShortName/calendar_dates.txt create mode 100644 test/gtfs-feed-min/noShortName/frequencies.txt create mode 100644 test/gtfs-feed-min/noShortName/routes.txt create mode 100644 test/gtfs-feed-min/noShortName/shapes.txt create mode 100644 test/gtfs-feed-min/noShortName/stop_times.txt create mode 100644 test/gtfs-feed-min/noShortName/stops.txt create mode 100644 test/gtfs-feed-min/noShortName/transfers.txt create mode 100644 test/gtfs-feed-min/noShortName/trips.txt create mode 100644 test/gtfs-feed-min/routes.txt create mode 100644 test/gtfs-feed-min/shapes.txt create mode 100644 test/gtfs-feed-min/stop_times.txt create mode 100644 test/gtfs-feed-min/stops.txt create mode 100644 test/gtfs-feed-min/transfers.txt create mode 100644 test/gtfs-feed-min/trips.txt diff --git a/src/main/java/org/matsim/pt2matsim/gtfs/GtfsFeedImpl.java b/src/main/java/org/matsim/pt2matsim/gtfs/GtfsFeedImpl.java index 1259725..93f79e0 100755 --- a/src/main/java/org/matsim/pt2matsim/gtfs/GtfsFeedImpl.java +++ b/src/main/java/org/matsim/pt2matsim/gtfs/GtfsFeedImpl.java @@ -210,7 +210,9 @@ protected void loadAgencies() throws IOException { String[] line = reader.readNext(); while(line != null) { l++; - String agencyId = line[col.get(GtfsDefinitions.AGENCY_ID)]; + String agencyId = col.containsKey(GtfsDefinitions.AGENCY_ID) ? + line[col.get(GtfsDefinitions.AGENCY_ID)] : + line[col.get(GtfsDefinitions.AGENCY_NAME)]; AgencyImpl agency = new AgencyImpl(agencyId, line[col.get(GtfsDefinitions.AGENCY_NAME)], line[col.get(GtfsDefinitions.AGENCY_URL)], line[col.get(GtfsDefinitions.AGENCY_TIMEZONE)]); agencies.put(agencyId, agency); @@ -218,6 +220,12 @@ protected void loadAgencies() throws IOException { } reader.close(); + + if (this.agencies.isEmpty()) { + throw new IllegalArgumentException("agencies file must contain at least one agency!"); + } else if (this.agencies.size() > 1 && !col.containsKey(GtfsDefinitions.AGENCY_ID)) { + throw new IllegalArgumentException("agencies file has more than one entry but no id column!"); + } } catch (ArrayIndexOutOfBoundsException e) { throw new RuntimeException("Line " + l + " in agency.txt is empty or malformed."); } catch (CsvValidationException e) { @@ -442,7 +450,16 @@ protected void loadRoutes() throws IOException { CSVReader reader = createCSVReader(root + GtfsDefinitions.Files.ROUTES.fileName); String[] header = reader.readNext(); Map col = getIndices(header, GtfsDefinitions.Files.ROUTES.columns, GtfsDefinitions.Files.ROUTES.optionalColumns); - + if (!col.containsKey(GtfsDefinitions.ROUTE_SHORT_NAME) && !col.containsKey(GtfsDefinitions.ROUTE_LONG_NAME)) { + throw new IllegalArgumentException("at least one of 'route_short_name' or 'route_long_name' is required but the dataset has neither column!"); + } + Agency defaultAgency = null; + if (this.agencies.size() > 1 && !col.containsKey(GtfsDefinitions.AGENCY_ID)) { + throw new IllegalArgumentException("there is no column 'agency_id' in the routes file but there are multiple agencies in the agency file"); + } else if (this.agencies.size() == 1) { + defaultAgency = this.agencies.values().stream().findAny().get(); + } + String[] line = reader.readNext(); while(line != null) { l++; @@ -455,12 +472,18 @@ protected void loadRoutes() throws IOException { extendedRouteType = ExtendedRouteType.Unknown; } String routeId = line[col.get(GtfsDefinitions.ROUTE_ID)]; - String shortName = line[col.get(GtfsDefinitions.ROUTE_SHORT_NAME)]; - String longName = line[col.get(GtfsDefinitions.ROUTE_LONG_NAME)]; + String shortName = col.containsKey(GtfsDefinitions.ROUTE_SHORT_NAME) ? + line[col.get(GtfsDefinitions.ROUTE_SHORT_NAME)] : + line[col.get(GtfsDefinitions.ROUTE_LONG_NAME)]; + String longName = col.containsKey(GtfsDefinitions.ROUTE_LONG_NAME) ? + line[col.get(GtfsDefinitions.ROUTE_LONG_NAME)] : + line[col.get(GtfsDefinitions.ROUTE_SHORT_NAME)]; - Agency agency = this.agencies.get(line[col.get(GtfsDefinitions.AGENCY_ID)]); + Agency agency = col.containsKey(GtfsDefinitions.AGENCY_ID) ? + this.agencies.get(line[col.get(GtfsDefinitions.AGENCY_ID)]) : + defaultAgency; if (agency == null) { - throw new RuntimeException("Line " + l + " in routes.txt references unknown agency id " + line[col.get(GtfsDefinitions.AGENCY_ID)]); + throw new IllegalArgumentException("Line " + l + " in routes.txt references unknown agency id " + line[col.get(GtfsDefinitions.AGENCY_ID)]); } Route newGtfsRoute = new RouteImpl(routeId, shortName, longName, agency, extendedRouteType); routes.put(line[col.get(GtfsDefinitions.ROUTE_ID)], newGtfsRoute); diff --git a/src/main/java/org/matsim/pt2matsim/gtfs/lib/GtfsDefinitions.java b/src/main/java/org/matsim/pt2matsim/gtfs/lib/GtfsDefinitions.java index 3920579..a85dc28 100644 --- a/src/main/java/org/matsim/pt2matsim/gtfs/lib/GtfsDefinitions.java +++ b/src/main/java/org/matsim/pt2matsim/gtfs/lib/GtfsDefinitions.java @@ -108,8 +108,8 @@ public final class GtfsDefinitions { */ public enum Files { AGENCY("Agency", "agency.txt", - new String[]{AGENCY_ID, AGENCY_NAME, AGENCY_URL, AGENCY_TIMEZONE}, - new String[]{AGENCY_LANG, AGENCY_PHONE, AGENCY_FARE_URL, AGENCY_EMAIL}), + new String[]{AGENCY_NAME, AGENCY_URL, AGENCY_TIMEZONE}, + new String[]{AGENCY_ID, AGENCY_LANG, AGENCY_PHONE, AGENCY_FARE_URL, AGENCY_EMAIL}), STOPS("Stop", "stops.txt", new String[]{STOP_ID, STOP_LON, STOP_LAT, STOP_NAME}, @@ -132,8 +132,8 @@ public enum Files { ROUTES("Route", "routes.txt", - new String[]{ROUTE_ID, AGENCY_ID, ROUTE_SHORT_NAME, ROUTE_LONG_NAME, ROUTE_TYPE}, - new String[]{ROUTE_DESC, ROUTE_URL, ROUTE_COLOR, ROUTE_TEXT_COLOR}), + new String[]{ROUTE_ID, ROUTE_TYPE}, + new String[]{AGENCY_ID, ROUTE_SHORT_NAME, ROUTE_LONG_NAME, ROUTE_DESC, ROUTE_URL, ROUTE_COLOR, ROUTE_TEXT_COLOR}), TRIPS("Trip", "trips.txt", diff --git a/src/test/java/org/matsim/pt2matsim/gtfs/GtfsMinimalCaseTest.java b/src/test/java/org/matsim/pt2matsim/gtfs/GtfsMinimalCaseTest.java new file mode 100644 index 0000000..79f49d1 --- /dev/null +++ b/src/test/java/org/matsim/pt2matsim/gtfs/GtfsMinimalCaseTest.java @@ -0,0 +1,74 @@ +/* *********************************************************************** * + * project: org.matsim.* + * *********************************************************************** * + * * + * copyright : (C) 2016 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 static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.matsim.core.utils.geometry.transformations.TransformationFactory; +import org.matsim.pt2matsim.gtfs.lib.GtfsDefinitions; + +/** + * This test should check that ftfs datasets, that only do the bare minimum (i.e. do our best + * do not meet the conditions in "conditionally required" and omit the corresponding fields) + * are still converted correctly + * + * @author Tobias Kohl / Senozon + */ +class GtfsMinimalCaseTest { + + @Test + void noAgencyId() { + GtfsFeed feed = new GtfsFeedImpl("test/gtfs-feed-min/noAgencyId"); + feed.getRoutes().values().forEach(route -> Assertions.assertNotNull(route.getAgency(), "no agency in route " + route.getId())); + Assertions.assertEquals("pt2matsim", feed.getRoutes().get("lineA").getAgency().getAgencyName()); + Assertions.assertEquals("https://github.com/matsim-org/pt2matsim", feed.getRoutes().get("lineB").getAgency().getAgencyUrl()); + Assertions.assertEquals("Europe/Zurich", feed.getRoutes().get("lineC").getAgency().getAgencyTimeZone()); + } + + @Test + void noShortName() { + GtfsFeed feed = new GtfsFeedImpl("test/gtfs-feed-min/noShortName"); + Assertions.assertEquals("Bus Line A", feed.getRoutes().get("lineA").getShortName()); + Assertions.assertEquals("Bus Line A", feed.getRoutes().get("lineA").getLongName()); + Assertions.assertEquals(GtfsDefinitions.RouteType.BUS, feed.getRoutes().get("lineA").getRouteType()); + Assertions.assertEquals("P2M", feed.getRoutes().get("lineB").getAgency().getId()); + } + + @Test + void noLongName() { + GtfsFeed feed = new GtfsFeedImpl("test/gtfs-feed-min/noLongName"); + Assertions.assertEquals("Line A", feed.getRoutes().get("lineA").getShortName()); + Assertions.assertEquals("Line A", feed.getRoutes().get("lineA").getLongName()); + Assertions.assertEquals(GtfsDefinitions.RouteType.BUS, feed.getRoutes().get("lineA").getRouteType()); + Assertions.assertEquals("P2M", feed.getRoutes().get("lineB").getAgency().getId()); + } + + @Test + void noNameAtAll() { + Assertions.assertThrows(IllegalArgumentException.class, () -> new GtfsFeedImpl("test/gtfs-feed-min/noNameAtAll")); + } + + @Test + void multipleAgencies() { + Assertions.assertThrows(IllegalArgumentException.class, () -> new GtfsFeedImpl("test/gtfs-feed-min/multipleAgencies")); + } +} diff --git a/test/gtfs-feed-min/agency.txt b/test/gtfs-feed-min/agency.txt new file mode 100644 index 0000000..3aae780 --- /dev/null +++ b/test/gtfs-feed-min/agency.txt @@ -0,0 +1,2 @@ +agency_id,agency_name,agency_url,agency_timezone +P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich \ No newline at end of file diff --git a/test/gtfs-feed-min/calendar.txt b/test/gtfs-feed-min/calendar.txt new file mode 100644 index 0000000..5cac40a --- /dev/null +++ b/test/gtfs-feed-min/calendar.txt @@ -0,0 +1,5 @@ +service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date +WEEK,1,1,1,1,1,0,0,20181001,20181007 +EXPR,0,0,0,0,0,0,0,20181001,20181007 +WEND,0,0,0,0,0,1,1,20181001,20181007 +EMPT,1,0,1,1,0,1,0,20181001,20181007 \ No newline at end of file diff --git a/test/gtfs-feed-min/calendar_dates.txt b/test/gtfs-feed-min/calendar_dates.txt new file mode 100644 index 0000000..17fff58 --- /dev/null +++ b/test/gtfs-feed-min/calendar_dates.txt @@ -0,0 +1,6 @@ +service_id,date,exception_type +WEEK,20181006,2 +WEEK,20181007,2 +EXPR,20181005,1 +EMPT,20181002,1 +EMPT,20181001,2 \ No newline at end of file diff --git a/test/gtfs-feed-min/frequencies.txt b/test/gtfs-feed-min/frequencies.txt new file mode 100644 index 0000000..c46a8f4 --- /dev/null +++ b/test/gtfs-feed-min/frequencies.txt @@ -0,0 +1,4 @@ +trip_id,start_time,end_time,headway_secs,exact_times +routeA1,08:00:00,14:00:01,10800,0 +routeA2,09:00:00,15:00:01,10800,0 +routeB,07:00:00,16:00:01,10800,0 \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/agency.txt b/test/gtfs-feed-min/multipleAgencies/agency.txt new file mode 100644 index 0000000..670f5dc --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/agency.txt @@ -0,0 +1,3 @@ +agency_id,agency_name,agency_url,agency_timezone +P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich +S42,Service 42,htpps://google.com,Europe/Berlin \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/calendar.txt b/test/gtfs-feed-min/multipleAgencies/calendar.txt new file mode 100644 index 0000000..5cac40a --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/calendar.txt @@ -0,0 +1,5 @@ +service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date +WEEK,1,1,1,1,1,0,0,20181001,20181007 +EXPR,0,0,0,0,0,0,0,20181001,20181007 +WEND,0,0,0,0,0,1,1,20181001,20181007 +EMPT,1,0,1,1,0,1,0,20181001,20181007 \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/calendar_dates.txt b/test/gtfs-feed-min/multipleAgencies/calendar_dates.txt new file mode 100644 index 0000000..17fff58 --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/calendar_dates.txt @@ -0,0 +1,6 @@ +service_id,date,exception_type +WEEK,20181006,2 +WEEK,20181007,2 +EXPR,20181005,1 +EMPT,20181002,1 +EMPT,20181001,2 \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/frequencies.txt b/test/gtfs-feed-min/multipleAgencies/frequencies.txt new file mode 100644 index 0000000..c46a8f4 --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/frequencies.txt @@ -0,0 +1,4 @@ +trip_id,start_time,end_time,headway_secs,exact_times +routeA1,08:00:00,14:00:01,10800,0 +routeA2,09:00:00,15:00:01,10800,0 +routeB,07:00:00,16:00:01,10800,0 \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/routes.txt b/test/gtfs-feed-min/multipleAgencies/routes.txt new file mode 100644 index 0000000..6308199 --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/routes.txt @@ -0,0 +1,4 @@ +route_id,route_short_name,route_long_name,route_type +lineA,Line A,Bus Line A,3 +lineB,Line B,Tram Line B,0 +lineC,Line C,Something else,907 \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/shapes.txt b/test/gtfs-feed-min/multipleAgencies/shapes.txt new file mode 100644 index 0000000..cbaff1c --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/shapes.txt @@ -0,0 +1,22 @@ +shape_id,shape_pt_lon,shape_pt_lat,shape_pt_sequence +A1,7.438899946082748,46.95162082278473,1 +A1,7.43916266994327,46.95162082188145,2 +A1,7.43916266818439,46.951440917895496,3 +A1,7.439294030224575,46.95148589321508,4 +A1,7.4394253911654555,46.951440916390055,5 +A1,7.439425388527151,46.951261012398504,6 +A2,7.439451661009937,46.95127900261426,1 +A2,7.439451663736189,46.95145890660527,2 +A2,7.4393203027733215,46.95150388346022,3 +A2,7.439188940667179,46.95145890817091,4 +A2,7.439188942514004,46.951638812156304,5 +A2,7.438926218565539,46.9516388131198,6 +B,7.438899946082748,46.95162082278473,1 +B,7.439031308672595,46.95171077439923,2 +B,7.43916266994327,46.95162082188145,3 +B,7.4394253938037815,46.951620820376,4 +B,7.439294030224575,46.95148589321508,5 +B,7.43916266818439,46.951440917895496,6 +B,7.439162667304952,46.951350965900424,7 +B,7.4392940263770475,46.951171061228614,8 +B,7.439425388527151,46.951261012398504,9 \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/stop_times.txt b/test/gtfs-feed-min/multipleAgencies/stop_times.txt new file mode 100644 index 0000000..26002a9 --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/stop_times.txt @@ -0,0 +1,27 @@ +trip_id,arrival_time,departure_time,stop_id,stop_sequence +routeA1,00:00:00,00:00:00,stop1,1 +routeA1,00:00:20,00:00:20,stop2,2 +routeA1,00:00:40,00:00:40,stop3,3 +routeA1,00:01:20,00:01:20,stop4,4 +routeA2,00:01:20,00:01:20,stop1,4 +routeA2,00:01:00,00:01:00,stop2,3 +routeA2,00:00:40,00:00:40,stop3,2 +routeA2,00:00:00,00:00:00,stop4,1 +routeB,00:00:00,00:00:00,stop1,1 +routeB,00:01:20,00:01:20,stop3,2 +routeB,00:01:40,00:01:40,stop5,3 +routeB,00:02:20,00:02:20,stop6,4 +routeB,00:02:40,00:02:40,stop4,5 +routeA1_weekend,00:00:00,00:00:00,stop1,1 +routeA1_weekend,00:00:30,00:00:20,stop2,2 +routeA1_weekend,00:01:00,00:00:40,stop3,3 +routeA1_weekend,00:01:30,00:01:20,stop4,4 +routeA2_weekend,00:00:00,00:00:00,stop4,1 +routeA2_weekend,00:00:30,00:00:30,stop3,2 +routeA2_weekend,00:01:00,00:01:00,stop2,3 +routeA2_weekend,00:01:30,00:01:30,stop1,4 +routeB_weekend,00:00:00,00:00:00,stop1,1 +routeB_weekend,00:01:00,00:01:00,stop3,2 +routeB_weekend,00:02:00,00:02:00,stop5,3 +routeB_weekend,00:03:00,00:03:00,stop6,4 +routeB_weekend,00:04:00,00:04:00,stop4,5 \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/stops.txt b/test/gtfs-feed-min/multipleAgencies/stops.txt new file mode 100644 index 0000000..48e73ce --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/stops.txt @@ -0,0 +1,7 @@ +stop_id,stop_name,stop_lat,stop_lon +stop1,One,46.95162082275386,7.438913082275775 +stop2,Two,46.95153086988918,7.439162669063829 +stop3,Three,46.95147689809022,7.439280893956796 +stop4,Four,46.95127900232747,7.439491069338372 +stop5,Five,46.9513959419576,7.439149531606609 +stop6,Six,46.95121603683256,7.439359707397135 \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/transfers.txt b/test/gtfs-feed-min/multipleAgencies/transfers.txt new file mode 100644 index 0000000..2c4d907 --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/transfers.txt @@ -0,0 +1,7 @@ +from_stop_id,to_stop_id,transfer_type,min_transfer_time +stop2,stop3,0,-99 +stop3,stop2,1,-99 +stop3,stop4,2,10 +stop4,stop3,2,10 +stop4,stop1,3, +stop1,stop4,3, \ No newline at end of file diff --git a/test/gtfs-feed-min/multipleAgencies/trips.txt b/test/gtfs-feed-min/multipleAgencies/trips.txt new file mode 100644 index 0000000..3aba2fa --- /dev/null +++ b/test/gtfs-feed-min/multipleAgencies/trips.txt @@ -0,0 +1,7 @@ +route_id,service_id,trip_id,shape_id +lineA,WEEK,routeA1,shapeA1 +lineA,WEEK,routeA2,shapeA2 +lineB,EXPR,routeB,shapeB +lineA,WEND,routeA1_weekend,shapeA1 +lineA,WEND,routeA2_weekend,shapeA2 +lineB,WEND,routeB_weekend,shapeB \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/agency.txt b/test/gtfs-feed-min/noAgencyId/agency.txt new file mode 100644 index 0000000..3aae780 --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/agency.txt @@ -0,0 +1,2 @@ +agency_id,agency_name,agency_url,agency_timezone +P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/calendar.txt b/test/gtfs-feed-min/noAgencyId/calendar.txt new file mode 100644 index 0000000..5cac40a --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/calendar.txt @@ -0,0 +1,5 @@ +service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date +WEEK,1,1,1,1,1,0,0,20181001,20181007 +EXPR,0,0,0,0,0,0,0,20181001,20181007 +WEND,0,0,0,0,0,1,1,20181001,20181007 +EMPT,1,0,1,1,0,1,0,20181001,20181007 \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/calendar_dates.txt b/test/gtfs-feed-min/noAgencyId/calendar_dates.txt new file mode 100644 index 0000000..17fff58 --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/calendar_dates.txt @@ -0,0 +1,6 @@ +service_id,date,exception_type +WEEK,20181006,2 +WEEK,20181007,2 +EXPR,20181005,1 +EMPT,20181002,1 +EMPT,20181001,2 \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/frequencies.txt b/test/gtfs-feed-min/noAgencyId/frequencies.txt new file mode 100644 index 0000000..c46a8f4 --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/frequencies.txt @@ -0,0 +1,4 @@ +trip_id,start_time,end_time,headway_secs,exact_times +routeA1,08:00:00,14:00:01,10800,0 +routeA2,09:00:00,15:00:01,10800,0 +routeB,07:00:00,16:00:01,10800,0 \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/routes.txt b/test/gtfs-feed-min/noAgencyId/routes.txt new file mode 100644 index 0000000..6308199 --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/routes.txt @@ -0,0 +1,4 @@ +route_id,route_short_name,route_long_name,route_type +lineA,Line A,Bus Line A,3 +lineB,Line B,Tram Line B,0 +lineC,Line C,Something else,907 \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/shapes.txt b/test/gtfs-feed-min/noAgencyId/shapes.txt new file mode 100644 index 0000000..cbaff1c --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/shapes.txt @@ -0,0 +1,22 @@ +shape_id,shape_pt_lon,shape_pt_lat,shape_pt_sequence +A1,7.438899946082748,46.95162082278473,1 +A1,7.43916266994327,46.95162082188145,2 +A1,7.43916266818439,46.951440917895496,3 +A1,7.439294030224575,46.95148589321508,4 +A1,7.4394253911654555,46.951440916390055,5 +A1,7.439425388527151,46.951261012398504,6 +A2,7.439451661009937,46.95127900261426,1 +A2,7.439451663736189,46.95145890660527,2 +A2,7.4393203027733215,46.95150388346022,3 +A2,7.439188940667179,46.95145890817091,4 +A2,7.439188942514004,46.951638812156304,5 +A2,7.438926218565539,46.9516388131198,6 +B,7.438899946082748,46.95162082278473,1 +B,7.439031308672595,46.95171077439923,2 +B,7.43916266994327,46.95162082188145,3 +B,7.4394253938037815,46.951620820376,4 +B,7.439294030224575,46.95148589321508,5 +B,7.43916266818439,46.951440917895496,6 +B,7.439162667304952,46.951350965900424,7 +B,7.4392940263770475,46.951171061228614,8 +B,7.439425388527151,46.951261012398504,9 \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/stop_times.txt b/test/gtfs-feed-min/noAgencyId/stop_times.txt new file mode 100644 index 0000000..26002a9 --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/stop_times.txt @@ -0,0 +1,27 @@ +trip_id,arrival_time,departure_time,stop_id,stop_sequence +routeA1,00:00:00,00:00:00,stop1,1 +routeA1,00:00:20,00:00:20,stop2,2 +routeA1,00:00:40,00:00:40,stop3,3 +routeA1,00:01:20,00:01:20,stop4,4 +routeA2,00:01:20,00:01:20,stop1,4 +routeA2,00:01:00,00:01:00,stop2,3 +routeA2,00:00:40,00:00:40,stop3,2 +routeA2,00:00:00,00:00:00,stop4,1 +routeB,00:00:00,00:00:00,stop1,1 +routeB,00:01:20,00:01:20,stop3,2 +routeB,00:01:40,00:01:40,stop5,3 +routeB,00:02:20,00:02:20,stop6,4 +routeB,00:02:40,00:02:40,stop4,5 +routeA1_weekend,00:00:00,00:00:00,stop1,1 +routeA1_weekend,00:00:30,00:00:20,stop2,2 +routeA1_weekend,00:01:00,00:00:40,stop3,3 +routeA1_weekend,00:01:30,00:01:20,stop4,4 +routeA2_weekend,00:00:00,00:00:00,stop4,1 +routeA2_weekend,00:00:30,00:00:30,stop3,2 +routeA2_weekend,00:01:00,00:01:00,stop2,3 +routeA2_weekend,00:01:30,00:01:30,stop1,4 +routeB_weekend,00:00:00,00:00:00,stop1,1 +routeB_weekend,00:01:00,00:01:00,stop3,2 +routeB_weekend,00:02:00,00:02:00,stop5,3 +routeB_weekend,00:03:00,00:03:00,stop6,4 +routeB_weekend,00:04:00,00:04:00,stop4,5 \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/stops.txt b/test/gtfs-feed-min/noAgencyId/stops.txt new file mode 100644 index 0000000..48e73ce --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/stops.txt @@ -0,0 +1,7 @@ +stop_id,stop_name,stop_lat,stop_lon +stop1,One,46.95162082275386,7.438913082275775 +stop2,Two,46.95153086988918,7.439162669063829 +stop3,Three,46.95147689809022,7.439280893956796 +stop4,Four,46.95127900232747,7.439491069338372 +stop5,Five,46.9513959419576,7.439149531606609 +stop6,Six,46.95121603683256,7.439359707397135 \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/transfers.txt b/test/gtfs-feed-min/noAgencyId/transfers.txt new file mode 100644 index 0000000..2c4d907 --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/transfers.txt @@ -0,0 +1,7 @@ +from_stop_id,to_stop_id,transfer_type,min_transfer_time +stop2,stop3,0,-99 +stop3,stop2,1,-99 +stop3,stop4,2,10 +stop4,stop3,2,10 +stop4,stop1,3, +stop1,stop4,3, \ No newline at end of file diff --git a/test/gtfs-feed-min/noAgencyId/trips.txt b/test/gtfs-feed-min/noAgencyId/trips.txt new file mode 100644 index 0000000..3aba2fa --- /dev/null +++ b/test/gtfs-feed-min/noAgencyId/trips.txt @@ -0,0 +1,7 @@ +route_id,service_id,trip_id,shape_id +lineA,WEEK,routeA1,shapeA1 +lineA,WEEK,routeA2,shapeA2 +lineB,EXPR,routeB,shapeB +lineA,WEND,routeA1_weekend,shapeA1 +lineA,WEND,routeA2_weekend,shapeA2 +lineB,WEND,routeB_weekend,shapeB \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/agency.txt b/test/gtfs-feed-min/noLongName/agency.txt new file mode 100644 index 0000000..670f5dc --- /dev/null +++ b/test/gtfs-feed-min/noLongName/agency.txt @@ -0,0 +1,3 @@ +agency_id,agency_name,agency_url,agency_timezone +P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich +S42,Service 42,htpps://google.com,Europe/Berlin \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/calendar.txt b/test/gtfs-feed-min/noLongName/calendar.txt new file mode 100644 index 0000000..5cac40a --- /dev/null +++ b/test/gtfs-feed-min/noLongName/calendar.txt @@ -0,0 +1,5 @@ +service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date +WEEK,1,1,1,1,1,0,0,20181001,20181007 +EXPR,0,0,0,0,0,0,0,20181001,20181007 +WEND,0,0,0,0,0,1,1,20181001,20181007 +EMPT,1,0,1,1,0,1,0,20181001,20181007 \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/calendar_dates.txt b/test/gtfs-feed-min/noLongName/calendar_dates.txt new file mode 100644 index 0000000..17fff58 --- /dev/null +++ b/test/gtfs-feed-min/noLongName/calendar_dates.txt @@ -0,0 +1,6 @@ +service_id,date,exception_type +WEEK,20181006,2 +WEEK,20181007,2 +EXPR,20181005,1 +EMPT,20181002,1 +EMPT,20181001,2 \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/frequencies.txt b/test/gtfs-feed-min/noLongName/frequencies.txt new file mode 100644 index 0000000..c46a8f4 --- /dev/null +++ b/test/gtfs-feed-min/noLongName/frequencies.txt @@ -0,0 +1,4 @@ +trip_id,start_time,end_time,headway_secs,exact_times +routeA1,08:00:00,14:00:01,10800,0 +routeA2,09:00:00,15:00:01,10800,0 +routeB,07:00:00,16:00:01,10800,0 \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/routes.txt b/test/gtfs-feed-min/noLongName/routes.txt new file mode 100644 index 0000000..2119899 --- /dev/null +++ b/test/gtfs-feed-min/noLongName/routes.txt @@ -0,0 +1,4 @@ +route_id,route_short_name,route_type,agency_id +lineA,Line A,3,S42 +lineB,Line B,0,P2M +lineC,Line C,907,P2M \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/shapes.txt b/test/gtfs-feed-min/noLongName/shapes.txt new file mode 100644 index 0000000..cbaff1c --- /dev/null +++ b/test/gtfs-feed-min/noLongName/shapes.txt @@ -0,0 +1,22 @@ +shape_id,shape_pt_lon,shape_pt_lat,shape_pt_sequence +A1,7.438899946082748,46.95162082278473,1 +A1,7.43916266994327,46.95162082188145,2 +A1,7.43916266818439,46.951440917895496,3 +A1,7.439294030224575,46.95148589321508,4 +A1,7.4394253911654555,46.951440916390055,5 +A1,7.439425388527151,46.951261012398504,6 +A2,7.439451661009937,46.95127900261426,1 +A2,7.439451663736189,46.95145890660527,2 +A2,7.4393203027733215,46.95150388346022,3 +A2,7.439188940667179,46.95145890817091,4 +A2,7.439188942514004,46.951638812156304,5 +A2,7.438926218565539,46.9516388131198,6 +B,7.438899946082748,46.95162082278473,1 +B,7.439031308672595,46.95171077439923,2 +B,7.43916266994327,46.95162082188145,3 +B,7.4394253938037815,46.951620820376,4 +B,7.439294030224575,46.95148589321508,5 +B,7.43916266818439,46.951440917895496,6 +B,7.439162667304952,46.951350965900424,7 +B,7.4392940263770475,46.951171061228614,8 +B,7.439425388527151,46.951261012398504,9 \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/stop_times.txt b/test/gtfs-feed-min/noLongName/stop_times.txt new file mode 100644 index 0000000..26002a9 --- /dev/null +++ b/test/gtfs-feed-min/noLongName/stop_times.txt @@ -0,0 +1,27 @@ +trip_id,arrival_time,departure_time,stop_id,stop_sequence +routeA1,00:00:00,00:00:00,stop1,1 +routeA1,00:00:20,00:00:20,stop2,2 +routeA1,00:00:40,00:00:40,stop3,3 +routeA1,00:01:20,00:01:20,stop4,4 +routeA2,00:01:20,00:01:20,stop1,4 +routeA2,00:01:00,00:01:00,stop2,3 +routeA2,00:00:40,00:00:40,stop3,2 +routeA2,00:00:00,00:00:00,stop4,1 +routeB,00:00:00,00:00:00,stop1,1 +routeB,00:01:20,00:01:20,stop3,2 +routeB,00:01:40,00:01:40,stop5,3 +routeB,00:02:20,00:02:20,stop6,4 +routeB,00:02:40,00:02:40,stop4,5 +routeA1_weekend,00:00:00,00:00:00,stop1,1 +routeA1_weekend,00:00:30,00:00:20,stop2,2 +routeA1_weekend,00:01:00,00:00:40,stop3,3 +routeA1_weekend,00:01:30,00:01:20,stop4,4 +routeA2_weekend,00:00:00,00:00:00,stop4,1 +routeA2_weekend,00:00:30,00:00:30,stop3,2 +routeA2_weekend,00:01:00,00:01:00,stop2,3 +routeA2_weekend,00:01:30,00:01:30,stop1,4 +routeB_weekend,00:00:00,00:00:00,stop1,1 +routeB_weekend,00:01:00,00:01:00,stop3,2 +routeB_weekend,00:02:00,00:02:00,stop5,3 +routeB_weekend,00:03:00,00:03:00,stop6,4 +routeB_weekend,00:04:00,00:04:00,stop4,5 \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/stops.txt b/test/gtfs-feed-min/noLongName/stops.txt new file mode 100644 index 0000000..48e73ce --- /dev/null +++ b/test/gtfs-feed-min/noLongName/stops.txt @@ -0,0 +1,7 @@ +stop_id,stop_name,stop_lat,stop_lon +stop1,One,46.95162082275386,7.438913082275775 +stop2,Two,46.95153086988918,7.439162669063829 +stop3,Three,46.95147689809022,7.439280893956796 +stop4,Four,46.95127900232747,7.439491069338372 +stop5,Five,46.9513959419576,7.439149531606609 +stop6,Six,46.95121603683256,7.439359707397135 \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/transfers.txt b/test/gtfs-feed-min/noLongName/transfers.txt new file mode 100644 index 0000000..2c4d907 --- /dev/null +++ b/test/gtfs-feed-min/noLongName/transfers.txt @@ -0,0 +1,7 @@ +from_stop_id,to_stop_id,transfer_type,min_transfer_time +stop2,stop3,0,-99 +stop3,stop2,1,-99 +stop3,stop4,2,10 +stop4,stop3,2,10 +stop4,stop1,3, +stop1,stop4,3, \ No newline at end of file diff --git a/test/gtfs-feed-min/noLongName/trips.txt b/test/gtfs-feed-min/noLongName/trips.txt new file mode 100644 index 0000000..3aba2fa --- /dev/null +++ b/test/gtfs-feed-min/noLongName/trips.txt @@ -0,0 +1,7 @@ +route_id,service_id,trip_id,shape_id +lineA,WEEK,routeA1,shapeA1 +lineA,WEEK,routeA2,shapeA2 +lineB,EXPR,routeB,shapeB +lineA,WEND,routeA1_weekend,shapeA1 +lineA,WEND,routeA2_weekend,shapeA2 +lineB,WEND,routeB_weekend,shapeB \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/agency.txt b/test/gtfs-feed-min/noNameAtAll/agency.txt new file mode 100644 index 0000000..670f5dc --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/agency.txt @@ -0,0 +1,3 @@ +agency_id,agency_name,agency_url,agency_timezone +P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich +S42,Service 42,htpps://google.com,Europe/Berlin \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/calendar.txt b/test/gtfs-feed-min/noNameAtAll/calendar.txt new file mode 100644 index 0000000..5cac40a --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/calendar.txt @@ -0,0 +1,5 @@ +service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date +WEEK,1,1,1,1,1,0,0,20181001,20181007 +EXPR,0,0,0,0,0,0,0,20181001,20181007 +WEND,0,0,0,0,0,1,1,20181001,20181007 +EMPT,1,0,1,1,0,1,0,20181001,20181007 \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/calendar_dates.txt b/test/gtfs-feed-min/noNameAtAll/calendar_dates.txt new file mode 100644 index 0000000..17fff58 --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/calendar_dates.txt @@ -0,0 +1,6 @@ +service_id,date,exception_type +WEEK,20181006,2 +WEEK,20181007,2 +EXPR,20181005,1 +EMPT,20181002,1 +EMPT,20181001,2 \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/frequencies.txt b/test/gtfs-feed-min/noNameAtAll/frequencies.txt new file mode 100644 index 0000000..c46a8f4 --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/frequencies.txt @@ -0,0 +1,4 @@ +trip_id,start_time,end_time,headway_secs,exact_times +routeA1,08:00:00,14:00:01,10800,0 +routeA2,09:00:00,15:00:01,10800,0 +routeB,07:00:00,16:00:01,10800,0 \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/routes.txt b/test/gtfs-feed-min/noNameAtAll/routes.txt new file mode 100644 index 0000000..0cdb6f2 --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/routes.txt @@ -0,0 +1,4 @@ +route_id,route_type,agency_id +lineA,3,S42 +lineB,0,P2M +lineC,907,P2M \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/shapes.txt b/test/gtfs-feed-min/noNameAtAll/shapes.txt new file mode 100644 index 0000000..cbaff1c --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/shapes.txt @@ -0,0 +1,22 @@ +shape_id,shape_pt_lon,shape_pt_lat,shape_pt_sequence +A1,7.438899946082748,46.95162082278473,1 +A1,7.43916266994327,46.95162082188145,2 +A1,7.43916266818439,46.951440917895496,3 +A1,7.439294030224575,46.95148589321508,4 +A1,7.4394253911654555,46.951440916390055,5 +A1,7.439425388527151,46.951261012398504,6 +A2,7.439451661009937,46.95127900261426,1 +A2,7.439451663736189,46.95145890660527,2 +A2,7.4393203027733215,46.95150388346022,3 +A2,7.439188940667179,46.95145890817091,4 +A2,7.439188942514004,46.951638812156304,5 +A2,7.438926218565539,46.9516388131198,6 +B,7.438899946082748,46.95162082278473,1 +B,7.439031308672595,46.95171077439923,2 +B,7.43916266994327,46.95162082188145,3 +B,7.4394253938037815,46.951620820376,4 +B,7.439294030224575,46.95148589321508,5 +B,7.43916266818439,46.951440917895496,6 +B,7.439162667304952,46.951350965900424,7 +B,7.4392940263770475,46.951171061228614,8 +B,7.439425388527151,46.951261012398504,9 \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/stop_times.txt b/test/gtfs-feed-min/noNameAtAll/stop_times.txt new file mode 100644 index 0000000..26002a9 --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/stop_times.txt @@ -0,0 +1,27 @@ +trip_id,arrival_time,departure_time,stop_id,stop_sequence +routeA1,00:00:00,00:00:00,stop1,1 +routeA1,00:00:20,00:00:20,stop2,2 +routeA1,00:00:40,00:00:40,stop3,3 +routeA1,00:01:20,00:01:20,stop4,4 +routeA2,00:01:20,00:01:20,stop1,4 +routeA2,00:01:00,00:01:00,stop2,3 +routeA2,00:00:40,00:00:40,stop3,2 +routeA2,00:00:00,00:00:00,stop4,1 +routeB,00:00:00,00:00:00,stop1,1 +routeB,00:01:20,00:01:20,stop3,2 +routeB,00:01:40,00:01:40,stop5,3 +routeB,00:02:20,00:02:20,stop6,4 +routeB,00:02:40,00:02:40,stop4,5 +routeA1_weekend,00:00:00,00:00:00,stop1,1 +routeA1_weekend,00:00:30,00:00:20,stop2,2 +routeA1_weekend,00:01:00,00:00:40,stop3,3 +routeA1_weekend,00:01:30,00:01:20,stop4,4 +routeA2_weekend,00:00:00,00:00:00,stop4,1 +routeA2_weekend,00:00:30,00:00:30,stop3,2 +routeA2_weekend,00:01:00,00:01:00,stop2,3 +routeA2_weekend,00:01:30,00:01:30,stop1,4 +routeB_weekend,00:00:00,00:00:00,stop1,1 +routeB_weekend,00:01:00,00:01:00,stop3,2 +routeB_weekend,00:02:00,00:02:00,stop5,3 +routeB_weekend,00:03:00,00:03:00,stop6,4 +routeB_weekend,00:04:00,00:04:00,stop4,5 \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/stops.txt b/test/gtfs-feed-min/noNameAtAll/stops.txt new file mode 100644 index 0000000..48e73ce --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/stops.txt @@ -0,0 +1,7 @@ +stop_id,stop_name,stop_lat,stop_lon +stop1,One,46.95162082275386,7.438913082275775 +stop2,Two,46.95153086988918,7.439162669063829 +stop3,Three,46.95147689809022,7.439280893956796 +stop4,Four,46.95127900232747,7.439491069338372 +stop5,Five,46.9513959419576,7.439149531606609 +stop6,Six,46.95121603683256,7.439359707397135 \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/transfers.txt b/test/gtfs-feed-min/noNameAtAll/transfers.txt new file mode 100644 index 0000000..2c4d907 --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/transfers.txt @@ -0,0 +1,7 @@ +from_stop_id,to_stop_id,transfer_type,min_transfer_time +stop2,stop3,0,-99 +stop3,stop2,1,-99 +stop3,stop4,2,10 +stop4,stop3,2,10 +stop4,stop1,3, +stop1,stop4,3, \ No newline at end of file diff --git a/test/gtfs-feed-min/noNameAtAll/trips.txt b/test/gtfs-feed-min/noNameAtAll/trips.txt new file mode 100644 index 0000000..3aba2fa --- /dev/null +++ b/test/gtfs-feed-min/noNameAtAll/trips.txt @@ -0,0 +1,7 @@ +route_id,service_id,trip_id,shape_id +lineA,WEEK,routeA1,shapeA1 +lineA,WEEK,routeA2,shapeA2 +lineB,EXPR,routeB,shapeB +lineA,WEND,routeA1_weekend,shapeA1 +lineA,WEND,routeA2_weekend,shapeA2 +lineB,WEND,routeB_weekend,shapeB \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/agency.txt b/test/gtfs-feed-min/noShortName/agency.txt new file mode 100644 index 0000000..670f5dc --- /dev/null +++ b/test/gtfs-feed-min/noShortName/agency.txt @@ -0,0 +1,3 @@ +agency_id,agency_name,agency_url,agency_timezone +P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich +S42,Service 42,htpps://google.com,Europe/Berlin \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/calendar.txt b/test/gtfs-feed-min/noShortName/calendar.txt new file mode 100644 index 0000000..5cac40a --- /dev/null +++ b/test/gtfs-feed-min/noShortName/calendar.txt @@ -0,0 +1,5 @@ +service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date +WEEK,1,1,1,1,1,0,0,20181001,20181007 +EXPR,0,0,0,0,0,0,0,20181001,20181007 +WEND,0,0,0,0,0,1,1,20181001,20181007 +EMPT,1,0,1,1,0,1,0,20181001,20181007 \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/calendar_dates.txt b/test/gtfs-feed-min/noShortName/calendar_dates.txt new file mode 100644 index 0000000..17fff58 --- /dev/null +++ b/test/gtfs-feed-min/noShortName/calendar_dates.txt @@ -0,0 +1,6 @@ +service_id,date,exception_type +WEEK,20181006,2 +WEEK,20181007,2 +EXPR,20181005,1 +EMPT,20181002,1 +EMPT,20181001,2 \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/frequencies.txt b/test/gtfs-feed-min/noShortName/frequencies.txt new file mode 100644 index 0000000..c46a8f4 --- /dev/null +++ b/test/gtfs-feed-min/noShortName/frequencies.txt @@ -0,0 +1,4 @@ +trip_id,start_time,end_time,headway_secs,exact_times +routeA1,08:00:00,14:00:01,10800,0 +routeA2,09:00:00,15:00:01,10800,0 +routeB,07:00:00,16:00:01,10800,0 \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/routes.txt b/test/gtfs-feed-min/noShortName/routes.txt new file mode 100644 index 0000000..fa112cb --- /dev/null +++ b/test/gtfs-feed-min/noShortName/routes.txt @@ -0,0 +1,4 @@ +route_id,route_long_name,route_type,agency_id, +lineA,Bus Line A,3,S42 +lineB,Tram Line B,0,P2M +lineC,Something else,907,P2M \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/shapes.txt b/test/gtfs-feed-min/noShortName/shapes.txt new file mode 100644 index 0000000..cbaff1c --- /dev/null +++ b/test/gtfs-feed-min/noShortName/shapes.txt @@ -0,0 +1,22 @@ +shape_id,shape_pt_lon,shape_pt_lat,shape_pt_sequence +A1,7.438899946082748,46.95162082278473,1 +A1,7.43916266994327,46.95162082188145,2 +A1,7.43916266818439,46.951440917895496,3 +A1,7.439294030224575,46.95148589321508,4 +A1,7.4394253911654555,46.951440916390055,5 +A1,7.439425388527151,46.951261012398504,6 +A2,7.439451661009937,46.95127900261426,1 +A2,7.439451663736189,46.95145890660527,2 +A2,7.4393203027733215,46.95150388346022,3 +A2,7.439188940667179,46.95145890817091,4 +A2,7.439188942514004,46.951638812156304,5 +A2,7.438926218565539,46.9516388131198,6 +B,7.438899946082748,46.95162082278473,1 +B,7.439031308672595,46.95171077439923,2 +B,7.43916266994327,46.95162082188145,3 +B,7.4394253938037815,46.951620820376,4 +B,7.439294030224575,46.95148589321508,5 +B,7.43916266818439,46.951440917895496,6 +B,7.439162667304952,46.951350965900424,7 +B,7.4392940263770475,46.951171061228614,8 +B,7.439425388527151,46.951261012398504,9 \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/stop_times.txt b/test/gtfs-feed-min/noShortName/stop_times.txt new file mode 100644 index 0000000..26002a9 --- /dev/null +++ b/test/gtfs-feed-min/noShortName/stop_times.txt @@ -0,0 +1,27 @@ +trip_id,arrival_time,departure_time,stop_id,stop_sequence +routeA1,00:00:00,00:00:00,stop1,1 +routeA1,00:00:20,00:00:20,stop2,2 +routeA1,00:00:40,00:00:40,stop3,3 +routeA1,00:01:20,00:01:20,stop4,4 +routeA2,00:01:20,00:01:20,stop1,4 +routeA2,00:01:00,00:01:00,stop2,3 +routeA2,00:00:40,00:00:40,stop3,2 +routeA2,00:00:00,00:00:00,stop4,1 +routeB,00:00:00,00:00:00,stop1,1 +routeB,00:01:20,00:01:20,stop3,2 +routeB,00:01:40,00:01:40,stop5,3 +routeB,00:02:20,00:02:20,stop6,4 +routeB,00:02:40,00:02:40,stop4,5 +routeA1_weekend,00:00:00,00:00:00,stop1,1 +routeA1_weekend,00:00:30,00:00:20,stop2,2 +routeA1_weekend,00:01:00,00:00:40,stop3,3 +routeA1_weekend,00:01:30,00:01:20,stop4,4 +routeA2_weekend,00:00:00,00:00:00,stop4,1 +routeA2_weekend,00:00:30,00:00:30,stop3,2 +routeA2_weekend,00:01:00,00:01:00,stop2,3 +routeA2_weekend,00:01:30,00:01:30,stop1,4 +routeB_weekend,00:00:00,00:00:00,stop1,1 +routeB_weekend,00:01:00,00:01:00,stop3,2 +routeB_weekend,00:02:00,00:02:00,stop5,3 +routeB_weekend,00:03:00,00:03:00,stop6,4 +routeB_weekend,00:04:00,00:04:00,stop4,5 \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/stops.txt b/test/gtfs-feed-min/noShortName/stops.txt new file mode 100644 index 0000000..48e73ce --- /dev/null +++ b/test/gtfs-feed-min/noShortName/stops.txt @@ -0,0 +1,7 @@ +stop_id,stop_name,stop_lat,stop_lon +stop1,One,46.95162082275386,7.438913082275775 +stop2,Two,46.95153086988918,7.439162669063829 +stop3,Three,46.95147689809022,7.439280893956796 +stop4,Four,46.95127900232747,7.439491069338372 +stop5,Five,46.9513959419576,7.439149531606609 +stop6,Six,46.95121603683256,7.439359707397135 \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/transfers.txt b/test/gtfs-feed-min/noShortName/transfers.txt new file mode 100644 index 0000000..2c4d907 --- /dev/null +++ b/test/gtfs-feed-min/noShortName/transfers.txt @@ -0,0 +1,7 @@ +from_stop_id,to_stop_id,transfer_type,min_transfer_time +stop2,stop3,0,-99 +stop3,stop2,1,-99 +stop3,stop4,2,10 +stop4,stop3,2,10 +stop4,stop1,3, +stop1,stop4,3, \ No newline at end of file diff --git a/test/gtfs-feed-min/noShortName/trips.txt b/test/gtfs-feed-min/noShortName/trips.txt new file mode 100644 index 0000000..3aba2fa --- /dev/null +++ b/test/gtfs-feed-min/noShortName/trips.txt @@ -0,0 +1,7 @@ +route_id,service_id,trip_id,shape_id +lineA,WEEK,routeA1,shapeA1 +lineA,WEEK,routeA2,shapeA2 +lineB,EXPR,routeB,shapeB +lineA,WEND,routeA1_weekend,shapeA1 +lineA,WEND,routeA2_weekend,shapeA2 +lineB,WEND,routeB_weekend,shapeB \ No newline at end of file diff --git a/test/gtfs-feed-min/routes.txt b/test/gtfs-feed-min/routes.txt new file mode 100644 index 0000000..9e0f1e5 --- /dev/null +++ b/test/gtfs-feed-min/routes.txt @@ -0,0 +1,4 @@ +route_id,route_long_name,route_type +lineA,Bus Line A,3 +lineB,Tram Line B,0 +lineC,Something else,907 \ No newline at end of file diff --git a/test/gtfs-feed-min/shapes.txt b/test/gtfs-feed-min/shapes.txt new file mode 100644 index 0000000..cbaff1c --- /dev/null +++ b/test/gtfs-feed-min/shapes.txt @@ -0,0 +1,22 @@ +shape_id,shape_pt_lon,shape_pt_lat,shape_pt_sequence +A1,7.438899946082748,46.95162082278473,1 +A1,7.43916266994327,46.95162082188145,2 +A1,7.43916266818439,46.951440917895496,3 +A1,7.439294030224575,46.95148589321508,4 +A1,7.4394253911654555,46.951440916390055,5 +A1,7.439425388527151,46.951261012398504,6 +A2,7.439451661009937,46.95127900261426,1 +A2,7.439451663736189,46.95145890660527,2 +A2,7.4393203027733215,46.95150388346022,3 +A2,7.439188940667179,46.95145890817091,4 +A2,7.439188942514004,46.951638812156304,5 +A2,7.438926218565539,46.9516388131198,6 +B,7.438899946082748,46.95162082278473,1 +B,7.439031308672595,46.95171077439923,2 +B,7.43916266994327,46.95162082188145,3 +B,7.4394253938037815,46.951620820376,4 +B,7.439294030224575,46.95148589321508,5 +B,7.43916266818439,46.951440917895496,6 +B,7.439162667304952,46.951350965900424,7 +B,7.4392940263770475,46.951171061228614,8 +B,7.439425388527151,46.951261012398504,9 \ No newline at end of file diff --git a/test/gtfs-feed-min/stop_times.txt b/test/gtfs-feed-min/stop_times.txt new file mode 100644 index 0000000..26002a9 --- /dev/null +++ b/test/gtfs-feed-min/stop_times.txt @@ -0,0 +1,27 @@ +trip_id,arrival_time,departure_time,stop_id,stop_sequence +routeA1,00:00:00,00:00:00,stop1,1 +routeA1,00:00:20,00:00:20,stop2,2 +routeA1,00:00:40,00:00:40,stop3,3 +routeA1,00:01:20,00:01:20,stop4,4 +routeA2,00:01:20,00:01:20,stop1,4 +routeA2,00:01:00,00:01:00,stop2,3 +routeA2,00:00:40,00:00:40,stop3,2 +routeA2,00:00:00,00:00:00,stop4,1 +routeB,00:00:00,00:00:00,stop1,1 +routeB,00:01:20,00:01:20,stop3,2 +routeB,00:01:40,00:01:40,stop5,3 +routeB,00:02:20,00:02:20,stop6,4 +routeB,00:02:40,00:02:40,stop4,5 +routeA1_weekend,00:00:00,00:00:00,stop1,1 +routeA1_weekend,00:00:30,00:00:20,stop2,2 +routeA1_weekend,00:01:00,00:00:40,stop3,3 +routeA1_weekend,00:01:30,00:01:20,stop4,4 +routeA2_weekend,00:00:00,00:00:00,stop4,1 +routeA2_weekend,00:00:30,00:00:30,stop3,2 +routeA2_weekend,00:01:00,00:01:00,stop2,3 +routeA2_weekend,00:01:30,00:01:30,stop1,4 +routeB_weekend,00:00:00,00:00:00,stop1,1 +routeB_weekend,00:01:00,00:01:00,stop3,2 +routeB_weekend,00:02:00,00:02:00,stop5,3 +routeB_weekend,00:03:00,00:03:00,stop6,4 +routeB_weekend,00:04:00,00:04:00,stop4,5 \ No newline at end of file diff --git a/test/gtfs-feed-min/stops.txt b/test/gtfs-feed-min/stops.txt new file mode 100644 index 0000000..48e73ce --- /dev/null +++ b/test/gtfs-feed-min/stops.txt @@ -0,0 +1,7 @@ +stop_id,stop_name,stop_lat,stop_lon +stop1,One,46.95162082275386,7.438913082275775 +stop2,Two,46.95153086988918,7.439162669063829 +stop3,Three,46.95147689809022,7.439280893956796 +stop4,Four,46.95127900232747,7.439491069338372 +stop5,Five,46.9513959419576,7.439149531606609 +stop6,Six,46.95121603683256,7.439359707397135 \ No newline at end of file diff --git a/test/gtfs-feed-min/transfers.txt b/test/gtfs-feed-min/transfers.txt new file mode 100644 index 0000000..2c4d907 --- /dev/null +++ b/test/gtfs-feed-min/transfers.txt @@ -0,0 +1,7 @@ +from_stop_id,to_stop_id,transfer_type,min_transfer_time +stop2,stop3,0,-99 +stop3,stop2,1,-99 +stop3,stop4,2,10 +stop4,stop3,2,10 +stop4,stop1,3, +stop1,stop4,3, \ No newline at end of file diff --git a/test/gtfs-feed-min/trips.txt b/test/gtfs-feed-min/trips.txt new file mode 100644 index 0000000..3aba2fa --- /dev/null +++ b/test/gtfs-feed-min/trips.txt @@ -0,0 +1,7 @@ +route_id,service_id,trip_id,shape_id +lineA,WEEK,routeA1,shapeA1 +lineA,WEEK,routeA2,shapeA2 +lineB,EXPR,routeB,shapeB +lineA,WEND,routeA1_weekend,shapeA1 +lineA,WEND,routeA2_weekend,shapeA2 +lineB,WEND,routeB_weekend,shapeB \ No newline at end of file From 92a6af154102e821a06833657efb15dc62318886 Mon Sep 17 00:00:00 2001 From: Tobias Kohl Date: Fri, 27 Dec 2024 14:55:54 +0100 Subject: [PATCH 3/3] add te remaining stop types and the proper restrictions --- .../matsim/pt2matsim/gtfs/GtfsFeedImpl.java | 62 ++++++++++++++----- .../pt2matsim/gtfs/lib/GtfsDefinitions.java | 17 ++++- .../matsim/pt2matsim/gtfs/lib/StopImpl.java | 40 +++++------- .../pt2matsim/gtfs/GtfsFeedImplTest.java | 3 +- test/gtfs-feed/stops.txt | 20 +++--- 5 files changed, 92 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/matsim/pt2matsim/gtfs/GtfsFeedImpl.java b/src/main/java/org/matsim/pt2matsim/gtfs/GtfsFeedImpl.java index 93f79e0..8fc8bc1 100755 --- a/src/main/java/org/matsim/pt2matsim/gtfs/GtfsFeedImpl.java +++ b/src/main/java/org/matsim/pt2matsim/gtfs/GtfsFeedImpl.java @@ -256,35 +256,65 @@ protected void loadStops() throws IOException { while(line != null) { l++; String stopId = line[col.get(GtfsDefinitions.STOP_ID)]; - StopImpl stop = new StopImpl(stopId, line[col.get(GtfsDefinitions.STOP_NAME)], Double.parseDouble(line[col.get(GtfsDefinitions.STOP_LON)]), Double.parseDouble(line[col.get(GtfsDefinitions.STOP_LAT)])); - stops.put(stopId, stop); - - // location type - if(col.get(GtfsDefinitions.LOCATION_TYPE) != null) { - if(line[col.get(GtfsDefinitions.LOCATION_TYPE)].equals("0")) { - stop.setLocationType(GtfsDefinitions.LocationType.STOP); + GtfsDefinitions.LocationType locationType = col.containsKey(GtfsDefinitions.LOCATION_TYPE) && !line[col.get(GtfsDefinitions.LOCATION_TYPE)].isEmpty() ? + GtfsDefinitions.LocationType.values()[Integer.parseInt(line[col.get(GtfsDefinitions.LOCATION_TYPE)])] : + GtfsDefinitions.LocationType.STOP; + + String parentStation = null; + if (col.containsKey(GtfsDefinitions.PARENT_STATION)) { + if (line[col.get(GtfsDefinitions.PARENT_STATION)].isEmpty()) { + if (locationType.index == 2 || locationType.index == 3 || locationType.index == 4) { + throw new IllegalArgumentException("stop " + stopId + " has no parent but its type requires one"); + } + } else { + if (locationType.index == 1) { + throw new IllegalArgumentException("stop " + stopId + " has a parent but its type forbids one"); + } else { + parentStation = line[col.get(GtfsDefinitions.PARENT_STATION)]; + } } - if(line[col.get(GtfsDefinitions.LOCATION_TYPE)].equals("1")) { - stop.setLocationType(GtfsDefinitions.LocationType.STATION); + } else { + if (locationType.index == 1 || locationType.index == 2 || locationType.index == 3) { + throw new IllegalArgumentException("the dataset has no parent_station column but the type of stop " + stopId + " requires one"); } } - - // parent station - if(col.get(GtfsDefinitions.PARENT_STATION) != null && !line[col.get(GtfsDefinitions.PARENT_STATION)].isEmpty()) { - stop.setParentStation(line[col.get(GtfsDefinitions.PARENT_STATION)]); - } - + + StopImpl stop = new StopImpl(stopId, line[col.get(GtfsDefinitions.STOP_NAME)], locationType, parentStation); + + if (col.containsKey(GtfsDefinitions.STOP_LON) && col.containsKey(GtfsDefinitions.STOP_LAT) && !line[col.get(GtfsDefinitions.STOP_LON)].isEmpty() && !line[col.get(GtfsDefinitions.STOP_LAT)].isEmpty()) { + stop.setLocation(Double.parseDouble(line[col.get(GtfsDefinitions.STOP_LON)]), Double.parseDouble(line[col.get(GtfsDefinitions.STOP_LAT)])); + } else if (locationType.index == 0 || locationType.index == 1 || locationType.index == 2) { + throw new IllegalArgumentException("stop " + stopId + " has no Coord but its type requires one!"); + } // in case of type 3 or 4 we can set it via the parent later + + stops.put(stopId, stop); line = reader.readNext(); } - reader.close(); } catch (ArrayIndexOutOfBoundsException e) { throw new RuntimeException("Line " + l + " in stops.txt is empty or malformed."); } catch (CsvValidationException e) { throw new RuntimeException(e); } + + for (Stop stop : stops.values()) { + setStopCoordFromParentRecursively(stop); + } + log.info("... stops.txt loaded"); } + + private void setStopCoordFromParentRecursively(Stop stop) { + if (stop.getCoord() == null) { + if (stop.getParentStationId() != null) { + Stop parentStop = stops.get(stop.getParentStationId()); + setStopCoordFromParentRecursively(parentStop); + ((StopImpl) stop).setLocation(parentStop.getCoord().getX(), parentStop.getCoord().getY()); + } else { + throw new IllegalArgumentException("stop " + stop.getId() + " has no Coord an no parent to derive it from!"); + } + } + } /** * Reads all services and puts them in {@link #services} diff --git a/src/main/java/org/matsim/pt2matsim/gtfs/lib/GtfsDefinitions.java b/src/main/java/org/matsim/pt2matsim/gtfs/lib/GtfsDefinitions.java index a85dc28..1eebfab 100644 --- a/src/main/java/org/matsim/pt2matsim/gtfs/lib/GtfsDefinitions.java +++ b/src/main/java/org/matsim/pt2matsim/gtfs/lib/GtfsDefinitions.java @@ -420,9 +420,24 @@ public static ExtendedRouteType getExtendedRouteType(RouteType routeType) { * The location type field can have the following values:
* 0 or blank: Stop. A location where passengers board or disembark from a transit vehicle
* 1: Station. A physical structure or area that contains one or more stop
+ * 2: Entrance/Exit. A location where passengers can enter or exit a station from the street. If an entrance/exit belongs to multiple stations, it may be linked by pathways to both, but the data provider must pick one of them as parent. + * 3: Generic Node. A location within a station, not matching any other location_type, that may be used to link together pathways define in pathways.txt. + * 4: Boarding Area. A specific location on a platform, where passengers can board and/or alight vehicles. */ public enum LocationType { - STOP, STATION + STOP(0, "stop"), + STATION(1, "station"), + ENTRANCE(2, "entrance / exit"), + NODE(3, "generic node"), + BOARDING_AREA(4, "boarding area"); + + public int index; + public String name; + + LocationType(int index, String name) { + this.index = index; + this.name = name; + } } public enum FareTransferType { diff --git a/src/main/java/org/matsim/pt2matsim/gtfs/lib/StopImpl.java b/src/main/java/org/matsim/pt2matsim/gtfs/lib/StopImpl.java index d098b4f..bd382cc 100644 --- a/src/main/java/org/matsim/pt2matsim/gtfs/lib/StopImpl.java +++ b/src/main/java/org/matsim/pt2matsim/gtfs/lib/StopImpl.java @@ -30,33 +30,25 @@ public class StopImpl implements Stop { private final String id; private final String name; - private final double lon; - private final double lat; - /** optional **/ - private GtfsDefinitions.LocationType locationType = null; - /** optional **/ - private String parentStationId = null; - + private String parentStationId; + private final GtfsDefinitions.LocationType locationType; + + private double lon; + private double lat; private Coord coord; private final Collection trips = new HashSet<>(); - public StopImpl(String id, String name, double lon, double lat) { + public StopImpl(String id, String name, GtfsDefinitions.LocationType locationType, String parentStationId) { this.id = id; - this.lon = lon; - this.lat = lat; - this.coord = new Coord(lon, lat); - this.name = name; - } - - public StopImpl(String id, String name, double lon, double lat, GtfsDefinitions.LocationType locationType, String parentStationId) { - this.id = id; - this.lon = lon; - this.lat = lat; - this.coord = new Coord(lon, lat); this.name = name; this.locationType = locationType; this.parentStationId = parentStationId; } + + public StopImpl(String id, String name, double lon, double lat, GtfsDefinitions.LocationType locationType, String parentStationId) { + this(id, name, locationType, parentStationId); + setLocation(lon, lat); + } @Override public String getId() { @@ -98,12 +90,10 @@ public Coord getCoord() { return coord; } - public void setLocationType(GtfsDefinitions.LocationType type) { - this.locationType = type; - } - - public void setParentStation(String id) { - this.parentStationId = id; + public void setLocation(double lon, double lat) { + this.lon = lon; + this.lat = lat; + this.coord = new Coord(lon, lat); } public void addTrip(Trip trip) { diff --git a/src/test/java/org/matsim/pt2matsim/gtfs/GtfsFeedImplTest.java b/src/test/java/org/matsim/pt2matsim/gtfs/GtfsFeedImplTest.java index 0fb790d..7ee9400 100644 --- a/src/test/java/org/matsim/pt2matsim/gtfs/GtfsFeedImplTest.java +++ b/src/test/java/org/matsim/pt2matsim/gtfs/GtfsFeedImplTest.java @@ -47,7 +47,8 @@ void compareShapes() { @Test void statistics() { - Assertions.assertEquals(6, feed.getStops().size()); + Assertions.assertEquals(12, feed.getStops().size()); + Assertions.assertEquals(6, feed.getStops().values().stream().filter(s -> s.getLocationType().index==0).count()); Assertions.assertEquals(3, feed.getRoutes().size()); Assertions.assertEquals(4, feed.getServices().size()); Assertions.assertEquals(3, feed.getShapes().size()); diff --git a/test/gtfs-feed/stops.txt b/test/gtfs-feed/stops.txt index 48e73ce..29d23f1 100755 --- a/test/gtfs-feed/stops.txt +++ b/test/gtfs-feed/stops.txt @@ -1,7 +1,13 @@ -stop_id,stop_name,stop_lat,stop_lon -stop1,One,46.95162082275386,7.438913082275775 -stop2,Two,46.95153086988918,7.439162669063829 -stop3,Three,46.95147689809022,7.439280893956796 -stop4,Four,46.95127900232747,7.439491069338372 -stop5,Five,46.9513959419576,7.439149531606609 -stop6,Six,46.95121603683256,7.439359707397135 \ No newline at end of file +stop_id,stop_name,stop_lat,stop_lon,parent_station,location_type +stop1,One,46.95162082275386,7.438913082275775,, +stop2,Two,46.95153086988918,7.439162669063829,,0 +stop3,Three,46.95147689809022,7.439280893956796,station1,0 +stop4,Four,46.95127900232747,7.439491069338372,station1, +stop5,Five,46.9513959419576,7.439149531606609,station1, +stop6,Six,46.95121603683256,7.439359707397135,, +station1,Station,46.95127900232747,7.439491069338372,,1 +entrance1,Station Entrance,46.95127900232430,7.439491069338999,station1,2 +node1,Node1,46.95127900232643,7.43949106933847,station1,3 +node2,Node2,,,station1,3 +boarding1,Boarding Area 1,46.95162082275999,7.438913082275123,stop1,4 +boarding2,stop2,,,stop2,4 \ No newline at end of file