-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE][processing] one-to-many join support to the join attribute …
…table alg. (#6499)
- Loading branch information
Showing
6 changed files
with
207 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
python/plugins/processing/tests/testdata/expected/join_attribute_table_all_match.gfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<GMLFeatureClassList> | ||
<GMLFeatureClass> | ||
<Name>join_attribute_table</Name> | ||
<ElementPath>join_attribute_table</ElementPath> | ||
<GeometryType>1</GeometryType> | ||
<SRSName>EPSG:4326</SRSName> | ||
<DatasetSpecificInfo> | ||
<FeatureCount>10</FeatureCount> | ||
<ExtentXMin>0.00000</ExtentXMin> | ||
<ExtentXMax>8.00000</ExtentXMax> | ||
<ExtentYMin>-5.00000</ExtentYMin> | ||
<ExtentYMax>3.00000</ExtentYMax> | ||
</DatasetSpecificInfo> | ||
<PropertyDefn> | ||
<Name>id</Name> | ||
<ElementPath>id</ElementPath> | ||
<Type>Integer</Type> | ||
</PropertyDefn> | ||
<PropertyDefn> | ||
<Name>id2</Name> | ||
<ElementPath>id2</ElementPath> | ||
<Type>Integer</Type> | ||
</PropertyDefn> | ||
<PropertyDefn> | ||
<Name>id_2</Name> | ||
<ElementPath>id_2</ElementPath> | ||
<Type>Integer</Type> | ||
</PropertyDefn> | ||
<PropertyDefn> | ||
<Name>NUM_A</Name> | ||
<ElementPath>NUM_A</ElementPath> | ||
<Type>Real</Type> | ||
</PropertyDefn> | ||
<PropertyDefn> | ||
<Name>ST_A</Name> | ||
<ElementPath>ST_A</ElementPath> | ||
<Type>String</Type> | ||
<Width>8</Width> | ||
</PropertyDefn> | ||
</GMLFeatureClass> | ||
</GMLFeatureClassList> |
111 changes: 111 additions & 0 deletions
111
python/plugins/processing/tests/testdata/expected/join_attribute_table_all_match.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ogr:FeatureCollection | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="" | ||
xmlns:ogr="http://ogr.maptools.org/" | ||
xmlns:gml="http://www.opengis.net/gml"> | ||
<gml:boundedBy> | ||
<gml:Box> | ||
<gml:coord><gml:X>0</gml:X><gml:Y>-5</gml:Y></gml:coord> | ||
<gml:coord><gml:X>8</gml:X><gml:Y>3</gml:Y></gml:coord> | ||
</gml:Box> | ||
</gml:boundedBy> | ||
|
||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.0"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>1</ogr:id> | ||
<ogr:id2>2</ogr:id2> | ||
<ogr:id_2>1</ogr:id_2> | ||
<ogr:NUM_A>1.100000</ogr:NUM_A> | ||
<ogr:ST_A>string a</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.1"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3,3</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>2</ogr:id> | ||
<ogr:id2>1</ogr:id2> | ||
<ogr:id_2>2</ogr:id_2> | ||
<ogr:NUM_A>2.400000</ogr:NUM_A> | ||
<ogr:ST_A>string c</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.1"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3,3</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>2</ogr:id> | ||
<ogr:id2>1</ogr:id2> | ||
<ogr:id_2>2</ogr:id_2> | ||
<ogr:NUM_A>2.200000</ogr:NUM_A> | ||
<ogr:ST_A>string a</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.2"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,2</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>3</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:id_2>3</ogr:id_2> | ||
<ogr:NUM_A>3.300000</ogr:NUM_A> | ||
<ogr:ST_A>string a</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.3"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5,2</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>4</ogr:id> | ||
<ogr:id2>2</ogr:id2> | ||
<ogr:id_2>4</ogr:id_2> | ||
<ogr:NUM_A>4.400000</ogr:NUM_A> | ||
<ogr:ST_A>string b</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.4"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>5</ogr:id> | ||
<ogr:id2>1</ogr:id2> | ||
<ogr:id_2>5</ogr:id_2> | ||
<ogr:NUM_A>5.500000</ogr:NUM_A> | ||
<ogr:ST_A>string b</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.5"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-5</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>6</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:id_2>6</ogr:id_2> | ||
<ogr:NUM_A>6.600000</ogr:NUM_A> | ||
<ogr:ST_A>string b</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.6"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>8,-1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>7</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:id_2>7</ogr:id_2> | ||
<ogr:NUM_A>7.700000</ogr:NUM_A> | ||
<ogr:ST_A>string b</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.7"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7,-1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>8</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:id_2>8</ogr:id_2> | ||
<ogr:NUM_A>8.800000</ogr:NUM_A> | ||
<ogr:ST_A>string b</ogr:ST_A> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:join_attribute_table fid="points.8"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>9</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
</ogr:join_attribute_table> | ||
</gml:featureMember> | ||
</ogr:FeatureCollection> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6f47b25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature! Seems like the definitions of one-to-one and one-to-many are inconsistent though:
SpatialJoin.py
qgsalgorithmjoinbyattribute.cpp
6f47b25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anitagraser , you mean the matching vs. located? I think it needs to be different here, since we're speaking of spatial join vs attribute join. Or am I missing your point? Glad I'm not the only one liking this one 😄 give it a try alongside the aggregate algorithm as part of a model, that made my day.
6f47b25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that in SpatialJoin, "one-to-one" = "create feature for each located/matching" while in JoinByAttribute "one-to-one" is "first matching feature only".
6f47b25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anitagraser , oh, doh, I see it now.