Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts any <see cref=GisSharpBlog.NetTopologySuite.Geometries.Geometry"/> to the correspondant 
        /// <see cref="SharpMap.Geometries.Geometry"/>.
        /// </summary>
        /// <param name="geometry"></param>
        /// <returns></returns>
        public static Geometry ToNTSGeometry(Geometries.Geometry geometry,
                                             GeometryFactory factory)
        {
            if (geometry == null)
                throw new NullReferenceException("geometry");

            if (geometry.GetType() == typeof (Point))
                return ToNTSPoint(geometry as Point, factory);

            else if (geometry.GetType() == typeof (Geometries.LineString))
                return ToNTSLineString(geometry as Geometries.LineString, factory);

            else if (geometry.GetType() == typeof (Geometries.Polygon))
                return ToNTSPolygon(geometry as Geometries.Polygon, factory);

            else if (geometry.GetType() == typeof (Geometries.MultiPoint))
                return ToNTSMultiPoint(geometry as Geometries.MultiPoint, factory);

            else if (geometry.GetType() == typeof (Geometries.MultiLineString))
                return ToNTSMultiLineString(geometry as Geometries.MultiLineString, factory);

            else if (geometry.GetType() == typeof (Geometries.MultiPolygon))
                return ToNTSMultiPolygon(geometry as Geometries.MultiPolygon, factory);

            else if (geometry.GetType() == typeof (Geometries.GeometryCollection))
                return ToNTSGeometryCollection(geometry as Geometries.GeometryCollection, factory);

            else throw new NotSupportedException("Type " + geometry.GetType().FullName + " not supported");
        }