Skip to content

Commit

Permalink
[processing] Port mean coordinates to c++
Browse files Browse the repository at this point in the history
And remove final use of inefficient vector.extractPoints function
  • Loading branch information
nyalldawson committed Sep 22, 2017
1 parent 10d6ef0 commit 0dd434c
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 216 deletions.
8 changes: 0 additions & 8 deletions python/plugins/processing/algs/help/qgis.yaml
Expand Up @@ -294,14 +294,6 @@ qgis:listuniquevalues: >

qgis:meanandstandarddeviationplot:


qgis:meancoordinates: >
This algorithm computes a point layer with the center of mass of geometries in an input layer.

An attribute can be specified as containing weights to be applied to each feature when computing the center of mass.

If an attribute is selected in the <Unique ID field> parameters, features will be grouped according to values in this field. Instead of a single point with the center of mass of the whole layer, the output layer will contain a center of mass for the features in each category.

qgis:mergevectorlayers: >
This algorithm combines multiple vector layers of the same geometry type into a single one.

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

This file was deleted.

2 changes: 0 additions & 2 deletions python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
Expand Up @@ -92,7 +92,6 @@
from .Intersection import Intersection
from .JoinAttributes import JoinAttributes
from .LinesToPolygons import LinesToPolygons
from .MeanCoords import MeanCoords
from .Merge import Merge
from .MinimumBoundingGeometry import MinimumBoundingGeometry
from .NearestNeighbourAnalysis import NearestNeighbourAnalysis
Expand Down Expand Up @@ -226,7 +225,6 @@ def getAlgs(self):
Intersection(),
JoinAttributes(),
LinesToPolygons(),
MeanCoords(),
Merge(),
MinimumBoundingGeometry(),
NearestNeighbourAnalysis(),
Expand Down
Expand Up @@ -2665,7 +2665,7 @@ tests:
name: expected/points_along_lines.gml
type: vector

- algorithm: qgis:meancoordinates
- algorithm: native:meancoordinates
name: standard mean coordinates
params:
INPUT:
Expand All @@ -2676,6 +2676,53 @@ tests:
name: expected/mean_coordinates.gml
type: vector

- algorithm: native:meancoordinates
name: Mean coordinates, multiple grouped
params:
INPUT:
name: points.gml
type: vector
UID: id2
results:
OUTPUT:
name: expected/mean_coordinates_unique_grouped.gml
type: vector
pk: id2
compare:
fields:
fid: skip

- algorithm: native:meancoordinates
name: Mean coordinates, unique field
params:
INPUT:
name: points.gml
type: vector
UID: id
results:
OUTPUT:
name: expected/mean_coordinates_unique_grouped_2.gml
type: vector
pk: id
compare:
fields:
fid: skip

- algorithm: native:meancoordinates
name: Mean coordinates, weighted
params:
INPUT:
name: points.gml
type: vector
WEIGHT: id
results:
OUTPUT:
name: expected/unique_coordinates_weight.gml
type: vector
compare:
fields:
fid: skip

- algorithm: native:collect
name: single part to multipart
params:
Expand Down
28 changes: 0 additions & 28 deletions python/plugins/processing/tools/vector.py
Expand Up @@ -90,34 +90,6 @@ def values(source, *attributes):
return ret


def extractPoints(geom):
points = []
if geom.type() == QgsWkbTypes.PointGeometry:
if geom.isMultipart():
points = geom.asMultiPoint()
else:
points.append(geom.asPoint())
elif geom.type() == QgsWkbTypes.LineGeometry:
if geom.isMultipart():
lines = geom.asMultiPolyline()
for line in lines:
points.extend(line)
else:
points = geom.asPolyline()
elif geom.type() == QgsWkbTypes.PolygonGeometry:
if geom.isMultipart():
polygons = geom.asMultiPolygon()
for poly in polygons:
for line in poly:
points.extend(line)
else:
polygon = geom.asPolygon()
for line in polygon:
points.extend(line)

return points


def checkMinDistance(point, index, distance, points):
"""Check if distance from given point to all other points is greater
than given value.
Expand Down

0 comments on commit 0dd434c

Please sign in to comment.