Skip to content

Commit

Permalink
[processing] Port 'Add unique value index field' to c++
Browse files Browse the repository at this point in the history
And implement some fixes/improvements (refs discussion on the dev mailing list):
- allow user to specify created field name
- allow optional creation of a summary table showing new class value vs original
value
  • Loading branch information
nyalldawson committed Jan 23, 2018
1 parent 40f09fa commit b8e1f77
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 102 deletions.
98 changes: 0 additions & 98 deletions python/plugins/processing/algs/qgis/EquivalentNumField.py

This file was deleted.

2 changes: 0 additions & 2 deletions python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py
Expand Up @@ -58,7 +58,6 @@
from .DensifyGeometriesInterval import DensifyGeometriesInterval
from .Difference import Difference
from .EliminateSelection import EliminateSelection
from .EquivalentNumField import EquivalentNumField
from .ExecuteSQL import ExecuteSQL
from .Explode import Explode
from .ExportGeometryInfo import ExportGeometryInfo
Expand Down Expand Up @@ -180,7 +179,6 @@ def getAlgs(self):
DensifyGeometriesInterval(),
Difference(),
EliminateSelection(),
EquivalentNumField(),
ExecuteSQL(),
Explode(),
ExportGeometryInfo(),
Expand Down
Expand Up @@ -2,7 +2,7 @@

"""
***************************************************************************
EquivalentNumField.py
VectorLayerHistogram.py
---------------------
Date : January 2013
Copyright : (C) 2013 by Victor Olaya
Expand Down
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ add_unique_field_summary.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy><gml:null>missing</gml:null></gml:boundedBy>

<gml:featureMember>
<ogr:add_unique_field_summary fid="add_unique_field_summary.0">
<ogr:classes>0</ogr:classes>
<ogr:id2>2</ogr:id2>
</ogr:add_unique_field_summary>
</gml:featureMember>
<gml:featureMember>
<ogr:add_unique_field_summary fid="add_unique_field_summary.1">
<ogr:classes>1</ogr:classes>
<ogr:id2>1</ogr:id2>
</ogr:add_unique_field_summary>
</gml:featureMember>
<gml:featureMember>
<ogr:add_unique_field_summary fid="add_unique_field_summary.2">
<ogr:classes>2</ogr:classes>
<ogr:id2>0</ogr:id2>
</ogr:add_unique_field_summary>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,36 @@
<?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="add_unique_field_summary" type="ogr:add_unique_field_summary_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="add_unique_field_summary_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="classes" 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:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Expand Up @@ -2534,7 +2534,7 @@ tests:
fid: skip


- algorithm: qgis:adduniquevalueindexfield
- algorithm: native:adduniquevalueindexfield
name: add unique field based on another field
params:
FIELD: id2
Expand All @@ -2546,6 +2546,24 @@ tests:
name: expected/add_unique_field.gml
type: vector

- algorithm: native:adduniquevalueindexfield
name: Add unique field summary
params:
FIELD: id2
FIELD_NAME: classes
INPUT:
name: points.gml
type: vector
results:
SUMMARY_OUTPUT:
name: expected/add_unique_field_summary.gml
type: vector
compare:
fields:
fid: skip
pk:
- id2

- algorithm: qgis:linestopolygons
name: convert lines to polygon
params:
Expand Down
1 change: 1 addition & 0 deletions src/analysis/CMakeLists.txt
Expand Up @@ -65,6 +65,7 @@ SET(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmtransect.cpp
processing/qgsalgorithmtransform.cpp
processing/qgsalgorithmtranslate.cpp
processing/qgsalgorithmuniquevalueindex.cpp

processing/qgsnativealgorithms.cpp

Expand Down

0 comments on commit b8e1f77

Please sign in to comment.