Ejemplo n.º 1
0
        /// <summary>
        /// 离散Polygon
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="distance"></param>
        private IPolygon DiscretePolygon(IPolygon polygon, double distance)
        {
            string wkt = "PROJCS[\"<Custom Coordinate>\",GEOGCS[\"GCS_Beijing_1954\",DATUM[\"D_Beijing_1954\",SPHEROID[\"Krasovsky_1940\",6378245.0,298.3]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"false_easting\",64685.26],PARAMETER[\"false_northing\",-3267460.1405],PARAMETER[\"central_meridian\",120.0],PARAMETER[\"scale_factor\",1.0],PARAMETER[\"latitude_of_origin\",0.0],UNIT[\"Meter\",1.0]]";
            ICoordinateReferenceSystem tempcrs = crsFactory.CreateFromWKT(wkt);
            IRing    ring       = polygon.ExteriorRing;
            IPolygon resPolygon = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;

            resPolygon.SpatialCRS = crs as ISpatialCRS;
            for (int i = 0; i < ring.PointCount - 1; i++)
            {
                IPoint point1 = ring.GetPoint(i);
                IPoint point2 = ring.GetPoint(i + 1);
                resPolygon.ExteriorRing.AppendPoint(point1);
                point1.Project(tempcrs as ISpatialCRS);
                point2.Project(tempcrs as ISpatialCRS);
                IVector3    p1    = point1.Position;
                IVector3    p2    = point2.Position;
                IEulerAngle angle = this.axRenderControl1.Camera.GetAimingAngles(p1, p2);

                p2.MultiplyByScalar(-1);
                double length = p1.Add(p2).Length;
                for (int j = 0; j < (int)(length / distance); j++)
                {
                    IVector3 tempv3    = this.axRenderControl1.Camera.GetAimingPoint(p1, angle, (distance * (j + 1)));
                    IPoint   tempPoint = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                    tempPoint.Position   = tempv3;
                    tempPoint.SpatialCRS = tempcrs as ISpatialCRS;
                    tempPoint.Project(crs as ISpatialCRS);
                    resPolygon.ExteriorRing.AppendPoint(tempPoint);
                }
            }
            resPolygon.Close();
            return(resPolygon);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 挖洞
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="deep"></param>
        public void DrawTerrainHole(IPolygon polygon, double deep)
        {
            if (polygon == null)
            {
                return;
            }
            IRing ring = polygon.ExteriorRing;

            if (!ring.IsClosed)
            {
                return;
            }
            IPoint   point0      = ring.GetPoint(0);
            double   lowestPoint = this.axRenderControl1.Terrain.GetElevation(point0.X, point0.Y, gviGetElevationType.gviGetElevationFromDatabase);
            IPolygon pBottom     = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;

            pBottom.SpatialCRS = crs as ISpatialCRS;
            for (int i = 0; i < ring.PointCount; i++)
            {
                IPoint point = ring.GetPoint(i);
                point.Z = this.axRenderControl1.Terrain.GetElevation(point.X, point.Y, gviGetElevationType.gviGetElevationFromDatabase);
                if (point.Z < lowestPoint)
                {
                    lowestPoint = point.Z;
                }
                ring.UpdatePoint(i, point);
                point = point.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                pBottom.ExteriorRing.AppendPoint(point);
            }
            //b、计算底面
            lowestPoint -= deep;
            for (int jj = 0; jj < pBottom.ExteriorRing.PointCount; jj++)
            {
                IPoint point1 = pBottom.ExteriorRing.GetPoint(jj);
                point1.Z = lowestPoint;
                pBottom.ExteriorRing.UpdatePoint(jj, point1);
            }
            ICurveSymbol cvSymbol = new CurveSymbol();

            cvSymbol.Color = System.Drawing.Color.Yellow;
            ISurfaceSymbol sfside = new SurfaceSymbol();

            sfside.BoundarySymbol = cvSymbol;
            sfside.Color          = System.Drawing.Color.BurlyWood;
            ISurfaceSymbol sfbottom = new SurfaceSymbol();

            sfbottom.BoundarySymbol = cvSymbol;
            sfbottom.Color          = System.Drawing.Color.Green;
            rpolygon = this.axRenderControl1.ObjectManager.CreateRenderPolygon(pBottom, sfbottom, rootId);
            rpolygon.MaxVisibleDistance = 9999999;

            IMultiPolygon mpolygon = geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon;

            mpolygon.SpatialCRS = crs as ISpatialCRS;
            for (int i = 0; i < ring.PointCount - 1; i++)
            {
                IPolygon pSide = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                pSide.SpatialCRS = crs as ISpatialCRS;
                pSide.ExteriorRing.AppendPoint(polygon.ExteriorRing.GetPoint(i));
                pSide.ExteriorRing.AppendPoint(pBottom.ExteriorRing.GetPoint(i));
                pSide.ExteriorRing.AppendPoint(pBottom.ExteriorRing.GetPoint(i + 1));
                pSide.ExteriorRing.AppendPoint(polygon.ExteriorRing.GetPoint(i + 1));
                pSide.Close();
                mpolygon.AddPolygon(pSide);
                //renderControl.ObjectManager.CreateRenderPolygon(pSide, sfside);
            }
            rmpolygon = this.axRenderControl1.ObjectManager.CreateRenderMultiPolygon(mpolygon, sfside, rootId);
            rmpolygon.MaxVisibleDistance = 99999999;
            hole = this.axRenderControl1.ObjectManager.CreateTerrainHole(polygon, rootId);
            currentRenderGeometry.VisibleMask = gviViewportMask.gviViewNone;
        }