Skip to content
Permalink
Browse files

[processing] Port mean coordinates to c++

And remove final use of inefficient vector.extractPoints function
  • Loading branch information
nyalldawson committed Sep 22, 2017
1 parent 10d6ef0 commit 0dd434c1837c3ac3d1bed66b44492ad2a21d9f1a
@@ -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.

This file was deleted.

@@ -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
@@ -226,7 +225,6 @@ def getAlgs(self):
Intersection(),
JoinAttributes(),
LinesToPolygons(),
MeanCoords(),
Merge(),
MinimumBoundingGeometry(),
NearestNeighbourAnalysis(),
@@ -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:
@@ -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:
@@ -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.

0 comments on commit 0dd434c

Please sign in to comment.
You can’t perform that action at this time.