Esempio n. 1
0
        /// <summary>
        /// Converts a point into an oms object.
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private static Point ConvertPoint(OsmSharp.Xml.Kml.v2_1.PointType point)
        {
            // convert the coordiantes.
            IList <GeoCoordinate> coordinates = KmlGeometryStreamSource.ConvertCoordinates(point.coordinates);

            // create the point.
            Point pointGeometry = new Point(coordinates[0]);

            pointGeometry.Attributes = new SimpleGeometryAttributeCollection();
            if (point.targetId != null)
            {
                pointGeometry.Attributes.Add("targetId", point.targetId);
            }
            pointGeometry.Attributes.Add("altitude", point.altitudeMode);
            if (point.extrude)
            {
                pointGeometry.Attributes.Add("extrude", point.extrude);
            }
            if (point.id != null)
            {
                pointGeometry.Attributes.Add("id", point.id);
            }

            return(pointGeometry);
        }
Esempio n. 2
0
 /// <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);
     }
 }
Esempio n. 3
0
        /// <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));
        }
Esempio n. 4
0
        /// <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 }));
        }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
        /// <summary>
        /// Converts a line string into an osm object.
        /// </summary>
        /// <param name="lineString"></param>
        /// <returns></returns>
        private static LineString ConvertLineString(OsmSharp.Xml.Kml.v2_1.LineStringType lineString)
        {
            // convert the coordinates.
            IList <GeoCoordinate> coordinates = KmlGeometryStreamSource.ConvertCoordinates(lineString.coordinates);

            // create the ring.
            LineString lineStringGeometry = new LineString(coordinates);

            lineStringGeometry.Attributes = new SimpleGeometryAttributeCollection();
            lineStringGeometry.Attributes.Add("id", lineString.id);

            return(lineStringGeometry);
        }
Esempio n. 7
0
        /// <summary>
        /// Converts a lineairring into an osm object.
        /// </summary>
        /// <param name="linearRing"></param>
        /// <returns></returns>
        private static LineairRing ConvertLinearRing(OsmSharp.Xml.Kml.v2_0_response.LinearRing linearRing)
        {
            // convert the coordinates.
            IList <GeoCoordinate> coordinates = KmlGeometryStreamSource.ConvertCoordinates(linearRing.coordinates);

            // create the ring.
            LineairRing ring = new LineairRing(coordinates);

            ring.Attributes = new SimpleGeometryAttributeCollection();
            ring.Attributes.Add("id", linearRing.id);

            return(ring);
        }
Esempio n. 8
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;
                }
            }
        }
Esempio n. 9
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;
                }
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Converts a multilinestring to osm objects.
 /// </summary>
 /// <param name="multiLineString"></param>
 /// <returns></returns>
 private static MultiLineString ConvertMultiLineString(OsmSharp.Xml.Kml.v2_0_response.MultiLineString multiLineString)
 {
     return(new MultiLineString(new LineString[] { KmlGeometryStreamSource.ConvertLineString(multiLineString.LineString) }));
 }
Esempio n. 11
0
 /// <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) }));
 }
Esempio n. 12
0
 /// <summary>
 /// Converts a multipolygon into osm objects.
 /// </summary>
 /// <param name="multiPolygon"></param>
 /// <returns></returns>
 private static MultiPolygon ConvertMultiPolygon(OsmSharp.Xml.Kml.v2_0_response.MultiPolygon multiPolygon)
 {
     return(new MultiPolygon(new Polygon[] { KmlGeometryStreamSource.ConvertPolygon(multiPolygon.Polygon) }));
 }