Skip to content

Commit e63ee67

Browse files
committed
[processing] maintain options order
1 parent 85e692e commit e63ee67

12 files changed

+122
-44
lines changed

python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import os
29+
from collections import OrderedDict
2930

3031
from qgis.PyQt.QtCore import QVariant
3132
from qgis.PyQt.QtGui import QIcon
@@ -76,10 +77,10 @@ def getIcon(self):
7677
return QIcon(os.path.join(pluginPath, 'images', 'networkanalysis.svg'))
7778

7879
def defineCharacteristics(self):
79-
self.DIRECTIONS = {self.tr('Forward direction'): QgsVectorLayerDirector.DirectionForward,
80-
self.tr('Backward direction'): QgsVectorLayerDirector.DirectionForward,
81-
self.tr('Both directions'): QgsVectorLayerDirector.DirectionForward
82-
}
80+
self.DIRECTIONS = OrderedDict([
81+
(self.tr('Forward direction'), QgsVectorLayerDirector.DirectionForward),
82+
(self.tr('Backward direction'), QgsVectorLayerDirector.DirectionForward),
83+
(self.tr('Both directions'), QgsVectorLayerDirector.DirectionForward)])
8384

8485
self.STRATEGIES = [self.tr('Shortest'),
8586
self.tr('Fastest')
@@ -122,7 +123,7 @@ def defineCharacteristics(self):
122123
params.append(ParameterSelection(self.DEFAULT_DIRECTION,
123124
self.tr('Default direction'),
124125
list(self.DIRECTIONS.keys()),
125-
default=0))
126+
default=2))
126127
params.append(ParameterTableField(self.SPEED_FIELD,
127128
self.tr('Speed field'),
128129
self.INPUT_VECTOR,
@@ -174,7 +175,7 @@ def processAlgorithm(self, progress):
174175
writerPoints = self.getOutputFromName(
175176
self.OUTPUT_POINTS).getVectorWriter(
176177
fields,
177-
QgsWkbTypes.Point,
178+
QgsWkbTypes.MultiPoint,
178179
layer.crs())
179180

180181
writerPolygons = self.getOutputFromName(

python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import os
29+
from collections import OrderedDict
2930

3031
from qgis.PyQt.QtCore import QVariant
3132
from qgis.PyQt.QtGui import QIcon
@@ -77,10 +78,10 @@ def getIcon(self):
7778
return QIcon(os.path.join(pluginPath, 'images', 'networkanalysis.svg'))
7879

7980
def defineCharacteristics(self):
80-
self.DIRECTIONS = {self.tr('Forward direction'): QgsVectorLayerDirector.DirectionForward,
81-
self.tr('Backward direction'): QgsVectorLayerDirector.DirectionForward,
82-
self.tr('Both directions'): QgsVectorLayerDirector.DirectionForward
83-
}
81+
self.DIRECTIONS = OrderedDict([
82+
(self.tr('Forward direction'), QgsVectorLayerDirector.DirectionForward),
83+
(self.tr('Backward direction'), QgsVectorLayerDirector.DirectionForward),
84+
(self.tr('Both directions'), QgsVectorLayerDirector.DirectionForward)])
8485

8586
self.STRATEGIES = [self.tr('Shortest'),
8687
self.tr('Fastest')
@@ -122,7 +123,7 @@ def defineCharacteristics(self):
122123
params.append(ParameterSelection(self.DEFAULT_DIRECTION,
123124
self.tr('Default direction'),
124125
list(self.DIRECTIONS.keys()),
125-
default=0))
126+
default=2))
126127
params.append(ParameterTableField(self.SPEED_FIELD,
127128
self.tr('Speed field'),
128129
self.INPUT_VECTOR,
@@ -229,7 +230,7 @@ def processAlgorithm(self, progress):
229230
writer = self.getOutputFromName(
230231
self.OUTPUT_POINTS).getVectorWriter(
231232
fields,
232-
QgsWkbTypes.Point,
233+
QgsWkbTypes.MultiPoint,
233234
layer.crs())
234235

235236
feat.setGeometry(geomUpper)

python/plugins/processing/algs/qgis/ShortestPathLayerToPoint.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import os
29+
from collections import OrderedDict
2930

3031
from qgis.PyQt.QtCore import QVariant
3132
from qgis.PyQt.QtGui import QIcon
@@ -75,10 +76,10 @@ def getIcon(self):
7576
return QIcon(os.path.join(pluginPath, 'images', 'networkanalysis.svg'))
7677

7778
def defineCharacteristics(self):
78-
self.DIRECTIONS = {self.tr('Forward direction'): QgsVectorLayerDirector.DirectionForward,
79-
self.tr('Backward direction'): QgsVectorLayerDirector.DirectionForward,
80-
self.tr('Both directions'): QgsVectorLayerDirector.DirectionForward
81-
}
79+
self.DIRECTIONS = OrderedDict([
80+
(self.tr('Forward direction'), QgsVectorLayerDirector.DirectionForward),
81+
(self.tr('Backward direction'), QgsVectorLayerDirector.DirectionForward),
82+
(self.tr('Both directions'), QgsVectorLayerDirector.DirectionForward)])
8283

8384
self.STRATEGIES = [self.tr('Shortest'),
8485
self.tr('Fastest')

python/plugins/processing/algs/qgis/ShortestPathPointToLayer.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import os
29+
from collections import OrderedDict
2930

3031
from qgis.PyQt.QtCore import QVariant
3132
from qgis.PyQt.QtGui import QIcon
@@ -75,10 +76,10 @@ def getIcon(self):
7576
return QIcon(os.path.join(pluginPath, 'images', 'networkanalysis.svg'))
7677

7778
def defineCharacteristics(self):
78-
self.DIRECTIONS = {self.tr('Forward direction'): QgsVectorLayerDirector.DirectionForward,
79-
self.tr('Backward direction'): QgsVectorLayerDirector.DirectionForward,
80-
self.tr('Both directions'): QgsVectorLayerDirector.DirectionForward
81-
}
79+
self.DIRECTIONS = OrderedDict([
80+
(self.tr('Forward direction'), QgsVectorLayerDirector.DirectionForward),
81+
(self.tr('Backward direction'), QgsVectorLayerDirector.DirectionForward),
82+
(self.tr('Both directions'), QgsVectorLayerDirector.DirectionForward)])
8283

8384
self.STRATEGIES = [self.tr('Shortest'),
8485
self.tr('Fastest')

python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import os
29+
from collections import OrderedDict
2930

3031
from qgis.PyQt.QtCore import QVariant
3132
from qgis.PyQt.QtGui import QIcon
@@ -77,10 +78,10 @@ def getIcon(self):
7778
return QIcon(os.path.join(pluginPath, 'images', 'networkanalysis.svg'))
7879

7980
def defineCharacteristics(self):
80-
self.DIRECTIONS = {self.tr('Forward direction'): QgsVectorLayerDirector.DirectionForward,
81-
self.tr('Backward direction'): QgsVectorLayerDirector.DirectionForward,
82-
self.tr('Both directions'): QgsVectorLayerDirector.DirectionForward
83-
}
81+
self.DIRECTIONS = OrderedDict([
82+
(self.tr('Forward direction'), QgsVectorLayerDirector.DirectionForward),
83+
(self.tr('Backward direction'), QgsVectorLayerDirector.DirectionForward),
84+
(self.tr('Both directions'), QgsVectorLayerDirector.DirectionForward)])
8485

8586
self.STRATEGIES = [self.tr('Shortest'),
8687
self.tr('Fastest')

python/plugins/processing/tests/testdata/expected/fastest.gml

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<gml:featureMember>
1515
<ogr:fastest fid="fastest.0">
1616
<ogr:geometryProperty><gml:LineString srsName="EPSG:32733"><gml:coordinates>1000953.57974071,6220312.94386716 1001107.24684923,6220391.87436156 1001202.14148585,6220278.54570253 1001223.5527025,6220254.162188 1001246.61300986,6220217.55052604 1001256.7885771,6220198.09709699 1001288.75671853,6220134.59225221 1001316.12250986,6220076.61143154 1001343.39016642,6220022.54512089 1001398.88208812,6219947.57470368 1001446.00944971,6219890.54669478 1001690.15771473,6220308.37238282 1001859.8438323,6220539.82106708 1002257.84768038,6220937.82878925 1002518.75791724,6221133.53444839 1002622.66996036,6221162.46807726 1002667.16458207,6221195.87188063 1002845.50542017,6221400.90692838 1003028.1814962,6221611.96830289 1003474.59453034,6222127.67457486 1003406.90500878,6222189.64158806 1003472.3070191,6222272.11630568 1003483.81137232,6222286.60579404 1003540.98718021,6222358.69755776</gml:coordinates></gml:LineString></ogr:geometryProperty>
17+
<ogr:start>1000943.66149, 6220332.25337</ogr:start>
18+
<ogr:end>1003534.81686, 6222363.59122</ogr:end>
19+
<ogr:cost>0.0478445</ogr:cost>
1720
</ogr:fastest>
1821
</gml:featureMember>
1922
</ogr:FeatureCollection>

python/plugins/processing/tests/testdata/expected/servicearea.gfs renamed to python/plugins/processing/tests/testdata/expected/servicearea_bounds.gfs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<GMLFeatureClassList>
22
<GMLFeatureClass>
3-
<Name>servicearea</Name>
4-
<ElementPath>servicearea</ElementPath>
3+
<Name>servicearea_bounds</Name>
4+
<ElementPath>servicearea_bounds</ElementPath>
55
<!--POLYGON-->
66
<GeometryType>3</GeometryType>
77
<SRSName>EPSG:32733</SRSName>
@@ -18,5 +18,11 @@
1818
<Type>String</Type>
1919
<Width>5</Width>
2020
</PropertyDefn>
21+
<PropertyDefn>
22+
<Name>start</Name>
23+
<ElementPath>start</ElementPath>
24+
<Type>String</Type>
25+
<Width>28</Width>
26+
</PropertyDefn>
2127
</GMLFeatureClass>
2228
</GMLFeatureClassList>

python/plugins/processing/tests/testdata/expected/servicearea.gml renamed to python/plugins/processing/tests/testdata/expected/servicearea_bounds.gml

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
</gml:boundedBy>
1313

1414
<gml:featureMember>
15-
<ogr:servicearea fid="servicearea.0">
15+
<ogr:servicearea_bounds fid="servicearea_bounds.0">
1616
<ogr:geometryProperty><gml:Polygon srsName="EPSG:32733"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1002845.50542017,6221400.90692838 1001968.37489204,6221502.13083684 1002180.65496167,6222555.77455478 1002527.19655281,6222727.93691723 1003198.63616199,6222463.1404267 1003285.47179071,6222319.99149044 1002845.50542017,6221400.90692838</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
1717
<ogr:type>upper</ogr:type>
18-
</ogr:servicearea>
18+
<ogr:start>1002660.34169, 6222015.78077</ogr:start>
19+
</ogr:servicearea_bounds>
1920
</gml:featureMember>
2021
<gml:featureMember>
21-
<ogr:servicearea fid="servicearea.1">
22+
<ogr:servicearea_bounds fid="servicearea_bounds.1">
2223
<ogr:geometryProperty><gml:Polygon srsName="EPSG:32733"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1002302.22841804,6221576.64258306 1002137.81278244,6221630.62018051 1002286.87770297,6222431.05239093 1002657.05576802,6222472.25802353 1002852.09477137,6222467.55382686 1003172.94058079,6222436.28679202 1003028.1814962,6221611.96830289 1002302.22841804,6221576.64258306</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
2324
<ogr:type>lower</ogr:type>
24-
</ogr:servicearea>
25+
<ogr:start>1002660.34169, 6222015.78077</ogr:start>
26+
</ogr:servicearea_bounds>
2527
</gml:featureMember>
2628
</ogr:FeatureCollection>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<GMLFeatureClassList>
2+
<GMLFeatureClass>
3+
<Name>servicearea_nodes</Name>
4+
<ElementPath>servicearea_nodes</ElementPath>
5+
<!--MULTIPOINT-->
6+
<GeometryType>4</GeometryType>
7+
<SRSName>EPSG:32733</SRSName>
8+
<DatasetSpecificInfo>
9+
<FeatureCount>2</FeatureCount>
10+
<ExtentXMin>1001968.37489</ExtentXMin>
11+
<ExtentXMax>1003285.47179</ExtentXMax>
12+
<ExtentYMin>6221400.90693</ExtentYMin>
13+
<ExtentYMax>6222727.93692</ExtentYMax>
14+
</DatasetSpecificInfo>
15+
<PropertyDefn>
16+
<Name>type</Name>
17+
<ElementPath>type</ElementPath>
18+
<Type>String</Type>
19+
<Width>5</Width>
20+
</PropertyDefn>
21+
<PropertyDefn>
22+
<Name>start</Name>
23+
<ElementPath>start</ElementPath>
24+
<Type>String</Type>
25+
<Width>28</Width>
26+
</PropertyDefn>
27+
</GMLFeatureClass>
28+
</GMLFeatureClassList>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation=""
5+
xmlns:ogr="http://ogr.maptools.org/"
6+
xmlns:gml="http://www.opengis.net/gml">
7+
<gml:boundedBy>
8+
<gml:Box>
9+
<gml:coord><gml:X>1001968.37489204</gml:X><gml:Y>6221400.90692838</gml:Y></gml:coord>
10+
<gml:coord><gml:X>1003285.47179071</gml:X><gml:Y>6222727.93691723</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:servicearea_nodes fid="servicearea_nodes.0">
16+
<ogr:geometryProperty><gml:MultiPoint srsName="EPSG:32733"><gml:pointMember><gml:Point><gml:coordinates>1001968.37489204,6221502.13083684</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002141.64083448,6221887.81776555</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002161.08326842,6222058.23120113</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002180.65496167,6222555.77455478</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002226.82368085,6221517.62843522</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002527.19655281,6222727.93691723</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002755.78126323,6222555.17746296</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002813.21865203,6221847.09999962</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002829.37711292,6222541.77590985</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002845.50542017,6221400.90692838</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002893.44547534,6221999.89357485</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002896.08523225,6222491.56157257</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003006.76410522,6222480.99306342</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003095.48438837,6222495.19645599</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003198.63616199,6222463.1404267</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003206.81541818,6222239.38127823</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003285.47179071,6222319.99149044</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint></ogr:geometryProperty>
17+
<ogr:type>upper</ogr:type>
18+
<ogr:start>1002660.34169, 6222015.78077</ogr:start>
19+
</ogr:servicearea_nodes>
20+
</gml:featureMember>
21+
<gml:featureMember>
22+
<ogr:servicearea_nodes fid="servicearea_nodes.1">
23+
<ogr:geometryProperty><gml:MultiPoint srsName="EPSG:32733"><gml:pointMember><gml:Point><gml:coordinates>1002137.81278244,6221630.62018051</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002200.84267254,6221919.96191528</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002207.17904492,6221977.8210857</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002286.87770297,6222431.05239093</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002302.22841804,6221576.64258306</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002657.05576802,6222472.25802353</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002657.05576802,6222472.25802353</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002623.85396603,6221672.14481097</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002852.09477137,6222467.55382686</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003028.1814962,6221611.96830289</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003022.39979238,6222107.94090369</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002852.54413666,6222449.88692926</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1002933.41223807,6222423.64415742</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003153.88971381,6222419.41498029</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003172.94058079,6222436.28679202</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003037.55521283,6222118.73863535</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>1003172.94058079,6222436.28679202</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint></ogr:geometryProperty>
24+
<ogr:type>lower</ogr:type>
25+
<ogr:start>1002660.34169, 6222015.78077</ogr:start>
26+
</ogr:servicearea_nodes>
27+
</gml:featureMember>
28+
</ogr:FeatureCollection>

0 commit comments

Comments
 (0)