Пример #1
0
        /// <summary>
        /// 创建Tin文件
        /// </summary>
        /// <param name="pFeatureClass">要素类</param>
        private void CreateTinFromFeature(IFeatureClass pFeatureClass)
        {
            try
            {
                IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;
                ESRI.ArcGIS.Geometry.IEnvelope pExtent = pGeoDataset.Extent;
                pExtent.SpatialReference = pGeoDataset.SpatialReference;

                //获得高程值
                IFields pFields = pFeatureClass.Fields;
                IField  pHeightField;
                pHeightField = pFields.get_Field(3);

                ITinEdit pTinEdit = new TinClass();
                pTinEdit.InitNew(pExtent);
                object Missing     = Type.Missing;
                object pbUseShapeZ = Missing;
                object pOverWrite  = Missing;

                pTinEdit.AddFromFeatureClass(pFeatureClass, null, pHeightField, null, esriTinSurfaceType.esriTinMassPoint, ref pbUseShapeZ);

                pTinEdit.SaveAs(Application.StartupPath + "\\Convert\\TemTIN\\" + this.Random, ref pOverWrite);
                pTinEdit.StopEditing(false);
                CreateContourData(Application.StartupPath + "\\Convert\\TemTIN");
            }
            catch (Exception)
            {
            }
        }
 public void OnItemClick(int index)
 {
     ESRI.ArcGIS.Carto.ILayer       layer = m_map.get_Layer(index);
     ESRI.ArcGIS.Geometry.IEnvelope env   = layer.AreaOfInterest;
     m_doc.ActiveView.Extent = env;
     m_doc.ActiveView.Refresh();
 }
 protected override void OnClick(Item item)
 {
     ESRI.ArcGIS.Carto.ILayer       layer = item.Tag as ESRI.ArcGIS.Carto.ILayer;
     ESRI.ArcGIS.Geometry.IEnvelope env   = layer.AreaOfInterest;
     ArcMap.Document.ActiveView.Extent = env;
     ArcMap.Document.ActiveView.Refresh();
 }
Пример #4
0
        public ESRI.ArcGIS.Geometry.IEnvelope DrawRectangle(ESRI.ArcGIS.Carto.IActiveView activeView)
        {
            if (activeView == null)
            {
                return(null);
            }
            else
            {
                ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

                // Constant
                screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
                //ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
                //rgbColor.Red = 255;

                //ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                //simpleFillSymbol.Color = color;
                simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;

                ESRI.ArcGIS.Display.ISymbol     symbol     = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
                ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberEnvelopeClass();
                ESRI.ArcGIS.Geometry.IGeometry  geometry   = rubberBand.TrackNew(screenDisplay, symbol);
                screenDisplay.SetSymbol(symbol);
                ESRI.ArcGIS.Geometry.IEnvelope pEnvelope = geometry as ESRI.ArcGIS.Geometry.IEnvelope;
                screenDisplay.DrawRectangle(pEnvelope); // Dynamic Cast
                screenDisplay.FinishDrawing();

                return(pEnvelope);
            }
        }
Пример #5
0
 public XmlEnvelope(ESRI.ArcGIS.Geometry.IEnvelope e)
 {
     XMin = e.XMin;
     XMax = e.XMax;
     YMin = e.YMin;
     YMax = e.YMax;
 }
Пример #6
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;
        }
Пример #7
0
        /// <summary>
        /// OverView地图的红框移动后,宿主地图视图发生改变
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapControl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            ESRI.ArcGIS.Geometry.IPoint centerPoint = new ESRI.ArcGIS.Geometry.PointClass();
            centerPoint.PutCoords(e.mapX, e.mapY);
            ESRI.ArcGIS.Geometry.IEnvelope eleEnvelope = m_Element.Geometry.Envelope;
            eleEnvelope.CenterAt(centerPoint);
            m_Element.Geometry = (ESRI.ArcGIS.Geometry.IGeometry)eleEnvelope;

            this.m_Application.MapControl.Extent = eleEnvelope;
            this.m_Application.MapControl.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics, null, null);
        }
Пример #8
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);
        }
Пример #9
0
        /// <summary>
        /// 验证拓扑
        /// </summary>
        /// <param name="topology">拓扑对象</param>
        /// <param name="envelope">验证范围</param>
        private void ValidateTopology(ITopology topology, ESRI.ArcGIS.Geometry.IEnvelope envelope)
        {
            try
            {
                // Get the dirty area within the provided envelope.
                ESRI.ArcGIS.Geometry.IPolygon           locationPolygon   = new ESRI.ArcGIS.Geometry.PolygonClass();
                ESRI.ArcGIS.Geometry.ISegmentCollection segmentCollection = (ESRI.ArcGIS.Geometry.ISegmentCollection)locationPolygon;
                segmentCollection.SetRectangle(envelope);
                ESRI.ArcGIS.Geometry.IPolygon polygon = topology.get_DirtyArea(locationPolygon);

                // If a dirty area exists, validate the topology.if (!polygon.IsEmpty)
                {
                    // Define the area to validate and validate the topology.
                    ESRI.ArcGIS.Geometry.IEnvelope areaToValidate = polygon.Envelope;
                    ESRI.ArcGIS.Geometry.IEnvelope areaValidated  = topology.ValidateTopology(areaToValidate);
                }
            }
            catch (Exception)
            {
            }
        }
Пример #10
0
        /// <summary>
        /// 创建拓扑
        /// </summary>
        /// <param name="workspaceName">被检查文件的路径名称</param>
        public void CreateTopology(string workspaceName)
        {
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
            IWorkspaceFactory   workspaceFactory  = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
            IWorkspace          workspace         = workspaceFactory.OpenFromFile(Application.StartupPath + @"\Convert\GeoDataBase.gdb", 0);
            IFeatureWorkspace   featureWorkspace  = (IFeatureWorkspace)workspace;
            IFeatureDataset     featureDataset    = featureWorkspace.OpenFeatureDataset("ContourData");
            ITopologyContainer2 topologyContainer = (ITopologyContainer2)featureDataset;
            IFeatureClass       CurrContour       = null;

            try
            {
                CurrContour = featureWorkspace.OpenFeatureClass("CurrContour");
                ITopology topology = topologyContainer.get_TopologyByName("eeee");
                IDataset  fDataset = (IDataset)topology;
                fDataset.Delete();
            }
            catch (Exception)
            {
                // throw;
            }

            if (CurrContour != null)
            {
                IDataset fDataset = (IDataset)CurrContour;

                fDataset.Delete();
            }

            Geoprocessor gp = new Geoprocessor();
            FeatureClassToFeatureClass pFFeatureClassToFeatureClass = new FeatureClassToFeatureClass();

            pFFeatureClassToFeatureClass.in_features = Application.StartupPath + "\\Convert\\ContourResult\\" + workspaceName + "\\Contour.shp";
            pFFeatureClassToFeatureClass.out_path    = Application.StartupPath + "\\Convert\\GeoDataBase.gdb\\ContourData";

            pFFeatureClassToFeatureClass.out_name = "CurrContour";


            IGeoProcessorResult geoProcessorResult = (IGeoProcessorResult)gp.Execute(pFFeatureClassToFeatureClass, null);

            CurrContour = featureWorkspace.OpenFeatureClass("CurrContour");

            ISchemaLock schemaLock = (ISchemaLock)featureDataset;

            try
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

                // Create the topology.

                ITopology topology = topologyContainer.CreateTopology("eeee",
                                                                      topologyContainer.DefaultClusterTolerance, -1, "");

                // Add feature classes and rules to the topology.
                topology.AddClass((IClass)CurrContour, 5, 1, 1, false);

                AddRuleToTopology(topology, esriTopologyRuleType.esriTRTLineNoIntersection,
                                  "must not intersect", CurrContour);

                int ErrorCount = 0;

                // Get an envelope with the topology's extents and validate the topology.
                IGeoDataset geoDataset = (IGeoDataset)topology;
                ESRI.ArcGIS.Geometry.IEnvelope envelope = geoDataset.Extent;
                ValidateTopology(topology, envelope);
                IGeoDataset               geoDS          = topology as IGeoDataset;
                IErrorFeatureContainer    errorContainer = topology as IErrorFeatureContainer;
                IEnumTopologyErrorFeature eErrorFeat;
                eErrorFeat = errorContainer.get_ErrorFeaturesByRuleType(geoDS.SpatialReference,
                                                                        esriTopologyRuleType.esriTRTAreaNoGaps, null, true, false);
                ITopologyErrorFeature topoError;
                topoError = eErrorFeat.Next();
                while (topoError != null)
                {
                    ErrorCount++;
                    topoError = eErrorFeat.Next();
                }
                if (ErrorCount == 0)
                {
                    MessageBox.Show("无拓扑错误!", "Sunz", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("拓扑错误" + "" + ErrorCount + "" + "个!");
                }
            }
            catch (COMException comExc)
            {
                throw new Exception(String.Format(
                                        "Error creating topology: {0} Message: {1}", comExc.ErrorCode,
                                        comExc.Message), comExc);
            }
            finally
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
        }
Пример #11
0
 public IBarrierCollection get_Barriers(ESRI.ArcGIS.Geometry.IEnvelope pExtent)
 {
     throw new NotImplementedException();
 }
Пример #12
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);
        }
Пример #13
0
 /// <summary>
 /// ViewRefreshed Event handler
 /// </summary>
 /// <param name="view"></param>
 /// <param name="phase"></param>
 /// <param name="data"></param>
 /// <param name="envelope"></param>
 /// <remarks></remarks>
 private void OnActiveViewEventsViewRefreshed(ESRI.ArcGIS.Carto.IActiveView view, ESRI.ArcGIS.Carto.esriViewDrawPhase phase, System.Object data, ESRI.ArcGIS.Geometry.IEnvelope envelope)
 {
     // TODO: Add your code here
     // System.Windows.Forms.MessageBox.Show("ViewRefreshed");
 }