Skip to content

Commit c600060

Browse files
authored
Add GTFS styles and fix #53
1 parent 384c267 commit c600060

File tree

3 files changed

+617
-5
lines changed

3 files changed

+617
-5
lines changed

qgis_processing/gtfsAlgorithm.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ def processAlgorithm(self, parameters, context, feedback):
103103
pt = QgsGeometry.fromWkt(stop.geometry.wkt)
104104
f = QgsFeature()
105105
f.setGeometry(pt)
106-
attrs = [
107-
stop.stop_id,
108-
stop.stop_code,
109-
stop.stop_name
110-
]
106+
attrs = [stop.stop_id]
107+
if hasattr(stop, 'stop_code'):
108+
attrs.append(stop.stop_code)
109+
else:
110+
attrs.append('')
111+
attrs.append(stop.stop_name)
112+
111113
f.setAttributes(attrs)
112114
self.sink_stops.addFeature(f, QgsFeatureSink.FastInsert)
113115

@@ -120,6 +122,11 @@ def get_fields(self):
120122
fields.append(QgsField("stop_name", QVariant.String))
121123
return fields
122124

125+
def postProcessAlgorithm(self, context, feedback):
126+
stop_layer = QgsProcessingUtils.mapLayerFromString(self.dest_stops, context)
127+
stop_layer.loadNamedStyle(os.path.join(pluginPath, "styles", "gtfs-stops.qml"))
128+
return {self.OUTPUT: self.dest_stops}
129+
123130

124131
class GtfsShapesAlgorithm(QgsProcessingAlgorithm):
125132
INPUT = "INPUT"
@@ -333,3 +340,8 @@ def get_fields(self, add_avg_speed):
333340
fields.append(QgsField("segment_max_speed_kmh", QVariant.Double))
334341
fields.append(QgsField("runtime_sec", QVariant.Double))
335342
return fields
343+
344+
def postProcessAlgorithm(self, context, feedback):
345+
seg_layer = QgsProcessingUtils.mapLayerFromString(self.dest_segments, context)
346+
seg_layer.loadNamedStyle(os.path.join(pluginPath, "styles", "gtfs-segments.qml"))
347+
return {self.OUTPUT: self.dest_segments}

0 commit comments

Comments
 (0)