From 237a54b74084443bc9ef8980b9b1b68bf120474b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Morin?= Date: Mon, 15 Apr 2019 16:40:59 -0400 Subject: [PATCH 1/3] added wheelchair_accessible column to gtfs_trips table --- src/gtfs_tables.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gtfs_tables.sql b/src/gtfs_tables.sql index b23d9d4..b11d970 100644 --- a/src/gtfs_tables.sql +++ b/src/gtfs_tables.sql @@ -226,6 +226,7 @@ create table gtfs_trips ( block_id text, shape_id text, trip_short_name text, + wheelchair_accessible text, -- unofficial features trip_type text ); From 8e4f3b9494293d2bcd6ef325524a5099f2fc01f8 Mon Sep 17 00:00:00 2001 From: Frederic Morin Date: Fri, 3 Feb 2023 14:09:31 -0500 Subject: [PATCH 2/3] Conversion to python3 --- src/import_gtfs_to_sql.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/import_gtfs_to_sql.py b/src/import_gtfs_to_sql.py index 0282b58..98f8afd 100755 --- a/src/import_gtfs_to_sql.py +++ b/src/import_gtfs_to_sql.py @@ -78,7 +78,7 @@ def handleVals(self,row,cols): class StopTimesHandler(SpecialHandler): @staticmethod def timeToSeconds(text): - h,m,s = map(int,text.split(":")) + h,m,s = list(map(int,text.split(":"))) return h*60*60 + m*60 + s @staticmethod @@ -144,7 +144,7 @@ def import_file(fname, tablename, handler, COPY=True): handler = SpecialHandler() reader = csv.reader(f,dialect=csv.excel); - header = handler.handleCols([c.strip() for c in reader.next()]); + header = handler.handleCols([c.strip() for c in next(reader)]); cols = ",".join(header); defaultVal = 'NULL'; @@ -199,8 +199,8 @@ def import_file(fname, tablename, handler, COPY=True): handlers['frequencies'] = FrequenciesHandler(); if len(sys.argv) not in (2,3): - print "Usage: %s gtfs_data_dir [nocopy]" % sys.argv[0] - print " If nocopy is present, then uses INSERT instead of COPY." + print("Usage: %s gtfs_data_dir [nocopy]" % sys.argv[0]) + print(" If nocopy is present, then uses INSERT instead of COPY.") sys.exit() dirname = sys.argv[1] @@ -209,11 +209,11 @@ def import_file(fname, tablename, handler, COPY=True): useCopy = not ("nocopy" in sys.argv[2:]) - print "begin;" + print("begin;") for fname in fnames: for statement in import_file(dirname+"/"+fname+".txt","gtfs_"+fname, handlers[fname],useCopy): - print statement; + print(statement); - print "commit;" + print("commit;") From ee66a77dbfc73f6349422b16c88d12d657ec6f24 Mon Sep 17 00:00:00 2001 From: Frederic Morin Date: Fri, 3 Feb 2023 14:09:41 -0500 Subject: [PATCH 3/3] Update for latest postgis version --- src/gtfs_tables_makespatial.sql | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gtfs_tables_makespatial.sql b/src/gtfs_tables_makespatial.sql index 8e701f0..a46f977 100644 --- a/src/gtfs_tables_makespatial.sql +++ b/src/gtfs_tables_makespatial.sql @@ -1,17 +1,18 @@ -- Add spatial support for PostGIS databases only -- Drop everything first -DROP TABLE gtfs_shape_geoms CASCADE; - +DROP TABLE IF EXISTS gtfs_shape_geoms CASCADE; +CREATE EXTENSION IF NOT EXISTS postgis; BEGIN; -- Add the_geom column to the gtfs_stops table - a 2D point geometry -SELECT AddGeometryColumn('gtfs_stops', 'the_geom', 4326, 'POINT', 2); +--SELECT AddGeometryColumn('gtfs_stops', 'the_geom', 4326, 'POINT', 2); +ALTER TABLE gtfs_stops ADD COLUMN the_geom geometry(POINT,4326); -- Update the the_geom column UPDATE gtfs_stops SET the_geom = ST_SetSRID(ST_MakePoint(stop_lon, stop_lat), 4326); -- Create spatial index -CREATE INDEX "gtfs_stops_the_geom_gist" ON "gtfs_stops" using gist ("the_geom" gist_geometry_ops); +--CREATE INDEX "gtfs_stops_the_geom_gist" ON "gtfs_stops" using gist ("the_geom" gist_geometry_ops); -- Create new table to store the shape geometries CREATE TABLE gtfs_shape_geoms ( @@ -19,8 +20,8 @@ CREATE TABLE gtfs_shape_geoms ( ); -- Add the_geom column to the gtfs_shape_geoms table - a 2D linestring geometry -SELECT AddGeometryColumn('gtfs_shape_geoms', 'the_geom', 4326, 'LINESTRING', 2); - +--SELECT AddGeometryColumn('gtfs_shape_geoms', 'the_geom', 4326, 'LINESTRING', 2); +ALTER TABLE gtfs_shape_geoms ADD COLUMN the_geom geometry(LINESTRING,4326); -- Populate gtfs_shape_geoms INSERT INTO gtfs_shape_geoms SELECT shape.shape_id, ST_SetSRID(ST_MakeLine(shape.the_geom), 4326) As new_geom @@ -32,6 +33,6 @@ SELECT shape.shape_id, ST_SetSRID(ST_MakeLine(shape.the_geom), 4326) As new_geom GROUP BY shape.shape_id; -- Create spatial index -CREATE INDEX "gtfs_shape_geoms_the_geom_gist" ON "gtfs_shape_geoms" using gist ("the_geom" gist_geometry_ops); +--CREATE INDEX "gtfs_shape_geoms_the_geom_gist" ON "gtfs_shape_geoms" using gist ("the_geom" gist_geometry_ops); COMMIT; \ No newline at end of file