Has anyone tried implementing a custom InMemoryFeatureLayer in the Release Candidate 2 version? I have a custom layer that was working in previous versions, but it no longer works in the latest release. By not works I mean it no longer has spatial query ability via the QueryTools because QueryTools is null. I am overriding SetupToolsCore to setup QueryTools for the layer as well as collumns for the underlying FeatureSourece. The SetupToolsCore method is no longer executing when the layer is initialized. Any ideas? Thanks,
Chad
class FcdInMemoryLayer : InMemoryFeatureLayer
{
private Dictionary<Feature, Style> features;
public FcdInMemoryLayer()
: this(new Dictionary<Feature, Style>())
{
base.QueryTools = new QueryTools(FeatureSource);
}
public FcdInMemoryLayer(Dictionary<Feature, Style> features) : base()
{
this.features = features;
}
public Dictionary<Feature, Style> Features
{
get { return features; }
}
public override bool HasBoundingBox
{
get
{
return features.Count > 0;
}
}
protected override RectangleShape GetBoundingBoxCore()
{
if (features == null || features.Count == 0)
return null;
double minX = features.Select(a => a.Key.GetBoundingBox().UpperLeftPoint.X).Min();
double maxY = features.Select(a => a.Key.GetBoundingBox().UpperLeftPoint.Y).Max();
double maxX = features.Select(a => a.Key.GetBoundingBox().LowerRightPoint.X).Max();
double minY = features.Select(a => a.Key.GetBoundingBox().LowerRightPoint.Y).Min();
return new RectangleShape(minX, maxY, maxX, minY);
}
protected override void SetupToolsCore()
{
// This doesn't execute
Collection<FeatureSourceColumn> newColumns = new Collection<FeatureSourceColumn>();
newColumns.Add(new FeatureSourceColumn(Strings.TrackingNameColumn));
newColumns.Add(new FeatureSourceColumn(Strings.StripNumberColumn));
newColumns.Add(new FeatureSourceColumn(Strings.TickerColumn));
newColumns.Add(new FeatureSourceColumn(Strings.CleanColumn));
FeatureSource = new InMemoryFeatureSource(newColumns, features.Keys);
base.QueryTools = new QueryTools(FeatureSource);
base.SetupToolsCore();
}
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
{
Collection<SimpleCandidate> labelInThisLayer = new Collection<SimpleCandidate>();
Collection<SimpleCandidate> labelInAllLayers = new Collection<SimpleCandidate>();
foreach (Feature feature in features.Keys)
{
//string drawPoint = feature.ColumnValues[Strings.DrawPointColumn];
Style style = features[feature];
style.Draw(new Feature[] { feature }, canvas, labelInThisLayer, labelInAllLayers);
}
}
}