public static XElement FromGeometry(SuperMap.WindowsPhone.Core.Geometry geo)
{
if (geo == null)
{
return null;
}
XElement xe = null;
if (geo is GeoPoint)
{
xe = new XElement("{" + gml + "}Point");
XElement coordinates = new XElement("{" + gml + "}coordinates", XMLHelper.GetCoorStr((geo as GeoPoint).Location));
xe.Add(coordinates);
}
else if (geo is GeoLine)
{
//xe = new XElement(XName.Get("MultiLineString", gml), new XAttribute("{" + defaultNS + "}gml", gml));
xe = new XElement("{" + gml + "}MultiLineString");
foreach (Point2DCollection item in (geo as GeoLine).Parts)
{
XElement coordinates = new XElement("{" + gml + "}coordinates", XMLHelper.GetCoorStr(item));
XElement LineString = new XElement("{" + gml + "}LineString", coordinates);
xe.Add(new XElement("{" + gml + "}lineStringMember", LineString));
}
}
else if (geo is GeoRegion)
{
xe = new XElement("{" + gml + "}MultiPolygon");
foreach (Point2DCollection item in (geo as GeoRegion).Parts)
{
XElement coordinates = new XElement("{" + gml + "}coordinates", XMLHelper.GetCoorStr(item));
XElement linearRing = new XElement("{" + gml + "}LinearRing", coordinates);
XElement outerBoundaryIs = new XElement("{" + gml + "}outerBoundaryIs", linearRing);
XElement polygon = new XElement("{" + gml + "}Polygon", outerBoundaryIs);
xe.Add(new XElement("{" + gml + "}polygonMember", polygon));
}
}
else
{ }
return xe;
}