示例#1
0
        private static bool TypeOf(Geometries.Geometry geometry, Type type)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException("geometry");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            return(geometry.GetType() == type);
        }
示例#2
0
        /// <summary>
        /// Converts any <see cref="GisSharpBlog.NetTopologySuite.Geometries.Geometry"/> to the correspondant
        /// <see cref="SharpMap.Geometries.Geometry"/>.
        /// </summary>
        public static NTSGeometry ToNTSGeometry(Geometries.Geometry geometry, IGeometryFactory factory)
        {
            if (geometry == null)
            {
                throw new NullReferenceException("geometry");
            }

            if (TypeOf(geometry, typeof(Geometries.Point)))
            {
                return(ToNTSPoint(geometry as Geometries.Point, factory));
            }

            if (TypeOf(geometry, typeof(Geometries.LineString)))
            {
                return(ToNTSLineString(geometry as Geometries.LineString, factory));
            }

            if (TypeOf(geometry, typeof(Geometries.Polygon)))
            {
                return(ToNTSPolygon(geometry as Geometries.Polygon, factory));
            }

            if (TypeOf(geometry, typeof(Geometries.MultiPoint)))
            {
                return(ToNTSMultiPoint(geometry as Geometries.MultiPoint, factory));
            }

            if (TypeOf(geometry, typeof(Geometries.MultiLineString)))
            {
                return(ToNTSMultiLineString(geometry as Geometries.MultiLineString, factory));
            }

            if (TypeOf(geometry, typeof(Geometries.MultiPolygon)))
            {
                return(ToNTSMultiPolygon(geometry as Geometries.MultiPolygon, factory));
            }

            if (TypeOf(geometry, typeof(Geometries.GeometryCollection)))
            {
                return(ToNTSGeometryCollection(geometry as Geometries.GeometryCollection, factory));
            }

            var message = String.Format("Type {0} not supported", geometry.GetType().FullName);

            throw new NotSupportedException(message);
        }