Skip to content

Commit

Permalink
Port Join Attributes to c++, add option to select subset of fields to…
Browse files Browse the repository at this point in the history
… copy
  • Loading branch information
nyalldawson committed Oct 12, 2017
1 parent edf7346 commit cac171a
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 129 deletions.
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/help/qgis.yaml
Expand Up @@ -262,11 +262,6 @@ qgis:joinattributesbylocation: >

The additional attributes and their values are taken from a second vector layer. A spatial criteria is applied to select the values from the second layer that are added to each feature from the first layer in the resulting one.

qgis:joinattributestable: >
This algorithm takes an input vector layer and creates a new vector layer that is an extended version of the input one, with additional attributes in its attribute table.

The additional attributes and their values are taken from a second vector layer. An attribute is selected in each of them to define the join criteria.

qgis:joinbylocationsummary: >
This algorithm takes an input vector layer and creates a new vector layer that is an extended version of the input one, with additional attributes in its attribute table.

Expand Down
120 changes: 0 additions & 120 deletions python/plugins/processing/algs/qgis/JoinAttributes.py

This file was deleted.

2 changes: 0 additions & 2 deletions python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
Expand Up @@ -90,7 +90,6 @@
from .ImportIntoPostGIS import ImportIntoPostGIS
from .ImportIntoSpatialite import ImportIntoSpatialite
from .Intersection import Intersection
from .JoinAttributes import JoinAttributes
from .LinesToPolygons import LinesToPolygons
from .Merge import Merge
from .MinimumBoundingGeometry import MinimumBoundingGeometry
Expand Down Expand Up @@ -223,7 +222,6 @@ def getAlgs(self):
ImportIntoPostGIS(),
ImportIntoSpatialite(),
Intersection(),
JoinAttributes(),
LinesToPolygons(),
Merge(),
MinimumBoundingGeometry(),
Expand Down
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ join_attribute_table_subset.xsd"
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_subset 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:NUM_A>1.100000</ogr:NUM_A>
</ogr:join_attribute_table_subset>
</gml:featureMember>
<gml:featureMember>
<ogr:join_attribute_table_subset 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:NUM_A>2.200000</ogr:NUM_A>
</ogr:join_attribute_table_subset>
</gml:featureMember>
<gml:featureMember>
<ogr:join_attribute_table_subset 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:NUM_A>3.300000</ogr:NUM_A>
</ogr:join_attribute_table_subset>
</gml:featureMember>
<gml:featureMember>
<ogr:join_attribute_table_subset 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:NUM_A>4.400000</ogr:NUM_A>
</ogr:join_attribute_table_subset>
</gml:featureMember>
<gml:featureMember>
<ogr:join_attribute_table_subset 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:NUM_A>5.500000</ogr:NUM_A>
</ogr:join_attribute_table_subset>
</gml:featureMember>
<gml:featureMember>
<ogr:join_attribute_table_subset 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:NUM_A>6.600000</ogr:NUM_A>
</ogr:join_attribute_table_subset>
</gml:featureMember>
<gml:featureMember>
<ogr:join_attribute_table_subset 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:NUM_A>7.700000</ogr:NUM_A>
</ogr:join_attribute_table_subset>
</gml:featureMember>
<gml:featureMember>
<ogr:join_attribute_table_subset 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:NUM_A>8.800000</ogr:NUM_A>
</ogr:join_attribute_table_subset>
</gml:featureMember>
<gml:featureMember>
<ogr:join_attribute_table_subset 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_subset>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="join_attribute_table_subset" type="ogr:join_attribute_table_subset_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="join_attribute_table_subset_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="id2" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NUM_A" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="19"/>
<xs:fractionDigits value="6"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Expand Up @@ -2487,7 +2487,7 @@ tests:
- expected/points_to_path_grouped2.gml
type: vector

- algorithm: qgis:joinattributestable
- algorithm: native:joinattributestable
name: join the attribute table by common field
params:
INPUT:
Expand All @@ -2503,6 +2503,25 @@ tests:
name: expected/join_attribute_table.gml
type: vector

- algorithm: native:joinattributestable
name: Join attributes table with subset of fields
params:
FIELD: id
FIELDS_TO_COPY:
- NUM_A
FIELD_2: ID
INPUT:
name: points.gml
type: vector
INPUT_2:
name: table.dbf
type: vector
results:
OUTPUT:
name: expected/join_attribute_table_subset.gml
type: vector


- algorithm: qgis:shortestpathpointtopoint
name: Shortest path (point to point, shortest route)
params:
Expand Down

0 comments on commit cac171a

Please sign in to comment.