Exemple #1
0
        /// <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;
                }
            }
        }
Exemple #2
0
        /// <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;
                }
            }
        }