コード例 #1
0
        public static List <int> getSelectedBuildings(LTE.Geometric.Point p, double fromAngle, double toAngle, double radius)
        {
            IPoint centralPoint = GeometryUtilities.ConstructPoint2D(p.X, p.Y);

            double arithmeticToAngle = GeometricUtilities.GetRadians(GeometricUtilities.ConvertGeometricArithmeticAngle(toAngle));
            double angle             = (toAngle - fromAngle + 360) % 360;
            bool   isCCW             = true;

            if (angle > 180)
            {
                angle = 360 - angle;
                isCCW = false;
            }
            else if (angle == 0)
            {
                angle = 360;
            }

            double arcDistance = radius * GeometricUtilities.GetRadians(angle);

            IPoint       fromPoint   = GeometryUtilities.ConstructPoint_AngleDistance(centralPoint, arithmeticToAngle, radius);
            ICircularArc circularArc = GeometryUtilities.ConstructCircularArc(centralPoint, fromPoint, isCCW, arcDistance); //逆时针
            IPoint       toPoint     = circularArc.ToPoint;

            ISegment fromSegment = GeometryUtilities.ConstructLine(centralPoint, fromPoint) as ISegment;
            ISegment toSegment   = GeometryUtilities.ConstructLine(toPoint, centralPoint) as ISegment;

            ISegment[]          segmentArray = new ISegment[] { fromSegment, circularArc as ISegment, toSegment };
            IGeometryCollection polygon      = GeometryUtilities.ConstructPolygon(segmentArray);
            IPolygon            pPolygon     = polygon as IPolygon;

            IGeometry pGeometry = GeometryUtilities.ConvertProjToGeo(pPolygon as IGeometry);

            IFeatureLayer pFeatureLayer = GISMapApplication.Instance.GetLayer(LayerNames.Projecton) as IFeatureLayer;
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

            ISpatialFilter spatialFilter = new SpatialFilterClass();

            spatialFilter.Geometry      = pGeometry;
            spatialFilter.GeometryField = pFeatureClass.ShapeFieldName;
            spatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;

            //Execute the spatialfilter
            IFeatureCursor featureCursor = pFeatureClass.Search(spatialFilter, false);

            IFeature   pFeature = null;
            List <int> bids     = new List <int>();

            while ((pFeature = featureCursor.NextFeature()) != null)
            {
                bids.Add(pFeature.OID);
            }

            return(bids);
        }
コード例 #2
0
        public static void drawSector(LTE.Geometric.Point p, double fromAngle, double toAngle, double radius)
        {
            IPoint centralPoint = GeometryUtilities.ConstructPoint2D(p.X, p.Y);

            double arithmeticToAngle = GeometricUtilities.GetRadians(GeometricUtilities.ConvertGeometricArithmeticAngle(toAngle));

            double angle = (toAngle - fromAngle) % 360;
            bool   isCCW = true;

            if (angle > 180)
            {
                angle = 360 - angle;
                isCCW = false;
            }
            if (angle == 0)
            {
                angle = 360;
            }
            double arcDistance = radius * GeometricUtilities.GetRadians(angle);

            IPoint       fromPoint   = GeometryUtilities.ConstructPoint_AngleDistance(centralPoint, arithmeticToAngle, radius);
            ICircularArc circularArc = GeometryUtilities.ConstructCircularArc(centralPoint, fromPoint, isCCW, arcDistance);
            IPoint       toPoint     = circularArc.ToPoint;

            ISegment fromSegment = GeometryUtilities.ConstructLine(centralPoint, fromPoint) as ISegment;
            ISegment toSegment   = GeometryUtilities.ConstructLine(toPoint, centralPoint) as ISegment;

            ISegment[]          segmentArray = new ISegment[] { fromSegment, circularArc as ISegment, toSegment };
            IGeometryCollection polygon      = GeometryUtilities.ConstructPolygon(segmentArray);

            //画扇形
            IGraphicsContainer3D graphicsContainer3D = GISMapApplication.Instance.GetLayer(LayerNames.Rays) as IGraphicsContainer3D;
            IPolygonElement      polygonElement      = new PolygonElementClass();
            IElement             element             = polygonElement as IElement;

            element.Geometry = polygon as IGeometry;
            graphicsContainer3D.AddElement(element);
        }
コード例 #3
0
        /// <summary>
        /// 获取扇形与地面网格相交的网格中心点
        /// </summary>
        /// <param name="p"></param>
        /// <param name="fromAngle"></param>
        /// <param name="toAngle"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public static List <LTE.Geometric.Point> getSelectedGridsCenterPoints(LTE.Geometric.Point p, double fromAngle, double toAngle, double radius)
        {
            IPoint centralPoint = GeometryUtilities.ConstructPoint2D(p.X, p.Y);

            double arithmeticToAngle = GeometricUtilities.GetRadians(GeometricUtilities.ConvertGeometricArithmeticAngle(toAngle));

            double angle = (toAngle - fromAngle) % 360;
            bool   isCCW = true;

            if (angle > 180)
            {
                angle = 360 - angle;
                isCCW = false;
            }
            if (angle == 0)
            {
                angle = 360;
            }
            double arcDistance = radius * GeometricUtilities.GetRadians(angle);


            IPoint       fromPoint   = GeometryUtilities.ConstructPoint_AngleDistance(centralPoint, arithmeticToAngle, radius);
            ICircularArc circularArc = GeometryUtilities.ConstructCircularArc(centralPoint, fromPoint, isCCW, arcDistance);
            IPoint       toPoint     = circularArc.ToPoint;

            ISegment fromSegment = GeometryUtilities.ConstructLine(centralPoint, fromPoint) as ISegment;
            ISegment toSegment   = GeometryUtilities.ConstructLine(toPoint, centralPoint) as ISegment;

            ISegment[]          segmentArray = new ISegment[] { fromSegment, circularArc as ISegment, toSegment };
            IGeometryCollection polygon      = GeometryUtilities.ConstructPolygon(segmentArray);

            //画扇形
            //IGraphicsContainer3D graphicsContainer3D = GISMapApplication.Instance.GetLayer(LayerNames.Rays) as IGraphicsContainer3D;
            //IPolygonElement polygonElement = new PolygonElementClass();
            //IElement element = polygonElement as IElement;
            //element.Geometry = polygon as IGeometry;
            //graphicsContainer3D.AddElement(element);

            IGeometry pGeometry = GeometryUtilities.ConvertProjToGeo(polygon as IGeometry);
            //地面网格图层是经纬度
            IFeatureLayer groundFeatureLayer = GISMapApplication.Instance.GetLayer(LayerNames.GroundGrids) as IFeatureLayer;
            IFeatureClass groundFeatureClass = groundFeatureLayer.FeatureClass;

            ISpatialFilter spatialFilter = new SpatialFilterClass();

            spatialFilter.Geometry = pGeometry;
            //spatialFilter.Geometry = pPolygon as IGeometry;
            spatialFilter.GeometryField = groundFeatureClass.ShapeFieldName;
            spatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureCursor featureCursor = groundFeatureClass.Search(spatialFilter, false);

            int CenterXIndex = groundFeatureClass.Fields.FindField("CenterX");
            int CenterYIndex = groundFeatureClass.Fields.FindField("CenterY");
            int xindex       = groundFeatureClass.Fields.FindField("GXID");
            int yindex       = groundFeatureClass.Fields.FindField("GYID");

            IFeature pFeature;
            List <LTE.Geometric.Point> centerPoints = new List <LTE.Geometric.Point>();

            while ((pFeature = featureCursor.NextFeature()) != null)
            {
                int    gxid    = (int)pFeature.get_Value(xindex);
                int    gyid    = (int)pFeature.get_Value(yindex);
                double centerX = double.Parse(pFeature.get_Value(CenterXIndex).ToString());
                double centerY = double.Parse(pFeature.get_Value(CenterYIndex).ToString());

                IPoint crossWithGround = GeometryUtilities.ConstructPoint3D(centerX, centerY, 0);
                double lng = crossWithGround.X, lat = crossWithGround.Y;
                crossWithGround = (IPoint)GeometryUtilities.ConvertGeoToProj(crossWithGround as IGeometry);

                centerPoints.Add(new LTE.Geometric.Point(crossWithGround.X, crossWithGround.Y, crossWithGround.Z));
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(groundFeatureLayer);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(groundFeatureClass);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(spatialFilter);
            System.Runtime.InteropServices.Marshal.ReleaseThreadCache();

            return(centerPoints);
        }