I’m trying to style a layer of road segments (a total of 2048 features created with LineShape) based on a feature value using ValueStyle, but some tiles are not loading.
The request returns status code 200, but with content-length = 0, and the ones that do load are taking 3 to 4 seconds each.
The way I’m setting the layer style is something like this:
var valueStyle = new ValueStyle();
valueStyle.ColumnName = "RoadStatus";
valueStyle.ValueItems.Add(new ValueItem("Open", new LineStyle(new GeoPen(GeoColor.FromHtml("#5181b2"), 3))));
valueStyle.ValueItems.Add(new ValueItem("Closed", new LineStyle(new GeoPen(GeoColor.FromHtml("#d13135"), 3))));
roadsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
roadsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
If I change the ValueStyle to a LineStyle, all tiles are rendered correctly:
roadsLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.FromHtml("#5181b2"), 3));
I CPU profile shows the majority of CPU time (97%) is spent on MapSuite.WebApi.Overlay::Draw.
I was getting a “Collection was modified; enumeration operation may not execute.” exception on layerOverlay.Draw(geoCanvas);.
The only difference I noticed was that I was creating the InMemoryFeatureLayer object only once and reusing on every request, and in your example you create a new object every time. I changed my code and the problem is gone.
I’m still a little confused because I have that InMemoryFeatureLayer reuse in other layers without problems. Even when I change your example to create that object only once, the problem doesn’t occur.
We were creating it on first request, and on subsequent ones we just returned the already created object. We refactored to create it on every request, and we didn’t see any degradation in performance, so we decided to leave it that way.