示例#1
0
        public static dynamic GetGISGeometries(dynamic Geometry)
        {
            var geometries = new GISServer.Core.Geometry.Geometries();
            var geometrieslist = new List<GISServer.Core.Geometry.Geometry>();
            if (Geometry is DotSpatial.Topology.Point)
            {
                var point = new GISServer.Core.Geometry.Point(Geometry.X, Geometry.Y);
                geometrieslist.Add(point);
                geometries.GeometryType = "GeometryPoint";
                geometries.geometries = geometrieslist;
                return geometries;
            }
            else if (Geometry is DotSpatial.Topology.MultiPoint)
            {
                var multipoint = new GISServer.Core.Geometry.MultiPoint();
                multipoint.Points = new List<GISServer.Core.Geometry.Point>();
                foreach (var coordinate in Geometry.Coordinates)
                {
                    var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                    multipoint.Points.Add(point);
                }
                geometrieslist.Add(multipoint);
                geometries.GeometryType = "GeometryMultipoint";
                geometries.geometries = geometrieslist;
                return geometries;
            }
            else if (Geometry is DotSpatial.Topology.MultiLineString)
            {
                var multiline = new GISServer.Core.Geometry.Polyline();
                multiline.Paths = new List<GISServer.Core.Geometry.PointCollection>();

                for (int i = 0; i < Geometry.Count; i++)
                {
                    var pointcollection = new GISServer.Core.Geometry.PointCollection();
                    foreach (var coordinate in Geometry[i].Coordinates)
                    {
                        var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                        pointcollection.Add(point);
                    }
                    multiline.Paths.Add(pointcollection);
                }
                geometrieslist.Add(multiline);
                geometries.GeometryType = "GeometryPolyline";
                geometries.geometries = geometrieslist;
                return geometries;
            }
            else if (Geometry is DotSpatial.Topology.Polygon)
            {
                var polygon = new GISServer.Core.Geometry.Polygon();
                polygon.Rings = new List<GISServer.Core.Geometry.PointCollection>();
                var pointcollection = new GISServer.Core.Geometry.PointCollection();
                foreach (var coordinate in Geometry.Coordinates)
                {
                    var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                    pointcollection.Add(point);
                }
                polygon.Rings.Add(pointcollection);
                geometrieslist.Add(polygon);
                geometries.GeometryType = "GeometryPolygon";
                geometries.geometries = geometrieslist;
                return geometries;
            }
            else if (Geometry is DotSpatial.Topology.MultiPolygon)
            {
                var polygon = new GISServer.Core.Geometry.Polygon();
                polygon.Rings = new List<GISServer.Core.Geometry.PointCollection>();

                for (int i = 0; i < Geometry.Count; i++)
                {
                    var pointcollection = new GISServer.Core.Geometry.PointCollection();
                    foreach (var coordinate in Geometry[i].Coordinates)
                    {
                        var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                        pointcollection.Add(point);
                    }
                    polygon.Rings.Add(pointcollection);
                }
                geometrieslist.Add(polygon);
                geometries.GeometryType = "GeometryPolygon";
                geometries.geometries = geometrieslist;
                return geometries;
            }
            else if (Geometry is DotSpatial.Topology.Envelope)
            {
                var envelope = new GISServer.Core.Geometry.Envelope(Geometry.Minimum.X, Geometry.Minimum.Y, Geometry.Maximum.X, Geometry.Minimum.Y);
                geometrieslist.Add(envelope);
                geometries.GeometryType = "GeometryEnvelope";
                geometries.geometries = geometrieslist;
                return geometries;
            }
            else if (Geometry is List<DotSpatial.Topology.IGeometry>)
            {
                foreach (var geometry in Geometry)
                {
                    var polygon = new GISServer.Core.Geometry.Polygon();
                    polygon.Rings = new List<GISServer.Core.Geometry.PointCollection>();
                    var pointcollection = new GISServer.Core.Geometry.PointCollection();
                    foreach (var coordinate in geometry.Coordinates)
                    {
                        var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                        pointcollection.Add(point);
                    }
                    polygon.Rings.Add(pointcollection);
                    geometrieslist.Add(polygon);
                }

                geometries.GeometryType = "GeometryPolygon";
                geometries.geometries = geometrieslist;
                return geometries;
            }
            return null;
        }
示例#2
0
        public static dynamic GetGISSingleGeometry(dynamic Geometry)
        {
            var singleGeometry = new GISServer.Core.Geometry.SingleGeometry();
            if (Geometry is DotSpatial.Topology.Point)
            {
                var point = new GISServer.Core.Geometry.Point(Geometry.X, Geometry.Y);
                singleGeometry.GeometryType = "GeometryPoint";
                singleGeometry.geometry = point;
                return singleGeometry;
            }
            else if (Geometry is DotSpatial.Topology.MultiPoint)
            {
                var multipoint = new GISServer.Core.Geometry.MultiPoint();
                multipoint.Points = new List<GISServer.Core.Geometry.Point>();
                foreach (var coordinate in Geometry.Coordinates)
                {
                    var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                    multipoint.Points.Add(point);
                }
                singleGeometry.GeometryType = "GeometryMultipoint";
                singleGeometry.geometry = multipoint;
                return singleGeometry;
            }
            else if (Geometry is DotSpatial.Topology.MultiLineString)
            {
                var multiline = new GISServer.Core.Geometry.Polyline();
                multiline.Paths = new List<GISServer.Core.Geometry.PointCollection>();

                for (int i = 0; i < Geometry.Count; i++)
                {
                    var pointcollection = new GISServer.Core.Geometry.PointCollection();
                    foreach (var coordinate in Geometry[i].Coordinates)
                    {
                        var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                        pointcollection.Add(point);
                    }
                    multiline.Paths.Add(pointcollection);
                }
                singleGeometry.GeometryType = "GeometryPolyline";
                singleGeometry.geometry = multiline;
                return singleGeometry;
            }
            else if (Geometry is DotSpatial.Topology.Polygon)
            {
                var polygon = new GISServer.Core.Geometry.Polygon();
                polygon.Rings = new List<GISServer.Core.Geometry.PointCollection>();
                var pointcollection = new GISServer.Core.Geometry.PointCollection();
                foreach (var coordinate in Geometry.Coordinates)
                {
                    var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                    pointcollection.Add(point);
                }
                polygon.Rings.Add(pointcollection);
                singleGeometry.GeometryType = "GeometryPolygon";
                singleGeometry.geometry = polygon;
                return singleGeometry;
            }
            else if (Geometry is DotSpatial.Topology.MultiPolygon)
            {
                var polygon = new GISServer.Core.Geometry.Polygon();
                polygon.Rings = new List<GISServer.Core.Geometry.PointCollection>();

                for (int i = 0; i < Geometry.Count; i++)
                {
                    var pointcollection = new GISServer.Core.Geometry.PointCollection();
                    foreach (var coordinate in Geometry[i].Coordinates)
                    {
                        var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                        pointcollection.Add(point);
                    }
                    polygon.Rings.Add(pointcollection);
                }
                singleGeometry.GeometryType = "GeometryPolygon";
                singleGeometry.geometry = polygon;
                return singleGeometry;
            }
            else if (Geometry is DotSpatial.Topology.Envelope)
            {
                var envelope = new GISServer.Core.Geometry.Envelope(Geometry.Minimum.X, Geometry.Minimum.Y, Geometry.Maximum.X, Geometry.Minimum.Y);
                singleGeometry.GeometryType = "GeometryEnvelope";
                singleGeometry.geometry = envelope;
                return singleGeometry;
            }
            return null;
        }
示例#3
0
        public static dynamic GetGISSingleGeometry(dynamic Geometry)
        {
            var singleGeometry = new GISServer.Core.Geometry.SingleGeometry();

            if (Geometry is DotSpatial.Topology.Point)
            {
                var point = new GISServer.Core.Geometry.Point(Geometry.X, Geometry.Y);
                singleGeometry.GeometryType = "GeometryPoint";
                singleGeometry.geometry     = point;
                return(singleGeometry);
            }
            else if (Geometry is DotSpatial.Topology.MultiPoint)
            {
                var multipoint = new GISServer.Core.Geometry.MultiPoint();
                multipoint.Points = new List <GISServer.Core.Geometry.Point>();
                foreach (var coordinate in Geometry.Coordinates)
                {
                    var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                    multipoint.Points.Add(point);
                }
                singleGeometry.GeometryType = "GeometryMultipoint";
                singleGeometry.geometry     = multipoint;
                return(singleGeometry);
            }
            else if (Geometry is DotSpatial.Topology.MultiLineString)
            {
                var multiline = new GISServer.Core.Geometry.Polyline();
                multiline.Paths = new List <GISServer.Core.Geometry.PointCollection>();

                for (int i = 0; i < Geometry.Count; i++)
                {
                    var pointcollection = new GISServer.Core.Geometry.PointCollection();
                    foreach (var coordinate in Geometry[i].Coordinates)
                    {
                        var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                        pointcollection.Add(point);
                    }
                    multiline.Paths.Add(pointcollection);
                }
                singleGeometry.GeometryType = "GeometryPolyline";
                singleGeometry.geometry     = multiline;
                return(singleGeometry);
            }
            else if (Geometry is DotSpatial.Topology.Polygon)
            {
                var polygon = new GISServer.Core.Geometry.Polygon();
                polygon.Rings = new List <GISServer.Core.Geometry.PointCollection>();
                var pointcollection = new GISServer.Core.Geometry.PointCollection();
                foreach (var coordinate in Geometry.Coordinates)
                {
                    var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                    pointcollection.Add(point);
                }
                polygon.Rings.Add(pointcollection);
                singleGeometry.GeometryType = "GeometryPolygon";
                singleGeometry.geometry     = polygon;
                return(singleGeometry);
            }
            else if (Geometry is DotSpatial.Topology.MultiPolygon)
            {
                var polygon = new GISServer.Core.Geometry.Polygon();
                polygon.Rings = new List <GISServer.Core.Geometry.PointCollection>();

                for (int i = 0; i < Geometry.Count; i++)
                {
                    var pointcollection = new GISServer.Core.Geometry.PointCollection();
                    foreach (var coordinate in Geometry[i].Coordinates)
                    {
                        var point = new GISServer.Core.Geometry.Point(coordinate.X, coordinate.Y);
                        pointcollection.Add(point);
                    }
                    polygon.Rings.Add(pointcollection);
                }
                singleGeometry.GeometryType = "GeometryPolygon";
                singleGeometry.geometry     = polygon;
                return(singleGeometry);
            }
            else if (Geometry is DotSpatial.Topology.Envelope)
            {
                var envelope = new GISServer.Core.Geometry.Envelope(Geometry.Minimum.X, Geometry.Minimum.Y, Geometry.Maximum.X, Geometry.Minimum.Y);
                singleGeometry.GeometryType = "GeometryEnvelope";
                singleGeometry.geometry     = envelope;
                return(singleGeometry);
            }
            return(null);
        }