Skip to content

Commit

Permalink
delete now takes multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
rghunter committed Sep 28, 2015
1 parent 9581f67 commit 9b89d89
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
27 changes: 14 additions & 13 deletions gtfsdb/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,22 @@ def load_gtfs_ex(ctx, feeds, parallel):
load_feeds(feeds, db, parallel)

@gtfsdb_main.command('delete-feed-file')
@click.argument('file_id', nargs=1)
@click.argument('file_id_list', nargs=-1)
@click.pass_context
def delete_feed_file(ctx, file_id):
def delete_feed_file(ctx, file_id_list):
session = ctx.obj['database'].get_session()
try:
feed_file = session.query(FeedFile).get(file_id)
except NoResultFound:
click.echo("Could not find file with id: {}".format(file_id))
sys.exit(1)
name = feed_file.filename
click.echo("found feed file: {} ({})".format(name, file_id))
session.delete(feed_file)
session.commit()
session.close()
click.echo("sucessfully deleted feed file: {} ({})".format(name, file_id))
for file_id in file_id_list:
try:
feed_file = session.query(FeedFile).get(file_id)
except NoResultFound:
click.echo("Could not find file with id: {}".format(file_id))
sys.exit(1)
name = feed_file.filename
click.echo("found feed file: {} ({})".format(name, file_id))
session.delete(feed_file)
session.commit()
session.close()
click.echo("sucessfully deleted feed file: {} ({})".format(name, file_id))

@gtfsdb_main.command('add-by-zip')
@click.argument('directory', nargs=1)
Expand Down
15 changes: 15 additions & 0 deletions sql/srid_conversion.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
drop index if EXISTS gtfs_shapes_geom_gem;
drop index if EXISTS gtfs_shapes_gem;
drop index if EXISTS gtfs_stops_gem;

ANALYZE;

alter table gtfs_shapes ALTER COLUMN the_geom type geometry(Point, 4326) using ST_Transform(ST_SetSRID(the_geom,900913),4326);
alter table gtfs_stops ALTER COLUMN the_geom type geometry(Point, 4326) using ST_Transform(ST_SetSRID(the_geom,900913),4326);
alter table gtfs_shape_geoms ALTER COLUMN the_geom type geometry(LineString, 4326) using ST_Transform(ST_SetSRID(the_geom,900913),4326);

create index gtfs_shapes_geom_gem on gtfs_shape_geoms using GIST (the_geom);
create index gtfs_shapes_gem on gtfs_shapes using GIST (the_geom);
create index gtfs_stops_gem on gtfs_stops using GIST (the_geom);

ANALYZE;
File renamed without changes.

0 comments on commit 9b89d89

Please sign in to comment.