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; }
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); }