public static GeoAPI.Geometries.ILinearRing ConvertTo(ESRI.ArcGIS.Geometry.IRing ring) { ESRI.ArcGIS.Geometry.IPoint fromToPoint = ring.FromPoint; List <GeoAPI.Geometries.ICoordinate> list = new List <GeoAPI.Geometries.ICoordinate>(); list.Add(ConvertTo(fromToPoint)); ISegmentCollection segmentCollection = ring as ISegmentCollection; if (segmentCollection != null) { int count = segmentCollection.SegmentCount; for (int i = 0; i < count; i++) { ISegment segment = segmentCollection.get_Segment(i); if (!(segment is ILine)) { throw new ApplicationException("Curves are not supported."); } list.Add(ConvertTo(segment.ToPoint)); } } else { throw new ApplicationException("No segments found in the ring geometry."); } list.Add(ConvertTo(fromToPoint)); list.Reverse(); return(new GisSharpBlog.NetTopologySuite.Geometries.LinearRing(list.ToArray())); }
//获得一个环的形状 private static ESRI.ArcGIS.Geometry.Polygon MakePolygonFromRing(ESRI.ArcGIS.Geometry.IRing pRing) { ESRI.ArcGIS.Geometry.Polygon pResPolygon = null; ESRI.ArcGIS.Geometry.IPolygon pPolygon = null; try { pPolygon = new ESRI.ArcGIS.Geometry.PolygonClass(); ESRI.ArcGIS.Geometry.IGeometryCollection pGeometryCollection; pGeometryCollection = pPolygon as ESRI.ArcGIS.Geometry.IGeometryCollection; object missing = Type.Missing; pGeometryCollection.AddGeometry(pRing, ref missing, ref missing); pResPolygon = pPolygon as ESRI.ArcGIS.Geometry.Polygon; return(pResPolygon); } catch (Exception err) { pResPolygon = null; pPolygon = null; } return(null); }