[Qgis-developer] Access count and center point from QgsPointDisplacementRenderer

Martin Dobias wonder.sk at gmail.com
Tue Jun 24 10:00:57 PDT 2014


Hi Matthias

On Tue, Jun 24, 2014 at 10:07 PM, Matthias Ludwig <kaotika at gmx.de> wrote:
> Hi,
>
> for a project (python standalone) I try to display points in "clusters"
> (like the Leaflet-marker-Cluster
> http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html,
> or Openlayers, etc. just a simple distance based solution).  As far as I
> understand the PointDisplacementRenderer more or less it does the same:
> group all points in a radius into a cluster and show the center point. If
> the tolerance is set depending on the scale the center points are displayed
> properly.
> I looked into the docs and the source code and didn't found a way to access
> the list of displacementGroups (to get the count and the center point) or
> just the count of points in each group. After that I tried to modify the
> source code of the renderer. I made the mDisplacementGroups publicly
> accessable (or i tried to do so) and moved the:
>     typedef QMap<QgsFeatureId, QgsFeature> DisplacementGroup;
>     /**Groups of features that have the same position*/
>     QList<DisplacementGroup> mDisplacementGroups;
>     /**Mapping from feature ID to its group index*/
> above the private section but it didn't worked. Is this completly wrong or
> do I have to change something else to get access with the python bindings?
> Is there any way to get the center point of each group and the count from
> the current implementation?

Those members variables are just temporary and not meant to be used
publicly. I don't think there is a way to retrieve these groupings.

> I didn't found something in the mailing list or somewhere else: is someone
> working on a "visual clustering" solution?

If the time will allow, I would like to do few improvements to the
point displacement renderer. It would probably make sense to actually
take the clustering out of the renderer and have a class just for the
clustering algorithm that will return the groups.

Regards
Martin


More information about the Qgis-developer mailing list