Klaus,
I talked to the Development Team regarding your situation and the recommendation is to not use GeometryCollectionShape for a Feature but instead to create a different feature for each shape as you can see in the code below. In the function Post10111 this is how you are creating the feature. In Post10111_Fix, this is how I recommend you create the features and the quetools qill work fine.
From what I understood from the Development Team, they created GeometryCollectionShape to be in compliance with the geometry library JTS that we use for our geometric functions. But this has not been thouroughly tested for other functions such as the query tools. This is why I recommend you create features as you see in Post10111_Fix. Thank you.
public void LoadPost10111()
{
wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
wpfMap1.CurrentExtent = new RectangleShape(25, 75, 75, 25);
wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
PolygonShape polygon = new PolygonShape("POLYGON((10 60,40 70,30 85, 10 60))");
LineShape line = new LineShape("LINESTRING(60 60, 70 70,75 60, 80 70, 85 60,95 80)");
Feature feature = new Feature(new GeometryCollectionShape(new BaseShape[] { line, polygon }));
inMemoryLayer.InternalFeatures.Add(feature);
inMemoryLayer.Open();
inMemoryLayer.Columns.Add(new FeatureSourceColumn("test"));
inMemoryLayer.Close();
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.RoyalBlue);
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryLayer);
wpfMap1.Overlays.Add("InMemoryOverlay", staticOverlay);
//Exception occurs
inMemoryLayer.Open();
Collection<Feature> features = inMemoryLayer.QueryTools.GetFeaturesNearestTo(new PointShape(35, 40), GeographyUnit.DecimalDegree, 1, ReturningColumnsType.NoColumns);
inMemoryLayer.Close();
wpfMap1.Refresh();
}
public void Post10111_Fix()
{
wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
wpfMap1.CurrentExtent = new RectangleShape(25, 75, 75, 25);
wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
PolygonShape polygon = new PolygonShape("POLYGON((10 60,40 70,30 85, 10 60))");
LineShape line = new LineShape("LINESTRING(60 60, 70 70,75 60, 80 70, 85 60,95 80)");
Feature polygonFeature = new Feature(polygon);
Feature lineFeature = new Feature(line);
inMemoryLayer.InternalFeatures.Add(lineFeature);
inMemoryLayer.InternalFeatures.Add(polygonFeature);
inMemoryLayer.Open();
inMemoryLayer.Columns.Add(new FeatureSourceColumn("test"));
inMemoryLayer.Close();
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.RoyalBlue);
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryLayer);
wpfMap1.Overlays.Add("InMemoryOverlay", staticOverlay);
//No exception
inMemoryLayer.Open();
Collection<Feature> features = inMemoryLayer.QueryTools.GetFeaturesNearestTo(new PointShape(35, 40), GeographyUnit.DecimalDegree, 1, ReturningColumnsType.NoColumns);
inMemoryLayer.Close();
wpfMap1.Refresh();
}