Пример #1
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ZoomToLayerCommand.OnClick implementation
            ILayer layer = (ILayer)m_mapControl.CustomProperty;

            ESRI.ArcGIS.Geometry.IEnvelope tExtent = layer.AreaOfInterest.Envelope;
            tExtent.Expand(1.1, 1.1, true);
            m_mapControl.Extent = tExtent;
        }
Пример #2
0
        public ESRI.ArcGIS.Carto.IMap GetMap(AxPageLayoutControl pageLayoutControl)
        {
            if (_map == null)
            {
                try
                {
                    IMapDocument mapDocu = new MapDocumentClass();
                    mapDocu.Open(GetMxdLoc());
                    _map = mapDocu.Map[0];

                    pageLayoutControl.LoadMxFile(GetMxdLoc());
                    _map = pageLayoutControl.ActiveView.FocusMap;

                    IFeatureLayer incidentsLayer = FindLayer(_map, "灾区位置分布点");
                    incidentsLayer.FeatureClass = this.SiteFeatureClass;

                    IFeatureLayer facilityLayer = FindLayer(_map, "物资贮备分布点");
                    facilityLayer.FeatureClass = this.RepoFeatureClass;

                    incidentsLayer.Name = _incidentClassName;
                    facilityLayer.Name  = _facilityClassName;

                    ILayer networkLayer = _roadNetwork.GetNetworkLayer();
                    _map.AddLayer(networkLayer);
                    _map.MoveLayer(networkLayer, 3);

                    IFeatureLayer resultLayer = FindLayer(_map, "Routes");
                    ESRI.ArcGIS.Geometry.IEnvelope envResult = ((resultLayer as IFeatureLayer).FeatureClass as IGeoDataset).Extent;
                    envResult.Expand(1.2, 1.2, true);

                    (pageLayoutControl.ActiveView.FocusMap as IActiveView).ScreenDisplay.DisplayTransformation
                    .VisibleBounds = envResult;
                    pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex.Message);
                    return(null);
                }
            }
            return(_map);
        }
Пример #3
0
        /// <summary>
        /// Returns all features from a given feature class that have a vertex or endpoint coincident with a given point
        /// </summary>
        /// <param name="point">IPoint to use as the spatial filter</param>
        /// <param name="searchFtClass">IFeatureClass to search in</param>
        /// <param name="linearEndpointsOnly">Flag to use only the endpoints of a line instead of all vertices</param>
        /// <param name="buffer">Search geometry buffer in map units</param>
        /// <returns>List of IFeature</returns>
        public static List <ESRI.ArcGIS.Geodatabase.IFeature> GetFeaturesWithCoincidentVertices(ESRI.ArcGIS.Geometry.IPoint point, ESRI.ArcGIS.Geodatabase.IFeatureClass searchFtClass, bool linearEndpointsOnly, double buffer)
        {
            List <ESRI.ArcGIS.Geodatabase.IFeature> result = new List <ESRI.ArcGIS.Geodatabase.IFeature>();

            using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser())
            {
                ESRI.ArcGIS.Geodatabase.ISpatialFilter filter = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass();
                releaser.ManageLifetime(filter);

                ESRI.ArcGIS.Geometry.IEnvelope filterGeometry = point.Envelope;
                if (0 < buffer)
                {
                    filterGeometry.Expand(buffer, buffer, false);
                }

                filter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects;
                filter.Geometry   = filterGeometry;

                ESRI.ArcGIS.Geodatabase.IFeatureCursor fts = searchFtClass.Search(filter, false);
                releaser.ManageLifetime(fts);

                ESRI.ArcGIS.Geodatabase.IFeature ft = fts.NextFeature();
                while (null != ft)
                {
                    if (searchFtClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
                    {
                        result.Add(ft);
                    }
                    else if (searchFtClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline && linearEndpointsOnly)
                    {
                        ESRI.ArcGIS.Geometry.IPolyline           polyline  = (ESRI.ArcGIS.Geometry.IPolyline)ft.Shape;
                        ESRI.ArcGIS.Geometry.IRelationalOperator fromPoint = polyline.FromPoint as ESRI.ArcGIS.Geometry.IRelationalOperator;
                        ESRI.ArcGIS.Geometry.IRelationalOperator toPoint   = polyline.ToPoint as ESRI.ArcGIS.Geometry.IRelationalOperator;

                        if (fromPoint.Equals(point) || toPoint.Equals(point))
                        {
                            result.Add(ft);
                        }
                    }
                    else
                    {
                        ESRI.ArcGIS.Geometry.IPointCollection pointCollection = ft.Shape as ESRI.ArcGIS.Geometry.IPointCollection;
                        if (null != pointCollection)
                        {
                            for (int i = 0; i < pointCollection.PointCount; i++)
                            {
                                ESRI.ArcGIS.Geometry.IRelationalOperator testPoint = pointCollection.get_Point(i) as ESRI.ArcGIS.Geometry.IRelationalOperator;
                                if (testPoint.Equals(point))
                                {
                                    result.Add(ft);
                                    break;
                                }
                            }
                        }
                    }

                    ft = fts.NextFeature();
                }
            }

            return(result);
        }