Skip to content

Commit c4052e6

Browse files
committed
added sample test script which calls two algorithms
1 parent a70e73c commit c4052e6

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<GMLFeatureClassList>
2+
<GMLFeatureClass>
3+
<Name>selected_points</Name>
4+
<ElementPath>selected_points</ElementPath>
5+
<!--POINT-->
6+
<GeometryType>1</GeometryType>
7+
<SRSName>EPSG:4326</SRSName>
8+
<DatasetSpecificInfo>
9+
<FeatureCount>2</FeatureCount>
10+
<ExtentXMin>1.00000</ExtentXMin>
11+
<ExtentXMax>5.00000</ExtentXMax>
12+
<ExtentYMin>1.00000</ExtentYMin>
13+
<ExtentYMax>2.00000</ExtentYMax>
14+
</DatasetSpecificInfo>
15+
<PropertyDefn>
16+
<Name>id</Name>
17+
<ElementPath>id</ElementPath>
18+
<Type>Integer</Type>
19+
</PropertyDefn>
20+
<PropertyDefn>
21+
<Name>id2</Name>
22+
<ElementPath>id2</ElementPath>
23+
<Type>Integer</Type>
24+
</PropertyDefn>
25+
</GMLFeatureClass>
26+
</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>1</gml:X><gml:Y>1</gml:Y></gml:coord>
10+
<gml:coord><gml:X>5</gml:X><gml:Y>2</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:selected_points fid="points.0">
16+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point></ogr:geometryProperty>
17+
<ogr:id>1</ogr:id>
18+
<ogr:id2>2</ogr:id2>
19+
</ogr:selected_points>
20+
</gml:featureMember>
21+
<gml:featureMember>
22+
<ogr:selected_points fid="points.3">
23+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5,2</gml:coordinates></gml:Point></ogr:geometryProperty>
24+
<ogr:id>4</ogr:id>
25+
<ogr:id2>2</ogr:id2>
26+
</ogr:selected_points>
27+
</gml:featureMember>
28+
</ogr:FeatureCollection>

python/plugins/processing/tests/testdata/script_algorithm_tests.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ tests:
1414
compare:
1515
geometry:
1616
precision: 7
17+
18+
- algorithm: script:selectbyattribute
19+
name: Select by attribute
20+
params:
21+
INPUT_LAYER:
22+
name: points.gml
23+
type: vector
24+
results:
25+
OUTPUT_LAYER:
26+
name: expected/selected_points.gml
27+
type: vector
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
##Select by attribute=name
2+
##Tests=group
3+
##INPUT_LAYER=vector
4+
##OUTPUT_LAYER=output vector
5+
6+
import processing
7+
8+
result = processing.runalg("qgis:selectbyattribute",
9+
INPUT_LAYER,
10+
"id2",
11+
0,
12+
"2")
13+
14+
processing.runalg("qgis:saveselectedfeatures",
15+
result["OUTPUT"],
16+
OUTPUT_LAYER)

0 commit comments

Comments
 (0)