ThinkGeo.com    |     Documentation    |     Premium Support

Cluster point problem

I am currently using version 10.5 code – all up to the latest 10.5 release with VS 2015.

I have an in-memory layer that gets populated with search results I am using a cluster style that is defined as below.

            bitmapObject = MethodHelpers.GetBitmapResource("bluemarker");
            PointStyle ps = new PointStyle(new GeoImage(bitmapObject));
            ps.YOffsetInPixel = -1 * (ps.Image.Height / 2);

            // Set up the cluster style. 
            ClusterPointStyle clusterPointStyle = new ClusterPointStyle();
            clusterPointStyle.Styles.Add(ps);
            clusterPointStyle.TextStyle = new TextStyle("FeatureCount", new GeoFont("Arial", 10), GeoBrushes.Black);
            clusterPointStyle.TextStyle.OverlappingRule = LabelOverlappingRule.AllowOverlapping;
            clusterPointStyle.TextStyle.XOffsetInPixel = -9;
            clusterPointStyle.TextStyle.YOffsetInPixel = 26;
            clusterPointStyle.DrawingLevel = DrawingLevel.LabelLevel;
            clusterPointStyle.PointType = PointType.Bitmap;
            bitmapObject = MethodHelpers.GetBitmapResource("bluemarker");
            clusterPointStyle.Image = new GeoImage(bitmapObject);
            clusterPointStyle.YOffsetInPixel = -1 * (ps.Image.Height / 2);
            
            // Set the minimum features in per cell. If the count is less than the value it will invisible.
            clusterPointStyle.MinimumFeaturesPerCellToCluster = 5;

            ZoomLevel lzl = SearchResultsLayer.ZoomLevelSet.ZoomLevel01;
            lzl.CustomStyles.Add(clusterPointStyle);
            lzl.ApplyUntilZoomLevel = (ApplyUntilZoomLevel)GlobalProperties.totalZoomLevels;

            SearchResultsLayer.Open();
            searchResultsOverlay.Layers.Add(SearchResultsLayer);
            searchResultsOverlay.Layers.Add(SearchHighlightResultsLayer);
            searchResultsOverlay.TileType = TileType.SingleTile;

The searhResultsLayer is an inMemoryLayer. This is actually working as expected until I have somewhere over 700 features in the InMemoryLayer. Once that occurs I get an exception when the layer gets drawn.

{“An item with the same key has already been added.”}

at ThinkGeo.MapSuite.Wpf.Tile.DrawException(GeoCanvas geoCanvas, Exception exception)
at ThinkGeo.MapSuite.Wpf.Tile.Draw(GeoCanvas geoCanvas)
at ThinkGeo.MapSuite.Wpf.LayerOverlay.DrawTileCore(Tile tile, RectangleShape targetExtent)
at ThinkGeo.MapSuite.Wpf.TileOverlay.DrawTile(Tile tile, RectangleShape targetExtent)
at ThinkGeo.MapSuite.Wpf.TileOverlay.ZEU=(RectangleShape targetExtent)
at ThinkGeo.MapSuite.Wpf.TileOverlay.DrawCore(RectangleShape targetExtent, OverlayRefreshType overlayRefreshType)
at ThinkGeo.MapSuite.Wpf.LayerOverlay.DrawCore(RectangleShape targetExtent, OverlayRefreshType refreshType)
at ThinkGeo.MapSuite.Wpf.Overlay.Draw(RectangleShape targetExtent, OverlayRefreshType refreshType)
at ThinkGeo.MapSuite.Wpf.TileOverlay.RefreshCore()
at ThinkGeo.MapSuite.Wpf.Overlay.Refresh()
at ByersOneView.Core.MapTools.SearchHandler2.showSearchPins() in C:\projects\OneViewClient\ByersOneView\ByersOneView.Core\MapTools\SearchHandler2.cs:line 267

I have absolutely no idea what I am doing wrong. I can’t exclude the possibility this is being caused by something else in my code, but I only encounter this with the clusterPointStyle. If I simply use a pointstyle instead I get a big mass of markers but no exception.

Hi Richard,

It looks I hadn’t reproduced your exception, here is a simple sample, it render 2000 features.

Could you please check the code and modify it to reproduce your problem? So we can look into it.

9621.zip (12.3 KB)

Regards,

Ethan

Ultimately what is causing the exception is a duplicate feature id in the inmemorylayer. The feature I create to put in the inmemoryLayer retains the feature id from the original feature. Since the results can encompass multiple feature layers I am getting duplicate ids.

Hi Richard,

Yes if the feature with same id it will met this problem.

You can loop your feature in your inmemory layer and reset it for example:

feature.Id = Guid.NewGuid().ToString();

Regards,

Ethan