Select to view content in your preferred language

WPF Performance

1113
5
08-23-2010 07:04 PM
linusang
Emerging Contributor
Hi,

I'm doing a multitouch app together with ArcGIS API in WPF 4. I'm experiencing sluggish performance with a FeatureLayer that has hundreds of polylines when i'm zooming in/out. My system is definitely not slow... it has an i5 processor, 8gb ram and nvidia GTX 285. the map zooms in/out quite smoothly when there is only the base map layer added.. although there is some signs of sluggishness as well....

is there a way i can pause the layer loading while the user is zooming and refresh the layer when the user has finished zooming? i believe it might improve the performance

Another issue is i'm using the GeoRssLayer to display USGS earthquake data in the Web Mercator projection. I'm using the CollectionChanged event in the GeoRssLayer's Layer property to change the MapPoint geometry. However, my UI freezes a while when i'm adding this layer. I believe it is becaused the CollectionChanged event fires a hundred times which causes the slight freeze...

is there a way i could improve these performances? thanks
0 Kudos
5 Replies
dotMorten_esri
Esri Notable Contributor
I'd like to see how you do the zooming/panning and how you are updating your graphics. Some ways are more efficient than others.

On a side note: Touch support is scheduled for v2.1, so if everything goes well you should hopefully be getting this out of the box in the next version.
0 Kudos
linusang
Emerging Contributor
hi thanks for the reply

my code for the manipulationdelta is as follows:

void targetMap_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {

            e.Handled = true;

            if (this.targetMap == null) { return; }
            if (this.targetMap.Extent == null) { return; }
            if ((e.DeltaManipulation.Translation.X == 0) && (e.DeltaManipulation.Translation.Y == 0) && (e.DeltaManipulation.Scale.X == 1)) { return; }


            if ((e.DeltaManipulation.Translation.X != 0) || (e.DeltaManipulation.Translation.Y != 0))
            {
                //Get map center coord
                MapPoint mapCenter = this.targetMap.Extent.GetCenter();
                //convert to screen coord
                Point screenCenter = this.targetMap.MapToScreen(mapCenter);
                Point newScreenCenter;

                newScreenCenter = Point.Subtract(screenCenter, e.DeltaManipulation.Translation);                
                MapPoint newMapCenter = this.targetMap.ScreenToMap(newScreenCenter);                
                this.targetMap.PanTo(newMapCenter);


            }

            if (!e.IsInertial)
            {

                if (e.DeltaManipulation.Scale.X != 1)
                {
                    if (targetMap.TouchesCaptured.Count() > 1)
                    {

                        Point currentManipulationOriginScreen = e.ManipulationOrigin;
                        MapPoint zoomCenter = this.targetMap.ScreenToMap(currentManipulationOriginScreen);

                        targetMap.ZoomToResolution(this.targetMap.Resolution / Math.Round(e.DeltaManipulation.Scale.X, 2), zoomCenter);
                    }
                }
            }

        }


and also can you suggest any performance improvement for my 2nd issue regarding the GeoRssLayer?

Another issue is i'm using the GeoRssLayer to display USGS earthquake data in the Web Mercator projection. I'm using the CollectionChanged event in the GeoRssLayer's Layer property to change the MapPoint geometry. However, my UI freezes a while when i'm adding this layer. I believe it is becaused the CollectionChanged event fires a hundred times which causes the slight freeze...
0 Kudos
dotMorten_esri
Esri Notable Contributor
Remember that the manipulation events will fire very frequent, and you are thus triggering an enormous amount of zoom animations (likely even faster than the screen framerate).
You are probably better off setting the extent directly, instead of calling the zoom and pan animations.
0 Kudos
linusang
Emerging Contributor
Thanks, i manage to get smoother performance using your suggestion....

for those interested.. this is the updated algo using matrix to transform the envelope's MapPoint1(Xmin & Ymin) and MapPoint2(Xmax, Ymax)...

void targetMap_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {

            e.Handled = true;

            if (this.targetMap == null) { return; }
            if (this.targetMap.Extent == null) { return; }
            if ((e.DeltaManipulation.Translation.X == 0) && (e.DeltaManipulation.Translation.Y == 0) && (e.DeltaManipulation.Scale.X == 1)) { return; }

            
            Matrix transformationMatrix = new Matrix();
            if ((e.DeltaManipulation.Translation.X != 0) || (e.DeltaManipulation.Translation.Y != 0))
            {


                transformationMatrix.Translate(-e.DeltaManipulation.Translation.X, -e.DeltaManipulation.Translation.Y);

                
            }

            if (!e.IsInertial)
            {

                if (e.DeltaManipulation.Scale.X != 1)
                {
                    if (targetMap.TouchesCaptured.Count() > 1)
                    {
                        transformationMatrix.ScaleAt(1/e.DeltaManipulation.Scale.X, 1/e.DeltaManipulation.Scale.Y, e.ManipulationOrigin.X, e.ManipulationOrigin.Y);
                    }
                }
            }

            Envelope en = this.targetMap.Extent;
            Point screenTopLeft = this.targetMap.MapToScreen(new MapPoint(en.Extent.XMin, en.Extent.YMin));
            Point screenBottomRight = this.targetMap.MapToScreen(new MapPoint(en.Extent.XMax, en.Extent.YMax));

            Point newScreenTopLeft = transformationMatrix.Transform(screenTopLeft);
            Point newScreenBottomRight = transformationMatrix.Transform(screenBottomRight);

            MapPoint newMapTopLeft = this.targetMap.ScreenToMap(newScreenTopLeft);
            MapPoint newMapBottomRight = this.targetMap.ScreenToMap(newScreenBottomRight);

            this.targetMap.Extent = new Envelope(newMapTopLeft, newMapBottomRight);
        }


if anyone wants is as a Map Behavior... email me and i will send it....

and now for the 2nd issue with the GeoRssLayer.... suggestions please.....

thanks

EDIT: Just realize there is still sluggishness when a feature layer with hundreds of polyline is added... but it is still better than my previous implementation
0 Kudos
linusang
Emerging Contributor
hi, i have a considerable amount of polygons(featurelayer) added and experience sluggish performance... i tried enabling cache mode to bitmap cache but it doesn't help... is there anything i can do to eliminate the sluggishness?
0 Kudos