Exemplo n.º 1
0
        protected override void OnClick()
        {
            IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document;
            ////IWorkspace pWorkspace
            IFeatureLayer pFeatureLayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0];
            IDataset      pDS           = (IDataset)pFeatureLayer.FeatureClass;

            TowerManager tm      = new TowerManager(pDS.Workspace);
            Towers       pTowers = tm.GetTowers();

            //Tower pTower = tm.GetTowerByID("T04");

            //int towerRange = 100;
            //ITopologicalOperator pTopo = (ITopologicalOperator)pTower.towerLocation;
            //IPolygon range3Bars = (IPolygon)pTopo.Buffer(towerRange / 3);

            //IPolygon range2BarsWhole = (IPolygon)pTopo.Buffer(towerRange * 2 / 3);
            //ITopologicalOperator p2BarTopo = (ITopologicalOperator)range2BarsWhole;
            //IPolygon range2BarsDonut = (IPolygon) p2BarTopo.Difference(range3Bars);

            //IPolygon range1BarWhole = (IPolygon)pTopo.Buffer(towerRange);
            //ITopologicalOperator p1BarTopo = (ITopologicalOperator)range1BarWhole;
            //IPolygon range1BarDonut = (IPolygon)p1BarTopo.Difference(range2BarsWhole);

            //IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDS.Workspace;
            //pWorkspaceEdit.StartEditing(true);
            //pWorkspaceEdit.StartEditOperation();

            //IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit;
            //IFeatureClass pTowerRangeFC = pFWorkspace.OpenFeatureClass("TowerRanges");

            //IFeature pFeature = pTowerRangeFC.CreateFeature();
            //pFeature.set_Value(pFeature.Fields.FindField("TOWERID"),"T04");
            //pFeature.set_Value(pFeature.Fields.FindField("RANGE"), 3);
            //pFeature.Shape = range3Bars;
            //pFeature.Store();

            //IFeature p2BarsFeature = pTowerRangeFC.CreateFeature();
            //p2BarsFeature.set_Value(pFeature.Fields.FindField("TOWERID"), "T04");
            //p2BarsFeature.set_Value(pFeature.Fields.FindField("RANGE"), 2);
            //p2BarsFeature.Shape = range2BarsDonut;
            //p2BarsFeature.Store();

            //IFeature p1BarsFeature = pTowerRangeFC.CreateFeature();
            //p1BarsFeature.set_Value(pFeature.Fields.FindField("TOWERID"), "T04");
            //p1BarsFeature.set_Value(pFeature.Fields.FindField("RANGE"), 1);
            //p1BarsFeature.Shape = range1BarDonut;
            //p1BarsFeature.Store();

            //pWorkspaceEdit.StopEditOperation();
            //pWorkspaceEdit.StopEditing(true);

            tm.GetTowerCoverage(pTowers);
            tm.GenerateDeadArea();
        }
Exemplo n.º 2
0
        public Towers GetTowers()
        {
            IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)_workspace;
            IFeatureClass     pTowersFC         = pFeatureWorkspace.OpenFeatureClass("Towers");

            Towers         pTowers  = new Towers();
            IFeatureCursor pFCursor = pTowersFC.Search(null, false);
            IFeature       pFeature = pFCursor.NextFeature();

            while (pFeature != null)
            {
                pTowers.Items.Add(GetTower(pFeature));
                pFeature = pFCursor.NextFeature();
            }
            // for each feature in pTowersFC, create a Tower object and add to Towers
            return(pTowers);
        }
Exemplo n.º 3
0
        public void GetTowerCoverage(Towers pTowers)
        {
            IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)_workspace;
            IFeatureClass     pRangeFC          = pFeatureWorkspace.OpenFeatureClass("TowerRanges");

            IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)_workspace;

            try
            {
                pWorkspaceEdit.StartEditing(true);
                pWorkspaceEdit.StartEditOperation();

                IFeatureCursor pRangeCursor = pRangeFC.Update(null, false);
                //IFeature pFeature = pRangeCursor.NextFeature();
                while (pRangeCursor.NextFeature() != null)
                {
                    //pFeature.Delete();
                    //pFeature = pRangeCursor.NextFeature();
                    pRangeCursor.DeleteFeature();
                }

                foreach (Tower pTower in pTowers.Items)
                {
                    //Tower pTower = tm.GetTowerByID("T04");

                    double towerRange               = pTower.towerCoverage;
                    ITopologicalOperator pTopo      = (ITopologicalOperator)pTower.towerLocation;
                    IPolygon             range3Bars = (IPolygon)pTopo.Buffer(towerRange / 3);

                    IPolygon             range2BarsWhole = (IPolygon)pTopo.Buffer(towerRange * 2 / 3);
                    ITopologicalOperator p2BarTopo       = (ITopologicalOperator)range2BarsWhole;
                    IPolygon             range2BarsDonut = (IPolygon)p2BarTopo.Difference(range3Bars);

                    IPolygon             range1BarWhole = (IPolygon)pTopo.Buffer(towerRange);
                    ITopologicalOperator p1BarTopo      = (ITopologicalOperator)range1BarWhole;
                    IPolygon             range1BarDonut = (IPolygon)p1BarTopo.Difference(range2BarsWhole);

                    //IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit;
                    //IFeatureClass pTowerRangeFC = pFWorkspace.OpenFeatureClass("TowerRanges");

                    IFeature pFeature = pRangeFC.CreateFeature();
                    pFeature.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID);
                    pFeature.set_Value(pFeature.Fields.FindField("RANGE"), 3);
                    pFeature.Shape = range3Bars;
                    pFeature.Store();

                    IFeature p2BarsFeature = pRangeFC.CreateFeature();
                    p2BarsFeature.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID);
                    p2BarsFeature.set_Value(pFeature.Fields.FindField("RANGE"), 2);
                    p2BarsFeature.Shape = range2BarsDonut;
                    p2BarsFeature.Store();

                    IFeature p1BarsFeature = pRangeFC.CreateFeature();
                    p1BarsFeature.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID);
                    p1BarsFeature.set_Value(pFeature.Fields.FindField("RANGE"), 1);
                    p1BarsFeature.Shape = range1BarDonut;
                    p1BarsFeature.Store();
                }

                pWorkspaceEdit.StopEditOperation();
                pWorkspaceEdit.StopEditing(true);
            }
            catch (Exception ex)
            {
                pWorkspaceEdit.AbortEditOperation();
                MessageBox.Show(ex.ToString());
            }
        }