/// <summary> /// Converts an IJsonGeometry object into an Esri IGeometry object. /// </summary> /// <param name="shape"></param> /// <returns></returns> public static IGeometry ToEsriGeometry(this IJsonGeometry shape) { var point = shape as JsonPoint; if (point != null) { return(point.ToEsriPoint()); } var multipoint = shape as JsonMultipoint; if (multipoint != null) { return(multipoint.ToEsriMultipoint()); } var polyline = shape as JsonPolyline; if (polyline != null) { return(polyline.ToEsriPolyline()); } var polygon = shape as JsonPolygon; if (polygon != null) { return(polygon.ToEsriPolygon()); } throw new Exception("This geometry type is not supported."); }
/// <summary> /// Converts a serializable geometry into KML. /// </summary> /// <param name="shape"></param> /// <param name="z">Altitude in meters</param> /// <param name="extraElements">Array of extra elements (i.e. altitudeMode).</param> /// <returns></returns> public static XElement ToKml(this IJsonGeometry shape, double z = 0, params XElement[] extraElements) { var point = shape as JsonPoint; if (point != null) { return(point.ToKmlPoint(z, extraElements)); } var multipoint = shape as JsonMultipoint; if (multipoint != null) { return(multipoint.ToKmlMultipoint(z, extraElements)); } var polyline = shape as JsonPolyline; if (polyline != null) { return(polyline.ToKmlPolyline(z, extraElements)); } var polygon = shape as JsonPolygon; if (polygon != null) { return(polygon.ToKmlPolygon(z, extraElements)); } throw new Exception("This geometry type is not supported."); }