-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d313b9d
Showing
8 changed files
with
122 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
stops.txt | ||
unfiltered-stops.txt |
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 @@ | ||
node index.js > unfiltered-stops.txt |
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,7 @@ | ||
psql^ | ||
--username=postgres^ | ||
--dbname VG^ | ||
-f 01-filter-stops.sql^ | ||
--set=stops_input="'%cd%\unfiltered-stops.txt'"^ | ||
--set=stops_output="'%cd%\stops.txt'"^ | ||
--set=selected_rs="'03251,03356,03361,03401,03403,03451,03458,03461,04011,04012'" |
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,28 @@ | ||
CREATE TEMPORARY TABLE STOPS (stop_id varchar, stop_name varchar, stop_lon double precision, stop_lat double precision, stop_code varchar); | ||
|
||
COPY | ||
STOPS | ||
FROM | ||
:stops_input | ||
DELIMITER ',' | ||
CSV | ||
HEADER | ||
QUOTE '"'; | ||
|
||
COPY ( | ||
select | ||
stops.* | ||
from | ||
stops, | ||
vg250_krs, | ||
regexp_split_to_table(:selected_rs, ',') as selected_rs | ||
where | ||
ST_contains(vg250_krs.geom, ST_SetSRID(ST_MakePoint(stops.stop_lon, stops.stop_lat), 4326)) and | ||
vg250_krs.rs = selected_rs | ||
) | ||
TO | ||
:stops_output | ||
WITH | ||
CSV | ||
HEADER QUOTE '"' | ||
FORCE QUOTE stop_id, stop_name, stop_code; |
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,25 @@ | ||
BSD 2-Clause License | ||
|
||
Copyright (c) 2017, Alexey Valikov | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,43 @@ | ||
# vbn-stops | ||
|
||
This is a simple script to download all [VBN](https://www.vbn.de) stops as [GTFS-compatible CSV](https://developers.google.com/transit/gtfs/reference/stops-file). | ||
|
||
The script uses the following endpoint: | ||
|
||
``` | ||
https://fahrplaner.vbn.de/hafas/query.exe/dny?performLocating=2&tpl=stop2json&look_stopclass=2147483647&look_minx={minx}&look_miny={miny}&look_maxx={maxx}&look_maxy={maxy} | ||
``` | ||
|
||
It starts from bounding box `(5, 47, 15, 56)` and works down to smaller quadrants. | ||
|
||
|
||
The script produces CSV output in the following format: | ||
|
||
``` | ||
stop_id,stop_name,stop_lon,stop_lat,stop_code | ||
"103204","Emden(Ostfriesl) B 210/Kolonie",7.211847,53.400005,"" | ||
``` | ||
|
||
# Prerequisites | ||
|
||
These scrips use PostGIS to filter stops belonging to administrative regions covered by the transport company. | ||
See [this project](https://github.com/highsource/postgis-verwaltungsgebiete) for a simple way to create a PostGIS database with administrative regions. | ||
|
||
# Usage | ||
|
||
## Windows | ||
|
||
``` | ||
npm install | ||
00-export-unfiltered-stops | ||
01-filter-stops | ||
``` | ||
|
||
# Disclaimer | ||
|
||
Usage of this script may or may not be legal, use on your own risk. | ||
This repository provides only source code, no data. | ||
|
||
# License | ||
|
||
Source code is licensed under [BSD 2-clause license](LICENSE). No license and no guarantees implied on the produced data, produce and use on your own risk. |
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,5 @@ | ||
const exportStops = require("hafas-export-stops-by-coordinates"); | ||
|
||
const ENDPOINT_BASE_URL_TEMPLATE = "https://fahrplaner.vbn.de/hafas/query.exe/dny?performLocating=2&tpl=stop2json&look_stopclass=2147483647&look_minx={minx}&look_miny={miny}&look_maxx={maxx}&look_maxy={maxy}"; | ||
|
||
exportStops(ENDPOINT_BASE_URL_TEMPLATE, "UTF-8", 5, 47, 15, 56, null, [51, 54, 80, 81, 84, 85, 87, 88]); |
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,10 @@ | ||
{ | ||
"name": "vbn-stops", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
"files": ["index.js"], | ||
"engines" : {"node": ">=6"}, | ||
"dependencies": { | ||
"hafas-export-stops-by-coordinates": "^0.3.0" | ||
} | ||
} |