I'm attempting to update a lot of features on my map as new data comes in, hopefully in the most efficient manner I can find. I looked at the example of the moving plane and came up with the code below. I'm attempting to get the RectangleShape associated with the feature and change it's height based on the new data. The feature is found by the query, but the returned RectangleShape is null.
//redraw the noise display
InMemoryFeatureLayer receiversLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("ReceiversLayer");
Overlay ReceiversOverlay = winformsMap1.Overlays["ReceiversOverlay"];
String[] columns = { "SerialNumber", "Noise" };
// Lock the overlay while we update the points
ReceiversOverlay.Lock.EnterWriteLock();
try
{
foreach (ReceiverUnit r in receivers.Values)
{
receiversLayer.Open();
Feature f = receiversLayer.QueryTools.GetFeatureById(r.SerialNumber, columns);
receiversLayer.Close();
RectangleShape rectShape = f.GetShape() as RectangleShape; // why is this null?
rectShape.UpperLeftPoint.Y = r.LatLong.Y + r.Noise*.01;
f.ColumnValues["Noise"] = r.Noise.ToString();
receiversLayer.Open();
receiversLayer.EditTools.BeginTransaction();
//receiversLayer.EditTools.Update(f);
receiversLayer.EditTools.Update(rectShape);
receiversLayer.EditTools.CommitTransaction();
receiversLayer.Close();
}
}
finally {
// Release the lock on the overlay
ReceiversOverlay.Lock.ExitWriteLock();
}
winformsMap1.Refresh();
}
Apparently I'm doing this wrong, but I don't find any other examples of doing this. I have tried clearing the features in the layer and creating new ones, which works, but at only 100 points, the updating is erratic, rather than smooth, and sometimes stops for a short moment. I will have many more than 100 points, so I'm looking at other methods.
Thanks for any help,
Janene
Wireless Seismic