/// <summary> /// Converts a geometry to a list of osm objects. /// </summary> /// <param name="geometry"></param> /// <returns></returns> private void ConvertGeometry(OsmSharp.Xml.Kml.v2_1.GeometryType geometry) { if (geometry is OsmSharp.Xml.Kml.v2_1.PointType) { this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertPoint(geometry as OsmSharp.Xml.Kml.v2_1.PointType)); } else if (geometry is OsmSharp.Xml.Kml.v2_1.LineStringType) { this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertLineString(geometry as OsmSharp.Xml.Kml.v2_1.LineStringType)); } else if (geometry is OsmSharp.Xml.Kml.v2_1.LinearRingType) { this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertLinearRing(geometry as OsmSharp.Xml.Kml.v2_1.LinearRingType)); } else if (geometry is OsmSharp.Xml.Kml.v2_1.PolygonType) { this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertPolygon(geometry as OsmSharp.Xml.Kml.v2_1.PolygonType)); } else if (geometry is OsmSharp.Xml.Kml.v2_1.MultiGeometryType) { this.ConvertMultiGeometry(geometry as OsmSharp.Xml.Kml.v2_1.MultiGeometryType); } }
/// <summary> /// Converts a multigeometry to osm objects. /// </summary> /// <param name="multiGeometry"></param> /// <returns></returns> private void ConvertMultiGeometry(OsmSharp.Xml.Kml.v2_0_response.MultiGeometry multiGeometry) { for (int idx = 0; idx < multiGeometry.Items.Length; idx++) { switch (multiGeometry.ItemsElementName[idx]) { case OsmSharp.Xml.Kml.v2_0_response.ItemsChoiceType.LineString: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertLineString(multiGeometry.Items[idx] as OsmSharp.Xml.Kml.v2_0_response.LineString)); break; case OsmSharp.Xml.Kml.v2_0_response.ItemsChoiceType.MultiGeometry: this.ConvertMultiGeometry(multiGeometry.Items[idx] as OsmSharp.Xml.Kml.v2_0_response.MultiGeometry); break; case OsmSharp.Xml.Kml.v2_0_response.ItemsChoiceType.MultiLineString: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertMultiLineString(multiGeometry.Items[idx] as OsmSharp.Xml.Kml.v2_0_response.MultiLineString)); break; case OsmSharp.Xml.Kml.v2_0_response.ItemsChoiceType.MultiPoint: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertMultiPoint(multiGeometry.Items[idx] as OsmSharp.Xml.Kml.v2_0_response.MultiPoint)); break; case OsmSharp.Xml.Kml.v2_0_response.ItemsChoiceType.MultiPolygon: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertMultiPolygon(multiGeometry.Items[idx] as OsmSharp.Xml.Kml.v2_0_response.MultiPolygon)); break; case OsmSharp.Xml.Kml.v2_0_response.ItemsChoiceType.Point: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertPoint(multiGeometry.Items[idx] as OsmSharp.Xml.Kml.v2_0_response.Point)); break; case OsmSharp.Xml.Kml.v2_0_response.ItemsChoiceType.Polygon: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertPolygon(multiGeometry.Items[idx] as OsmSharp.Xml.Kml.v2_0_response.Polygon)); break; } } }
/// <summary> /// Converts a placemark into an osm object. /// </summary> /// <param name="placemark"></param> /// <returns></returns> private void ConvertPlacemark(OsmSharp.Xml.Kml.v2_0.Placemark placemark) { for (int idx = 0; idx < placemark.Items.Length; idx++) { switch (placemark.ItemsElementName[idx]) { case OsmSharp.Xml.Kml.v2_0.ItemsChoiceType1.LineString: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertLineString(placemark.Items[idx] as OsmSharp.Xml.Kml.v2_0.LineString)); break; case OsmSharp.Xml.Kml.v2_0.ItemsChoiceType1.MultiGeometry: this.ConvertMultiGeometry(placemark.Items[idx] as OsmSharp.Xml.Kml.v2_0.MultiGeometry); break; case OsmSharp.Xml.Kml.v2_0.ItemsChoiceType1.MultiLineString: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertMultiLineString(placemark.Items[idx] as OsmSharp.Xml.Kml.v2_0.MultiLineString)); break; case OsmSharp.Xml.Kml.v2_0.ItemsChoiceType1.MultiPoint: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertMultiPoint(placemark.Items[idx] as OsmSharp.Xml.Kml.v2_0.MultiPoint)); break; case OsmSharp.Xml.Kml.v2_0.ItemsChoiceType1.MultiPolygon: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertMultiPolygon(placemark.Items[idx] as OsmSharp.Xml.Kml.v2_0.MultiPolygon)); break; case OsmSharp.Xml.Kml.v2_0.ItemsChoiceType1.Point: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertPoint(placemark.Items[idx] as OsmSharp.Xml.Kml.v2_0.Point)); break; case OsmSharp.Xml.Kml.v2_0.ItemsChoiceType1.Polygon: this.GeometryCollection.Add( KmlGeometryStreamSource.ConvertPolygon(placemark.Items[idx] as OsmSharp.Xml.Kml.v2_0.Polygon)); break; } } }
/// <summary> /// Converts a multipoint to osm objects. /// </summary> /// <param name="multiPoint"></param> /// <returns></returns> private static MultiPoint ConvertMultiPoint(OsmSharp.Xml.Kml.v2_0_response.MultiPoint multiPoint) { return(new MultiPoint(new Point[] { KmlGeometryStreamSource.ConvertPoint(multiPoint.Point) })); }