WinForms & WPF Map Control - Clustering (Coming soon in v15.2)

Thinking Out Loud
17 November 2015

Set for release in v15.2 is clustering support for both our WinForms and WPF Map Controls. For those unfamiliar with this feature, its designed to aggregate map items and perform data density analysis.

WinForms and WPF Map Control - Data Clustering

Once shipped, the DevExpress Map Control will support 2 clustering algorithms:

  • Distance Based: joins items - whose separation is smaller than a specified threshold - into a single cluster. The cluster's indicator is calculated as the mean of items.
  • Marker: joins items - whose distance to the central item is smaller than a specified threshold - into a single cluster. The cluster indicator matches the central item.

You can also implement a custom clustering algorithm by inheriting from the MapClustererBase class (WPF) or implementing the IClusterer (WinForms) interface.

Groups

Predefined clusterers allow you to separate items into groups prior to clustering (for instance, to group items by attribute values before clustering).

WinForms & WPF Map Control - Clustering Groups
 

It's relatively straightforward to implement this feature for our WPF Map Control - You simply assign the MapClustererGroupProviderBase class descendant object to the GroupProvider property:

<dxm:ListSourceDataAdapter.Clusterer>
    <dxm:DistanceBasedClusterer>
        <dxm:DistanceBasedClusterer.GroupProvider>
            <dxm:AttributeGroupProvider AttributeName="LocationName"/>
        </dxm:DistanceBasedClusterer.GroupProvider>
    </dxm:DistanceBasedClusterer>
 </dxm:ListSourceDataAdapter.Clusterer>

If you're using the WinForms version of our Map Control, you would assign an object implementing the IClustererGroupProvider interface to the GroupProvider property:

ListSourceDataAdapter vectorDataAdapter = new ListSourceDataAdapter();
// Several data adapter configurations...
vectorDataAdapter.Clusterer = new DistanceBasedClusterer {
    GroupProvider = new AttributeGroupProvider { AttributeName = "LocationName" }
};


Custom Indicators

As you'd expect, you can customize cluster indicators as needed (by using custom cluster item factories for WinForms or item settings for WPF).

WinForms & WPF Map Control - Custom Clustering Indicators


To customize indicators for the WinForms Map Control, use the clusterer's SetClusterFactory(IClusterItemFactory) method to specify the factory used to generate cluster indicators:

public class CustomClusterItemFactory : IClusterItemFactory {
// Code to generate items...
}
 
// Additional Code...
clusterer.SetClusterItemFactory(new CustomClusterItemFactory());

For WPF, specify the required MapItemSetting class descendant object to the ClusterSettings property of the clusterer:

<dxm:DistanceBasedClusterer>
    <dxm:DistanceBasedClusterer.ClusterSettings>
        <dxm:MapCustomElementSettings ContentTemplate="{Binding Source={StaticResource itemTemplate}}"/>
    </dxm:DistanceBasedClusterer.ClusterSettings>
</dxm:DistanceBasedClusterer>

===========================

We'd love to get your feedback on this new Map Clustering feature. How likely are you to use it in your next WinForms or WPF project?

2 comment(s)
Christopher Todd
Christopher Todd

Pretty nice! I would use the control, but we need WMS support first!

17 November, 2015
Mark Bissett 2
Mark Bissett 2

Great work DevExpress!

17 November, 2015

Please login or register to post comments.