private ShapePolygon ShapePolygonGeoToPrj(ShapePolygon shapePolygon) { if (shapePolygon == null || shapePolygon.IsProjected) { return(null); } GeoDo.RSS.Core.DrawEngine.ICoordinateTransform tran = _canvas.CoordTransform; double prjX; double prjY; int ringLength = shapePolygon.Rings.Length; ShapeRing[] ring = new ShapeRing[ringLength]; int potsLength = 0; for (int i = 0; i < ringLength; i++) { if (shapePolygon.Rings[i].Points == null) { continue; } potsLength = shapePolygon.Rings[i].Points.Length; ShapePoint[] shpPoint = new ShapePoint[potsLength]; for (int j = 0; j < shapePolygon.Rings[i].Points.Length; j++) { tran.Geo2Prj(shapePolygon.Rings[i].Points[j].X, shapePolygon.Rings[i].Points[j].Y, out prjX, out prjY); ShapePoint point = new ShapePoint(prjX, prjY); shpPoint[j] = point; } ring[i] = new ShapeRing(shpPoint); } ShapePolygon prjSp = new ShapePolygon(ring); return(prjSp); }
private ShapePolygon ShapePolygonPrjToGeo(GeoDo.Project.IProjectionTransform transform, ShapePolygon shapePolygon) { if (shapePolygon == null) { return(null); } double prjX; double prjY; int ringLength = shapePolygon.Rings.Length; ShapeRing[] ring = new ShapeRing[ringLength]; int potsLength = 0; for (int i = 0; i < ringLength; i++) { if (shapePolygon.Rings[i].Points == null) { continue; } potsLength = shapePolygon.Rings[i].Points.Length; ShapePoint[] shpPoint = new ShapePoint[potsLength]; for (int j = 0; j < shapePolygon.Rings[i].Points.Length; j++) { //ShapePoint point = new ShapePoint(shapePolygon.Rings[i].Points[j].X, shapePolygon.Rings[i].Points[j].Y); double[] x = new double[] { shapePolygon.Rings[i].Points[j].X }; double[] y = new double[] { shapePolygon.Rings[i].Points[j].Y }; transform.Transform(x, y); shpPoint[j] = new ShapePoint(x[0], y[0]);; } ring[i] = new ShapeRing(shpPoint); } ShapePolygon prjSp = new ShapePolygon(ring); return(prjSp); }
private void TryExportPolygon(Feature[] features, string shpFileName) { EsriShapeFilesWriterII w = new EsriShapeFilesWriterII(shpFileName, enumShapeType.Polygon); w.BeginWrite(); Feature feature = features[0]; string[] fieldNames = feature.FieldNames; Feature[] retFeature = new Feature[features.Length]; for (int i = 0; i < features.Length; i++) { ShapePolygon ply = (features[i].Geometry as ShapePolygon).Clone() as ShapePolygon; ShapeRing[] rings = ply.Rings; ShapeRing[] newRings = new ShapeRing[rings.Length]; for (int j = 0; j < rings.Length; j++) { ShapePoint[] points = rings[j].Points; ShapePoint[] newPoints = new ShapePoint[points.Length]; for (int p = 0; p < points.Length; p++) { double prjx = points[p].X; double prjy = points[p].Y; double geox, geoy; _canvas.CoordTransform.Prj2Geo(prjx, prjy, out geox, out geoy); newPoints[p] = new ShapePoint(geox, geoy); } newRings[j] = new ShapeRing(newPoints); } ShapePolygon newPly = new ShapePolygon(newRings); Feature fet = new Feature(features[i].OID, newPly, fieldNames, features[i].FieldValues, null); retFeature[i] = fet; } w.Write(retFeature); w.EndWriter(); }
private ShapePolygon ShapePolygonGeoToPrj(IProjectionTransform transform, ShapePolygon shapePolygon) { if (shapePolygon == null || shapePolygon.IsProjected) { return(null); } int ringLength = shapePolygon.Rings.Length; ShapeRing[] ring = new ShapeRing[ringLength]; int potsLength = 0; for (int i = 0; i < ringLength; i++) { if (shapePolygon.Rings[i].Points == null) { continue; } potsLength = shapePolygon.Rings[i].Points.Length; ShapePoint[] shpPoint = new ShapePoint[potsLength]; for (int j = 0; j < shapePolygon.Rings[i].Points.Length; j++) { //tran.Geo2Prj(shapePolygon.Rings[i].Points[j].X, shapePolygon.Rings[i].Points[j].Y, out prjX, out prjY);transform //ShapePoint point = new ShapePoint(prjX, prjY); //shpPoint[j] = point; ShapePoint point = shapePolygon.Rings[i].Points[j]; transform.Transform(point); shpPoint[j] = point; } ring[i] = new ShapeRing(shpPoint); } ShapePolygon prjSp = new ShapePolygon(ring); return(prjSp); }
//生成覆盖度矢量 private Feature[] CreateFeature(Envelope env, float xInterval, float yInterval, short[] data, Envelope dataEnv, Size dataSize) { int oid = 0; List <Feature> features = new List <Feature>(); double leftTopX = env.MinX; while (leftTopX < env.MaxX) { double leftTopY = env.MaxY; while (leftTopY > env.MinY) { ShapeRing ring = new ShapeRing( new ShapePoint[] { new ShapePoint(leftTopX, leftTopY), new ShapePoint(leftTopX + xInterval, leftTopY), new ShapePoint(leftTopX + xInterval, leftTopY - yInterval), new ShapePoint(leftTopX, leftTopY - yInterval) } ); ShapePolygon sp = new ShapePolygon(new ShapeRing[] { ring }); int degree = CalcIceDegree(sp, data, dataEnv, dataSize); Feature fet = new Feature(oid++, sp, new string[] { "覆盖度" }, new string[] { degree == 0 ? "" : degree.ToString() }, null); features.Add(fet); leftTopY -= yInterval; } leftTopX += xInterval; } return(features.ToArray()); }
private object DrToEnvelope(IDataReader dr, int idx) { ShapePolygon ply = _adapter.DrToShape(dr, idx) as ShapePolygon; if (ply != null) { ShapeRing ring = ply.Rings[0]; return(new Envelope(ring.Points[0].X, ring.Points[2].Y, ring.Points[1].X, ring.Points[0].Y)); } return(new Envelope()); }
private Feature GetFeature() { ShapePoint[] pts = new ShapePoint[] { new ShapePoint(116, 39), new ShapePoint(117, 39), new ShapePoint(117, 38), new ShapePoint(116, 38) }; ShapeRing ring = new ShapeRing(pts); ShapePolygon ply = new ShapePolygon(new ShapeRing[] { ring }); Feature fet = new Feature(0, ply, null, null, null); return(fet); }
public static CodeCell.AgileMap.Core.Shape ToPolygon(ICanvas canvas, GeometryOfDrawed geometry) { if (canvas == null || geometry == null || geometry.RasterPoints == null || geometry.RasterPoints.Length == 0) { return(null); } int count = geometry.RasterPoints.Length; List <ShapePoint> pts = new List <ShapePoint>(count); double geoX = 0, geoY = 0; for (int i = 0; i < count; i++) { canvas.CoordTransform.Raster2Geo((int)geometry.RasterPoints[i].Y, (int)geometry.RasterPoints[i].X, out geoX, out geoY); pts.Add(new ShapePoint(geoX, geoY)); } ShapeRing ring = new ShapeRing(pts.ToArray()); ShapePolygon ply = new ShapePolygon(new ShapeRing[] { ring }); return(ply); }
private void UpdateBlock(PrjEnvelopeItem[] obj) { if (obj == null || obj.Length == 0) { return; } ShapeRing[] rings = new ShapeRing[obj.Length]; for (int i = 0; i < obj.Length; i++) { PrjEnvelope prjEnv = obj[i].PrjEnvelope; rings[i] = new ShapeRing( new ShapePoint[] { new ShapePoint(prjEnv.LeftTop.X, prjEnv.LeftTop.Y), new ShapePoint(prjEnv.LeftTop.X, prjEnv.RightBottom.Y), new ShapePoint(prjEnv.RightBottom.X, prjEnv.RightBottom.Y), new ShapePoint(prjEnv.RightBottom.X, prjEnv.LeftTop.Y) }); } ShapePolygon sp = new ShapePolygon(rings); _aoiObj.SetGeometry(sp); }