/// <summary> /// 线与外圆相交的多边形 /// </summary> /// <param name="features"></param> public static void outPolygonOuput(IList <IFeature> features) { IList <IGeometry> outPolygons = new List <IGeometry>(); IList <IGeometry> outPolygon = new List <IGeometry>(); for (int i = 0; i < features.Count; i++) { // intPolygon intP = new Algorithm.Utils.Public.intPolygon(); //intP.getOutPolygons(features[i]); outPolygons = intPolygon.getOutPolygons(features[i]); foreach (var polygon in outPolygons) { outPolygon.Add(polygon); } } string path1 = @"H:\test\结果\outpolygon实验测试1.shp"; var shapefileWriter = new ShapefileWriter(path1, ShapeGeometryType.Polygon); foreach (var p in outPolygon) { shapefileWriter.Write(p); } string path2 = @"H:\test\结果\outpolygon实验测试1.dbf"; ShapefileWriter.WriteDummyDbf(path2, outPolygon.Count); shapefileWriter.Close(); Console.WriteLine("生成成功"); Console.ReadKey(); }
public static void interBoundaryOuput(IList <IFeature> features) { IList <IGeometry> interBoundarys = new List <IGeometry>(); IList <IGeometry> interBoundary = new List <IGeometry>(); for (int i = 0; i < features.Count; i++) { // intPolygon intP = new Algorithm.Utils.Public.intPolygon(); //intP.getOutPolygons(features[i]); interBoundarys = intPolygon.getInterBoundaryPolygons(features[i]); foreach (var polygon in interBoundarys) { interBoundary.Add(polygon); } } string path1 = @"H:\test\结果\interBoundary1.shp"; var shapefileWriter = new ShapefileWriter(path1, ShapeGeometryType.LineString); foreach (var p in interBoundary) { shapefileWriter.Write(p); } string path2 = @"H:\test\结果\interBoundary1.dbf"; ShapefileWriter.WriteDummyDbf(path2, interBoundary.Count); shapefileWriter.Close(); Console.WriteLine("生成成功"); Console.ReadKey(); }
public static void minCircleOutput(IList <IFeature> features) { IList <ILineString> circles = new List <ILineString>(); for (int i = 0; i < features.Count; i++) { ILineString minLine = MinPoints.getMinVector(features[i]); ILineString circle = Circles.getCircle(minLine.Coordinates[0], minLine.Coordinates[1]); circles.Add(circle); } string path1 = @"H:\test\结果\MinCircle1.shp"; var shapefileWriter = new ShapefileWriter(path1, ShapeGeometryType.LineString); foreach (var circle in circles) { shapefileWriter.Write(circle); } string path2 = @"H:\test\结果\MinCircle1.dbf"; ShapefileWriter.WriteDummyDbf(path2, features.Count); shapefileWriter.Close(); Console.WriteLine("生成成功"); Console.ReadKey(); }
public static void linesOuput(IList <IFeature> features) { IList <ILineString> lines = new List <ILineString>(); for (int i = 0; i < features.Count; i++) { foreach (var line in new AngleProperty(features[i]).Lines) { lines.Add(line); } } string path1 = @"H:\test\结果\lines实验.shp"; var shapefileWriter = new ShapefileWriter(path1, ShapeGeometryType.LineString); foreach (var line in lines) { shapefileWriter.Write(line); } string path2 = @"H:\test\结果\lines实验.dbf"; ShapefileWriter.WriteDummyDbf(path2, lines.Count); shapefileWriter.Close(); Console.WriteLine("生成成功"); Console.ReadKey(); }
public static void minLineOutput(IList <IFeature> features) { IList <ILineString> minLines = new List <ILineString>(); for (int i = 0; i < features.Count; i++) { minLines.Add(MinPoints.getMinVector(features[i])); } string path1 = @"H:\test\结果\MinLine1.shp"; var shapefileWriter = new ShapefileWriter(path1, ShapeGeometryType.LineString); foreach (var minLine in minLines) { shapefileWriter.Write(minLine); } string path2 = @"H:\test\结果\MinLine1.dbf"; ShapefileWriter.WriteDummyDbf(path2, features.Count); shapefileWriter.Close(); Console.WriteLine("生成成功"); Console.ReadKey(); }
public void TestWriteSimpleShapeFile() { IPoint p1 = Factory.CreatePoint(new Coordinate(100, 100)); IPoint p2 = Factory.CreatePoint(new Coordinate(200, 200)); GeometryCollection coll = new GeometryCollection(new IGeometry[] { p1, p2, }); ShapefileWriter writer = new ShapefileWriter(Factory); writer.Write(@"c:\test_arcview", coll); ShapefileWriter.WriteDummyDbf(@"c:\test_arcview.dbf", 2); // Not read by ArcView!!! }
public void TestReadingShapeFileAfvalbakken() { IGeometryFactory factory = GeometryFactory.Default; List <IPolygon> polys = new List <IPolygon>(); const int distance = 500; using (ShapefileDataReader reader = new ShapefileDataReader("afvalbakken", factory)) { int index = 0; while (reader.Read()) { IGeometry geom = reader.Geometry; Assert.IsNotNull(geom); Assert.IsTrue(geom.IsValid); Debug.WriteLine(String.Format("Geom {0}: {1}", index++, geom)); IGeometry buff = geom.Buffer(distance); Assert.IsNotNull(buff); polys.Add((IPolygon)geom); } } IMultiPolygon multiPolygon = factory.CreateMultiPolygon(polys.ToArray()); Assert.IsNotNull(multiPolygon); Assert.IsTrue(multiPolygon.IsValid); IMultiPolygon multiBuffer = (IMultiPolygon)multiPolygon.Buffer(distance); Assert.IsNotNull(multiBuffer); Assert.IsTrue(multiBuffer.IsValid); ShapefileWriter writer = new ShapefileWriter(factory); writer.Write(@"test_buffer", multiBuffer); ShapefileWriter.WriteDummyDbf(@"test_buffer.dbf", multiBuffer.NumGeometries); }