/// <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> /// Convests the polygon to osm objects. /// </summary> /// <param name="polygon"></param> /// <returns></returns> private static Polygon ConvertPolygon(OsmSharp.Xml.Kml.v2_1.PolygonType polygon) { IEnumerable <LineairRing> inners = KmlGeometryStreamSource.ConvertBoundary(polygon.innerBoundaryIs); LineairRing outer = KmlGeometryStreamSource.ConvertLinearRing(polygon.outerBoundaryIs.LinearRing); return(new Polygon(outer, inners)); }
/// <summary> /// Converts a polygon. /// </summary> /// <param name="polygon"></param> /// <returns></returns> private static Polygon ConvertPolygon(OsmSharp.Xml.Kml.v2_0_response.Polygon polygon) { LineairRing inner = KmlGeometryStreamSource.ConvertLinearRing(polygon.innerBoundaryIs.LinearRing); LineairRing outer = KmlGeometryStreamSource.ConvertLinearRing(polygon.outerBoundaryIs.LinearRing); return(new Polygon(outer, new LineairRing[] { inner })); }
/// <summary> /// Converts boundary type into an osm object. /// </summary> /// <param name="boundary"></param> /// <returns></returns> private static IEnumerable <LineairRing> ConvertBoundary(OsmSharp.Xml.Kml.v2_1.boundaryType[] boundary) { List <LineairRing> rings = new List <LineairRing>(); foreach (OsmSharp.Xml.Kml.v2_1.boundaryType geo in boundary) { rings.Add(KmlGeometryStreamSource.ConvertLinearRing(geo.LinearRing)); } return(rings); }