Skip to content

Commit

Permalink
Merge pull request #74 from MIERUNE/refactor-parser
Browse files Browse the repository at this point in the history
Refactor parser
  • Loading branch information
Kanahiro authored Jul 4, 2023
2 parents 9a4c528 + c1fd3c6 commit f1a05d5
Show file tree
Hide file tree
Showing 26 changed files with 40 additions and 136,520 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: pull submodules
run: |
git submodule update --init --recursive
- name: Create Plugin Directory
run: |
mkdir ${{env.PLUGIN_NAME}}
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/test_gtfs_parser.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "gtfs_parser"]
path = gtfs_parser
url = https://github.com/MIERUNE/gtfs-parser.git
56 changes: 30 additions & 26 deletions gtfs_go_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
***************************************************************************/
"""

import os
import datetime
import json
import urllib
import os
import shutil
import zipfile
import tempfile
import datetime
import urllib
import uuid
import zipfile

from PyQt5.QtCore import *
from PyQt5.QtGui import *
Expand All @@ -39,18 +39,14 @@
from qgis.PyQt import uic
from qgis.utils import iface

from .gtfs_parser import GTFSParser
from .gtfs_go_renderer import Renderer
from . import constants, repository
from .gtfs_go_labeling import get_labeling_for_stops

from . import repository
from .repository.japan_dpf.table import HEADERS, HEADERS_TO_HIDE
from . import constants

from .gtfs_go_renderer import Renderer
from .gtfs_go_settings import (
FILENAME_RESULT_CSV,
STOPS_MINIMUM_VISIBLE_SCALE,
)
from .gtfs_parser import gtfs_parser
from .repository.japan_dpf.table import HEADERS, HEADERS_TO_HIDE

DATALIST_JSON_PATH = os.path.join(os.path.dirname(__file__), "gtfs_go_datalist.json")
TEMP_DIR = os.path.join(tempfile.gettempdir(), "GTFSGo")
Expand Down Expand Up @@ -240,17 +236,18 @@ def execution(self):
}

if self.ui.simpleCheckbox.isChecked():
gtfs_parser = GTFSParser(extracted_dir)
gtfs = gtfs_parser.GTFS(extracted_dir)
routes_geojson = {
"type": "FeatureCollection",
"features": gtfs_parser.read_routes(
no_shapes=self.ui.ignoreShapesCheckbox.isChecked()
"features": gtfs_parser.parse.read_routes(
gtfs, ignore_shapes=self.ui.ignoreShapesCheckbox.isChecked()
),
}
stops_geojson = {
"type": "FeatureCollection",
"features": gtfs_parser.read_stops(
ignore_no_route=self.ui.ignoreNoRouteStopsCheckbox.isChecked()
"features": gtfs_parser.parse.read_stops(
gtfs,
ignore_no_route=self.ui.ignoreNoRouteStopsCheckbox.isChecked(),
),
}
# write
Expand All @@ -271,22 +268,22 @@ def execution(self):
json.dump(stops_geojson, f, ensure_ascii=False)

if self.ui.aggregateCheckbox.isChecked():
gtfs_parser = GTFSParser(
extracted_dir,
as_frequency=self.ui.aggregateCheckbox.isChecked(),
as_unify_stops=self.ui.unifyCheckBox.isChecked(),
gtfs = gtfs_parser.GTFS(extracted_dir)
aggregator = gtfs_parser.aggregate.Aggregator(
gtfs,
no_unify_stops=not self.ui.unifyCheckBox.isChecked(),
delimiter=self.get_delimiter(),
yyyymmdd=self.get_yyyymmdd(),
begin_time=self.get_time_filter(self.ui.beginTimeLineEdit),
end_time=self.get_time_filter(self.ui.endTimeLineEdit),
)
aggregated_routes_geojson = {
"type": "FeatureCollection",
"features": gtfs_parser.read_route_frequency(),
"features": aggregator.read_route_frequency(),
}
aggregated_stops_geojson = {
"type": "FeatureCollection",
"features": gtfs_parser.read_interpolated_stops(),
"features": aggregator.read_interpolated_stops(),
}

# write
Expand Down Expand Up @@ -315,7 +312,7 @@ def execution(self):
encoding="cp932",
errors="ignore",
) as f:
gtfs_parser.dataframes["stops"][
aggregator.gtfs["stops"][
["stop_id", "stop_name", "similar_stop_id", "similar_stop_name"]
].to_csv(f, index=False)

Expand Down Expand Up @@ -415,9 +412,16 @@ def show_geojson(
)

scale_stop_size = self.ui.scaleStopSizeCheckBox.isChecked()
dd_props = aggregated_stops_vlayer.renderer().symbol().symbolLayers()[0].dataDefinedProperties()
dd_props = (
aggregated_stops_vlayer.renderer()
.symbol()
.symbolLayers()[0]
.dataDefinedProperties()
)
if dd_props.hasProperty(QgsSymbolLayer.PropertySize):
dd_props.property(QgsSymbolLayer.PropertySize).setActive(scale_stop_size)
dd_props.property(QgsSymbolLayer.PropertySize).setActive(
scale_stop_size
)

QgsProject.instance().addMapLayer(aggregated_stops_vlayer, False)
group.insertLayer(0, aggregated_stops_vlayer)
Expand Down
1 change: 1 addition & 0 deletions gtfs_parser
Submodule gtfs_parser added at 281885
7 changes: 0 additions & 7 deletions gtfs_parser/LICENSE

This file was deleted.

5 changes: 0 additions & 5 deletions gtfs_parser/README.md

This file was deleted.

1 change: 0 additions & 1 deletion gtfs_parser/__init__.py

This file was deleted.

Loading

0 comments on commit f1a05d5

Please sign in to comment.