Projection services slow, can we multi-thread?

459
2
02-21-2014 11:20 AM
LuisGarcia2
Occasional Contributor II
we have a map that displays a large number of graphics (in a graphic layer). We set up the property myGraphicLayer.ProjectionService. We then create  MapPoint's and set the spatial reference property. These map points are finally added as the geometry of the ESRI.ArcGIS.Client.Graphic objects which in turn go into the graphic layer.


GeometryService geomser = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
GraphicsLayer gl = new GraphicsLayer();
gl.ProjectionService = geomser;
this.mapControl1.map1.Layers.Add(gl);

//FROM HERE ON WE NORMALLY DO IT IN A LOOP  TO ADD SEVERAL GRAPHICS

MapPoint p = new MapPoint(myLongitude, myLatitude, null);
p.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(4267);
SimpleMarkerSymbol mark = new SimpleMarkerSymbol();

ESRI.ArcGIS.Client.Graphic g = new ESRI.ArcGIS.Client.Graphic();

g.Symbol = mark;
g.Geometry = p; 

gl.Graphics.Add(g);



We have noticed (and timed) the process of adding the graphics to the layer in a loop as described before. That does not take any time at all; yet the application pretty much freezes. We have checked in several points and it seems to be waiting on the projection service to comeback. My guess is that it sends the projections one by one and it is waiting for all of them to comeback?? Is there any way for us to set this up in a way that it sends a batch to the projection service? If not, then is there a way to make this work in a multi-threaded environment so the projections are happening yet the client can continue working?
thanks!
0 Kudos
2 Replies
AhmedEl-Sisi
Occasional Contributor III
You can use Geometry Service to project all your graphics list in one shot and it will be Async.

After projection complete you can assign your symbology.
0 Kudos
dotMorten_esri
Esri Frequent Contributor
The projection service does perform batching (but will group by geometry type). However it's NOT recommended to rely on the projection service to project large amounts of geometry. Instead it's better to create/retrieve the geometries in the correct spatial reference to begin with.
0 Kudos