ThinkGeo.com    |     Documentation    |     Premium Support

Performance and loading issues with ValueStyle

Hello,

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.

Do you have any idea where the problem may be?

Thanks!

Just to add, I tried reducing the number of features to about 100, but that do not seem to improve the performance.

Hi Douglas_Matoso,

I build a quickly sample which render the 100 lines, but it looks the CPU usage is well and I hadn’t reproduce your exception.

Could you please try this sample and modify it to reproduce your issue?

9122.zip (11.1 KB)

Regards,

Ethan

Thanks, Ethan!

I’ll check it out and see what I’m doing differently.

Regards,

Hi Douglas_Matoso,

Any update please let us know.

Regards,

Ethan

Hi, Ethan!

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.

Thanks!

Hi Douglas_Matoso,

For WebAPI I think it won’t save the status, so could you let me know where you save the InMemoryFeatureLayer in server side?

Have you tried to save LayerOverlay instead of the Layer?

Regards,

Ethan

Hi Ethan,

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.

Thanks for your support.

Hi Douglas_Matoso,

I am glad to hear you find a solution for it.

Any question please let us know.

Regards,

Ethan