diff --git a/README.md b/README.md index 2546921..a232fc3 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Smaller number of rules is prefered. 3. stop_name and distance - - unifying stops having same stop_name and near to each in certain extent - 0.01 degree in terms of lonlat-plane + - unifying stops having same stop_name and near to each in certain extent - 0.003 degree in terms of lonlat-plane - new stop_id is the first stop's one in grouped stops ordered by stop_id ascending. #### unifying result diff --git a/gtfs_go_dialog.py b/gtfs_go_dialog.py index b6c811b..585d963 100755 --- a/gtfs_go_dialog.py +++ b/gtfs_go_dialog.py @@ -29,6 +29,7 @@ import tempfile import urllib import uuid +import csv from PyQt5.QtCore import * from PyQt5.QtGui import * @@ -227,7 +228,7 @@ def execution(self): "aggregated_csv": "", } - gtfs = gtfs_parser.GTFS(feed_info["path"]) + gtfs = gtfs_parser.GTFSFactory(feed_info["path"]) if self.ui.simpleCheckbox.isChecked(): routes_geojson = { @@ -277,7 +278,7 @@ def execution(self): "type": "FeatureCollection", "features": aggregator.read_interpolated_stops(), } - + stop_relations = aggregator.read_stop_relations() # write written_files["aggregated_routes"] = os.path.join( output_dir, "aggregated_routes.geojson" @@ -301,12 +302,13 @@ def execution(self): with open( written_files["aggregated_csv"], mode="w", - encoding="cp932", + encoding="utf-8", errors="ignore", + newline='', ) as f: - aggregator.gtfs["stops"][ - ["stop_id", "stop_name", "similar_stop_id", "similar_stop_name"] - ].to_csv(f, index=False) + writer = csv.DictWriter(f, fieldnames=stop_relations[0].keys()) + writer.writeheader() + writer.writerows(stop_relations) self.show_geojson( feed_info["group"], @@ -424,6 +426,7 @@ def show_geojson( os.path.basename(aggregated_csv).split(".")[0], "ogr", ) + aggregated_csv_vlayer.setProviderEncoding("UTF-8") QgsProject.instance().addMapLayer(aggregated_csv_vlayer, False) group.insertLayer(0, aggregated_csv_vlayer) diff --git a/gtfs_parser b/gtfs_parser index 65ccce5..34daec8 160000 --- a/gtfs_parser +++ b/gtfs_parser @@ -1 +1 @@ -Subproject commit 65ccce58e6aa955db9132c84ad09f90954c38a5a +Subproject commit 34daec873e4ecbe0bf3e76bf44e3371be97274ea