Select to view content in your preferred language

Convert Serialized PolygonN (XML) to Silverlight ESRI.ArcGIS.Client.Geometry.Polygon?

1854
3
12-01-2011 09:14 AM
DavidMarley
Occasional Contributor II
Is there a convenient way to convert a PolygonN serialized as XML to a Silverlight ESRI.ArcGIS.Client.Geometry.Polygon?  Back in the Web ADF days, you could use a combination of System.Xml.Serialization.XmlSerializer and ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPolygon to create the Web ADF polygon from the PolygonN XML.  I would like to do the same within Silverlight to create ESRI.ArcGIS.Client.Geometry.Polygons.

I am hoping to avoid parsing the XML for the ring(s)/PointArray/Points and manually constructing the Silverlight polygon.

Background:  On one project we have a fairly substantial web service that pulls data from numerous sources (GIS and non-GIS) and among the return data are Esri Geometries (PolygonN, PolylineN, PointN) serialized as XML on the server and returned to the service consumer as a string. I don't have the luxury of modifying this web service, and am hoping to avoid having to create some kind of companion service that returns the Esri geometries in a more "Silverlight-friendly" way (for example, I've read the Esri blog post "Sending geometry between Silverlight and the server using WCF" - good post and I totally get how to do that, but don't want to go there...).

ArcGIS Server 10 SP3 and Silverlight API 2.2 (though that may soon change to 2.3).
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
In this thread, I gave code to serialize and deserialize graphics in XML (including geometry).

Not sure it's useful if your XML input geometry is not using the same exact format, but it's worth to look at.
0 Kudos
DavidMarley
Occasional Contributor II
Thanks for the reply Dominique - I did find you post in my searches, and I will definitely take a look at your code.
0 Kudos
dotMorten_esri
Esri Notable Contributor
Also see this sample: http://www.arcgis.com/home/item.html?id=6d28a606369c43fd9a6f929541ae7c93
While this converts SQL Server Geometry to JSON, it should provide you with the key parts for doing the same thing with PolygonN.
0 Kudos