public ServiceTerritory(IWorkspace workspace, string name)
        {
            _workspace   = workspace;
            TowerManager = new TowerManager(workspace);
            IFeatureWorkspace pFWorkspace       = (IFeatureWorkspace)workspace;
            IFeatureClass     pServiceTerritory = pFWorkspace.OpenFeatureClass("sde.ServiceTerritory");
            IQueryFilter      pQFilter          = new QueryFilter();

            pQFilter.WhereClause = "NAME='" + name + "'";

            IFeatureCursor pFCursor = pServiceTerritory.Search(pQFilter, false);

            ServiceTerritoryFeature = pFCursor.NextFeature();
        }
        /// <summary>
        /// return all towers in a service terrtory
        /// </summary>
        /// <returns></returns>
        public Towers GetTowers()
        {
            Towers            towers      = new Towers();
            IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)_workspace;
            IFeatureClass     pTowerFC    = pFWorkspace.OpenFeatureClass("sde.Towers");

            IFeatureCursor pFcursor = pTowerFC.Search(null, false);
            IFeature       pFeature = pFcursor.NextFeature();

            while (pFeature != null)
            {
                Tower tower = TowerManager.GetTower(pFeature);
                towers.Items.Add(tower);
                pFeature = pFcursor.NextFeature();
            }

            return(towers);
        }
Exemple #3
0
        protected override void OnMouseUp(MouseEventArgs arg)
        {
            try
            {
                int x = arg.X;
                int y = arg.Y;

                IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document;

                IFeatureLayer pfeaturelayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0];
                IDataset      pDS           = (IDataset)pfeaturelayer.FeatureClass;

                IPoint pPoint = pMxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);


                DeviceManager dm = new DeviceManager(pDS.Workspace);
                dm.AddDevice("D01", pPoint);



                TowerManager tm = new TowerManager(pDS.Workspace);

                //  MessageBox.Show("we have a point");
                Tower t = tm.GetNearestTower(pPoint, 10); //tm.GetTowerByID("T04");

                if (t == null)
                {
                    MessageBox.Show("No towers were found within the area you clicked.");
                    return;
                }
                //IPoint pPoint = pMxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

                MessageBox.Show("Tower id  " + t.ID + Environment.NewLine + "Type " + t.TowerType + Environment.NewLine + "Networkband: " + t.NetworkBand);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #4
0
        protected override void OnClick()
        {
            try
            {
                IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document;

                IFeatureLayer pfeaturelayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0];
                IDataset      pDS           = (IDataset)pfeaturelayer.FeatureClass;
                TowerManager  tm            = new TowerManager(pDS.Workspace);

                Towers towers = tm.GetTowers();
                tm.GenerateTowerCoverage(towers);
                pMxdoc.ActiveView.Refresh();
            }

            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
            //IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document;

            //IFeatureLayer pfeaturelayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0];
            //IDataset pDS = (IDataset)pfeaturelayer.FeatureClass;
            //TowerManager tm = new TowerManager(pDS.Workspace);


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

            //// range of 100 meters
            //int towerRange = 100;
            //ITopologicalOperator pTopo = (ITopologicalOperator)pTower.TowerLocation;
            //IPolygon range3Bars = (IPolygon)pTopo.Buffer(towerRange / 3);

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

            //IPolygon range1BarWhole = (IPolygon)pTopo.Buffer(towerRange);
            //ITopologicalOperator pIntTopo2 = (ITopologicalOperator)range1BarWhole;
            //IPolygon range1BarDonut = (IPolygon)pIntTopo2.SymmetricDifference(range2BarsWhole);

            //// Start editing session to create features
            //IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDS.Workspace;
            //pWorkspaceEdit.StartEditing(true);
            //pWorkspaceEdit.StartEditOperation();

            //// Get feature class to edit
            //IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit;
            //IFeatureClass pTowerRangeFC = pFWorkspace.OpenFeatureClass("TowerRange");

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

            //// Create range 2 bars
            //IFeature pFeature2Bar = pTowerRangeFC.CreateFeature();
            //pFeature2Bar.set_Value(pFeature2Bar.Fields.FindField("TOWERID"), "T04");
            //pFeature2Bar.set_Value(pFeature2Bar.Fields.FindField("RANGE"), 2);
            //pFeature2Bar.Shape = range2BarsDonut;
            //pFeature2Bar.Store();

            //// Create range 1 bar
            //IFeature pFeature1Bar = pTowerRangeFC.CreateFeature();
            //pFeature1Bar.set_Value(pFeature1Bar.Fields.FindField("TOWERID"), "T04");
            //pFeature1Bar.set_Value(pFeature1Bar.Fields.FindField("RANGE"), 1);
            //pFeature1Bar.Shape = range1BarDonut;
            //pFeature1Bar.Store();

            //// End editing session
            //pWorkspaceEdit.StopEditOperation();
            //pWorkspaceEdit.StopEditing(true);
        }