File tree 4 files changed +101
-1
lines changed
python/plugins/processing/tests/testdata
4 files changed +101
-1
lines changed Original file line number Diff line number Diff line change
1
+ <GMLFeatureClassList>
2
+ <GMLFeatureClass>
3
+ <Name>select_by_expression</Name>
4
+ <ElementPath>select_by_expression</ElementPath>
5
+ <!--POINT-->
6
+ <GeometryType>1</GeometryType>
7
+ <SRSName>EPSG:4326</SRSName>
8
+ <DatasetSpecificInfo>
9
+ <FeatureCount>2</FeatureCount>
10
+ <ExtentXMin>0.00000</ExtentXMin>
11
+ <ExtentXMax>7.00000</ExtentXMax>
12
+ <ExtentYMin>-1.00000</ExtentYMin>
13
+ <ExtentYMax>-1.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 number Diff line number Diff line change
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 >0</gml : X ><gml : Y >-1</gml : Y ></gml : coord >
10
+ <gml : coord ><gml : X >7</gml : X ><gml : Y >-1</gml : Y ></gml : coord >
11
+ </gml : Box >
12
+ </gml : boundedBy >
13
+
14
+ <gml : featureMember >
15
+ <ogr : select_by_expression fid =" points.8" >
16
+ <ogr : geometryProperty ><gml : Point srsName =" EPSG:4326" ><gml : coordinates >0,-1</gml : coordinates ></gml : Point ></ogr : geometryProperty >
17
+ <ogr : id >9</ogr : id >
18
+ <ogr : id2 >0</ogr : id2 >
19
+ </ogr : select_by_expression >
20
+ </gml : featureMember >
21
+ <gml : featureMember >
22
+ <ogr : select_by_expression fid =" points.7" >
23
+ <ogr : geometryProperty ><gml : Point srsName =" EPSG:4326" ><gml : coordinates >7,-1</gml : coordinates ></gml : Point ></ogr : geometryProperty >
24
+ <ogr : id >8</ogr : id >
25
+ <ogr : id2 >0</ogr : id2 >
26
+ </ogr : select_by_expression >
27
+ </gml : featureMember >
28
+ </ogr : FeatureCollection >
Original file line number Diff line number Diff line change @@ -2554,4 +2554,35 @@ tests:
2554
2554
results :
2555
2555
OUTPUT_LAYER :
2556
2556
name : expected/selected_points.gml
2557
- type : vector
2557
+ type : vector
2558
+
2559
+ - algorithm : script:selectbyexpression
2560
+ name : Select by expression
2561
+ params :
2562
+ INPUT_LAYER :
2563
+ name : points.gml
2564
+ type : vector
2565
+ results :
2566
+ OUTPUT_LAYER :
2567
+ name : expected/select_by_expression.gml
2568
+ type : vector
2569
+
2570
+ - algorithm : qgis:randomextract
2571
+ name : Random extract by number
2572
+ params :
2573
+ INPUT :
2574
+ name : custom/points_weighted.gml
2575
+ type : vector
2576
+ METHOD : ' 0'
2577
+ NUMBER : 4
2578
+ results : {}
2579
+
2580
+ - algorithm : qgis:randomextract
2581
+ name : Random extract by percentage
2582
+ params :
2583
+ INPUT :
2584
+ name : custom/points_weighted.gml
2585
+ type : vector
2586
+ METHOD : ' 1'
2587
+ NUMBER : 50
2588
+ results : {}
Original file line number Diff line number Diff line change
1
+ ##Select by expression=name
2
+ ##Tests=group
3
+ ##INPUT_LAYER=vector
4
+ ##OUTPUT_LAYER=output vector
5
+
6
+ import processing
7
+
8
+ result = processing .run ("qgis:selectbyexpression" ,
9
+ INPUT_LAYER ,
10
+ '"id2" = 0 and "id" > 7' ,
11
+ "1" )
12
+
13
+ processing .run ("qgis:saveselectedfeatures" ,
14
+ result ["RESULT" ],
15
+ OUTPUT_LAYER )
You can’t perform that action at this time.
0 commit comments