public static void maxCircleOutput(IList <IFeature> features) { IList <ILineString> circles = new List <ILineString>(); for (int i = 0; i < features.Count; i++) { ILineString maxLine = MaxPoints.getMaxVector(features[i]); ILineString circle = Circles.getCircle(maxLine.Coordinates[0], maxLine.Coordinates[1]); circles.Add(circle); } string path1 = @"H:\test\结果\MaxCircle实验测试1.shp"; var shapefileWriter = new ShapefileWriter(path1, ShapeGeometryType.LineString); foreach (var circle in circles) { shapefileWriter.Write(circle); } string path2 = @"H:\test\结果\MaxCircle实验测试1.dbf"; ShapefileWriter.WriteDummyDbf(path2, features.Count); shapefileWriter.Close(); Console.WriteLine("生成成功"); Console.ReadKey(); }
private void getPolygons(IFeature feature) { IList <ILineString> lines = new List <ILineString>(); Coordinate centroid = feature.Geometry.Centroid.Coordinate; Coordinate origin = new Coordinate(); origin.X = MaxPoints.getMaxVector(feature).Coordinates[1].X - centroid.X; origin.Y = MaxPoints.getMaxVector(feature).Coordinates[1].Y - centroid.Y; //最大点平移到自定义坐标系 for (int i = 5; i <= 361; i += 5) { double angle = getAngle(origin); double k = 0; angle += i; if (angle > 360) //若角大于360,减去360 { angle -= 360; } k = Math.Tan(angle * Math.PI / 180); Coordinate point = new Coordinate(); //判定每隔5度的点落在1.4象限,2,3象限,或者X轴上 if (angle > 90 && angle < 270) { point.X = -100000.0; point.Y = k * point.X; } else if ((angle >= 0 && angle < 90) || (angle > 270 && angle <= 360)) { point.X = 100000.0; point.Y = k * point.X; } else if (angle == 90) { point.X = 0; point.Y = 100000.0; } else if (angle == 270) { point.X = 0; point.Y = -100000.0; } point.X += centroid.X; //将点移动回到原空间投影坐标系 point.Y += centroid.Y; Coordinate[] points = new Coordinate[] { centroid, point }; LineString line = new LineString(points); if (!line.Intersects(feature.Geometry.Boundary)) //如果所得线段与边界不相交,跳出当前循环,进入下个循环 { continue; } lines.Add(line); } lines.Add(lines[0]); for (int i = 0; i < lines.Count - 1; i++) { Coordinate[] points = new Coordinate[] { centroid, lines[i].Coordinates[1], lines[i + 1].Coordinates[1], centroid }; ILinearRing triangle = new LinearRing(points); Polygon angleArea = new Polygon(triangle); IGeometry area = angleArea.Intersection(feature.Geometry); Polygens.Add(area); //两条线与多边形交出的多边形面积 } }
private void setMaxCha(IFeature feature) { ILineString maxLine = MaxPoints.getMaxVector(feature); AngleProperty property = new AngleProperty(feature); foreach (var line in property.Lines) { Index index = new Index(maxLine.Coordinates[1].Distance(maxLine.Coordinates[0]) - line.Coordinates[1].Distance(line.Coordinates[0]), "外圆与外边界差"); MaxCha.Add(index); } }
private void setMaxCha(IFeature feature) { ILineString maxLine = MaxPoints.getMaxVector(feature); AngleProperty property = new AngleProperty(feature); foreach (var line in property.Lines) { //double index = (maxLine.Coordinates[1].Distance(maxLine.Coordinates[0]) - line.Coordinates[1].Distance(line.Coordinates[0])); double index = (maxLine.Length - line.Length); MaxCha.Add(index);//外圆与外边界差 } }
public Indexs(IFeature feature) { setMaxCha(feature); setMinCha(feature); //setMidCha(feature); setMinMax(); setPolygen(feature); setAreaRatio(feature); setTitio(feature); setPointNum(feature); setRows(); MaxLine = MaxPoints.getMaxVector(feature); MinLine = MinPoints.getMinVector(feature); }
public static void maxLineOutput(IList <IFeature> features) { IList <ILineString> maxLines = new List <ILineString>(); for (int i = 0; i < features.Count; i++) { maxLines.Add(MaxPoints.getMaxVector(features[i])); } string path1 = @"H:\test\结果\MaxLine实验测试1.shp"; var shapefileWriter = new ShapefileWriter(path1, ShapeGeometryType.LineString); foreach (var maxLine in maxLines) { shapefileWriter.Write(maxLine); } string path2 = @"H:\test\结果\MaxLine实验测试1.dbf"; ShapefileWriter.WriteDummyDbf(path2, features.Count); shapefileWriter.Close(); Console.WriteLine("生成成功"); Console.ReadKey(); }
private void getMaxMinAngle(IFeature feature) { IList <ILineString> lines = new List <ILineString>(); Coordinate centroid = feature.Geometry.Centroid.Coordinate; Coordinate origin = new Coordinate(); origin.X = MaxPoints.getMaxVector(feature).Coordinates[1].X - centroid.X; origin.Y = MaxPoints.getMaxVector(feature).Coordinates[1].Y - centroid.Y; //最大点平移到自定义坐标系 for (int i = 5; i <= 361; i += 5) { double angle = getAngle(origin); double k = 0; angle += i; if (angle > 360) //若角大于360,减去360 { angle -= 360; } k = Math.Tan(angle * Math.PI / 180); Coordinate point = new Coordinate(); //判定每隔5度的点落在1.4象限,2,3象限,或者X轴上 if (angle > 90 && angle < 270) { point.X = -100000.0; point.Y = k * point.X; } else if ((angle >= 0 && angle < 90) || (angle > 270 && angle <= 360)) { point.X = 100000.0; point.Y = k * point.X; } else if (angle == 90) { point.X = 0; point.Y = 100000.0; } else if (angle == 270) { point.X = 0; point.Y = -100000.0; } point.X += centroid.X; //将点移动回到原空间投影坐标系 point.Y += centroid.Y; Coordinate[] points = new Coordinate[] { centroid, point }; LineString line = new LineString(points); if (!line.Intersects(feature.Geometry.Boundary)) //如果所得线段与边界不相交,跳出当前循环,进入下个循环 { continue; } IGeometry intersectPoints = line.Intersection(feature.Geometry.Boundary); if (intersectPoints.Coordinates.Length > 1) { if (points[1].X > points[0].X) { line.Coordinates[1] = intersectPoints.Coordinates[intersectPoints.Coordinates.Length - 1]; } else if (points[1].X < points[0].X) { line.Coordinates[1] = intersectPoints.Coordinates[0]; } else if (points[1].X == points[0].X) { if (points[1].Y > points[0].Y) { line.Coordinates[1] = intersectPoints.Coordinates[intersectPoints.Coordinates.Length - 1]; } else if (points[1].Y < points[0].Y) { line.Coordinates[1] = intersectPoints.Coordinates[0]; } } } else { line.Coordinates[1] = intersectPoints.Coordinate; } lines.Add(line); } lines.Add(lines[0]); double titio = 0; for (int i = 0; i < lines.Count - 1; i++) { double b = centroid.Distance(lines[i + 1].Coordinates[1]); double a = centroid.Distance(lines[i].Coordinates[1]); double h = b * Math.Sin(5 * Math.PI / 180); titio = 1 - h / (h + a); Titio.Add(titio); } }