Skip to content

Commit

Permalink
improve missing_in_osm
Browse files Browse the repository at this point in the history
  • Loading branch information
nlehuby committed Jan 8, 2024
1 parent 8929f34 commit e071018
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
11 changes: 4 additions & 7 deletions missing_in_osm/missing_in_osm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ set -euvo pipefail

cd data

## préparation des lignes open data
xsv join agency_id gtfs_routes.txt agency_id gtfs_agency.txt |xsv select agency_id,agency_name,route_id,route_short_name,route_long_name,route_type,route_color,route_text_color |xsv sort -s route_id|xsv sort -s agency_name > opendata_lignes.csv
sed -i -e "s/IDFM://g" opendata_lignes.csv


## ajout de l'id OSM sur les lignes open data
xsv join --left route_id opendata_lignes.csv ref:FR:STIF lignes.csv|xsv select 1-8,line_id > opendata_lines_with_osm_id.csv
## ajout des infos OSM sur les lignes open data
xsv join --left ID_Line opendata_lines_referential.csv ref:FR:STIF lignes.csv \
|xsv select line_id,ID_Line,code,ShortName_Line,network,NetworkName,operator,OperatorName,mode,TransportMode \
|xsv sort -s NetworkName,OperatorName,ID_Line > merged_lines.csv
# /!\ on a parfois plusieurs lignes OSM pour une même ligne opendata

## extraction des lignes OSM avec un tracé déjà existant
Expand Down
12 changes: 7 additions & 5 deletions missing_in_osm/missing_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
osm_with_shapes.append(elem[0])

lines = []
with open("../data/opendata_lines_with_osm_id.csv") as csvfile:
with open("../data/merged_lines.csv") as csvfile:
csv_ = csv.DictReader(csvfile)
for tt in csv_:
line = {}
line['opendata_line_id'] = tt['route_id']
line['opendata_network'] = tt['agency_name']
line['opendata_line_name'] = tt['route_short_name']
line['opendata_line_id'] = tt['ID_Line']
line['opendata_network'] = tt['NetworkName']
line['opendata_line_name'] = tt['ShortName_Line']
line['found_in_osm'] = tt['line_id'] != ''
line['osm_line_id'] = tt['line_id']
line['has_shape_in_osm'] = tt['line_id'] in osm_with_shapes
Expand All @@ -39,8 +39,10 @@


for a_network in networks:
content += "\n# {} \n".format(a_network)
lines_of_this_network = [line for line in lines if line['opendata_network'] == a_network]
if not a_network:
a_network = "*Pas de réseau défini côté IDFM*"
content += "\n# {} \n".format(a_network)
content += "{} lignes open data \n".format(len(lines_of_this_network))

osm_missing_lines_of_this_network = [line for line in lines_of_this_network if not line['found_in_osm']]
Expand Down
6 changes: 3 additions & 3 deletions run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ set -e
# compute routepoints with GTFS and OSM
./audit_routepoints/audit_routepoints.sh

# extract missing lines in OSM with GTFS and OSM
./missing_in_osm/missing_in_osm.sh

# extract lines ref
./lines_ref/init_lines_ref.sh

# extract missing lines in OSM with GTFS and OSM
./missing_in_osm/missing_in_osm.sh

# extract focus routepoints from GTFS and OSM
#./focus/focus.sh

Expand Down

0 comments on commit e071018

Please sign in to comment.