Beispiel #1
0
        private void _AddNetworkForLayer(ILayer layer, List <ComboBoxItem> geometricNetworks)
        {
            IFeatureLayer featureLayer = (IFeatureLayer)layer;
            INetworkClass networkClass = (INetworkClass)featureLayer.FeatureClass;

            try
            {
                IGeometricNetwork network = networkClass.GeometricNetwork;
                bool alreadyAdded         = false;
                foreach (ComboBoxItem element in geometricNetworks)
                {
                    if (element.Value == network)
                    {
                        alreadyAdded = true;
                        break;
                    }
                }
                if (!alreadyAdded)
                {
                    geometricNetworks.Add(new ComboBoxItem()
                    {
                        Name = ((IDataset)network).Name, Value = network
                    });
                }
            }
            finally
            {
                UrbanDelineationExtension.ReleaseComObject(networkClass);
            }
        }
Beispiel #2
0
        private void _CheckLayer(ILayer layer, List <ComboBoxItem> geometricNetworks, List <ComboBoxItem> junctionLayers, List <ComboBoxItem> rasterLayers, List <ComboBoxItem> polygonLayers)
        {
            bool layerUsed = false;

            if (layer is IGroupLayer && layer is ICompositeLayer)
            {
                ICompositeLayer groupLayer = (ICompositeLayer)layer;
                int             layerCount = groupLayer.Count;
                for (int i = 0; i < layerCount; i++)
                {
                    ILayer subLayer = groupLayer.get_Layer(i);
                    _CheckLayer(subLayer, geometricNetworks, junctionLayers, rasterLayers, polygonLayers);
                }
            }
            else if (layer is IFeatureLayer)
            {
                if (((IFeatureLayer)layer).FeatureClass != null)
                {
                    if (((IFeatureLayer)layer).FeatureClass is INetworkClass)
                    {
                        _AddNetworkForLayer(layer, geometricNetworks);

                        INetworkClass networkClass = (INetworkClass)((IFeatureLayer)layer).FeatureClass;
                        if (networkClass.FeatureType == esriFeatureType.esriFTSimpleJunction)
                        {
                            junctionLayers.Add(new ComboBoxItem()
                            {
                                Name = layer.Name, Value = layer
                            });
                            layerUsed = true;
                        }
                    }

                    if (((IFeatureLayer)layer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        polygonLayers.Add(new ComboBoxItem()
                        {
                            Name = layer.Name, Value = layer
                        });
                        layerUsed = true;
                    }
                }
            }
            else if (layer is IRasterLayer && ((IRasterLayer)layer).BandCount == 1)
            {
                if (((IRasterLayer)layer).Raster != null)
                {
                    rasterLayers.Add(new ComboBoxItem()
                    {
                        Name = layer.Name, Value = layer
                    });
                    layerUsed = true;
                }
            }

            if (!layerUsed)
            {
                UrbanDelineationExtension.ReleaseComObject(layer);
            }
        }
        public ZNetworkClass(INetworkClass networkClass)
            : base(networkClass as IFeatureClass)
        {
            // Is Junction?
            this.IsJunction = networkClass.FeatureType == esriFeatureType.esriFTSimpleJunction;

            // Is Edge?
            this.IsEdge = networkClass.FeatureType == esriFeatureType.esriFTSimpleEdge || networkClass.FeatureType == esriFeatureType.esriFTComplexEdge;

            // Is Complex?
            this.IsComplex = networkClass.FeatureType == esriFeatureType.esriFTComplexEdge;

            // Is Source or Sink?
            this.IsSourceSink = networkClass.NetworkAncillaryRole == esriNetworkClassAncillaryRole.esriNCARSourceSink;

            // Is Orphan Junction?
            this.IsOrphanJunctionFeatureClass = networkClass.FeatureClassID == networkClass.GeometricNetwork.OrphanJunctionFeatureClass.FeatureClassID;
        }
Beispiel #4
0
        public void GetSortInfos(ArrayList pSortInfos)
        {
            pSortInfos.Clear();
            IMap         map         = m_context.FocusMap;
            IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection;
            IFeature     feature     = enumFeature.Next();

            if (feature != null)
            {
                do
                {
                    if (feature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                    {
                        IPolyline egLine    = feature.Shape as IPolyline;
                        IPoint    newCenter = new PointClass();
                        egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter);
                        IEdgeFeature  pEgFeature    = feature as IEdgeFeature;
                        IFeatureClass pClass        = feature.Class as IFeatureClass;
                        INetworkClass pNetworkClass = pClass as INetworkClass;
                        INetElements  network       = pNetworkClass.GeometricNetwork.Network as INetElements;
                        IEnumFeature  enumFeatures  = pNetworkClass.GeometricNetwork.SearchForNetworkFeature(newCenter,
                                                                                                             esriFeatureType.esriFTSimpleEdge);

                        IEdgeFeature       edgeFeature     = (IEdgeFeature)enumFeatures.Next();
                        ISimpleEdgeFeature simpedgeFeature = (ISimpleEdgeFeature)edgeFeature;
                        pSortInfos.Add(new SortInfo
                        {
                            SmID    = simpedgeFeature.EID,
                            SmFNode = edgeFeature.FromJunctionEID,
                            SmTNode = edgeFeature.ToJunctionEID
                        });
                    }
                    //IEdgeFeature edgeFeature = (IEdgeFeature) feature;
                    //pSortInfos.Add(new SortInfo
                    //{
                    //    SmID = Convert.ToInt32(feature.get_Value(0).ToString()),
                    //    SmFNode = edgeFeature.FromJunctionEID,
                    //    SmTNode = edgeFeature.ToJunctionEID
                    //});
                    feature = enumFeature.Next();
                } while (feature != null);
            }
        }
Beispiel #5
0
        private void SetBut_Click(object obj, EventArgs eventArgs)
        {
            int selectedIndex = this.NetWorkCombo.SelectedIndex;

            if (selectedIndex >= 0 && this.MapControl != null)
            {
                IFeatureLayer ifeatureLayer_ = ((SetFlowToolForm.Class2) this.NetWorkCombo.SelectedItem).ifeatureLayer_0;
                INetworkClass networkClass   = ifeatureLayer_.FeatureClass as INetworkClass;
                if (networkClass != null)
                {
                    IGeometricNetwork geometricNetwork = networkClass.GeometricNetwork;
                    INetwork          network          = geometricNetwork.Network;
                    IDataset          dataset          = (IDataset)ifeatureLayer_.FeatureClass;
                    IWorkspaceEdit    workspaceEdit    = (IWorkspaceEdit)dataset.Workspace;
                    if (!workspaceEdit.IsBeingEdited())
                    {
                        MessageBox.Show("数据不可编辑");
                    }
                    else
                    {
                        workspaceEdit.StartEditOperation();
                        geometricNetwork.EstablishFlowDirection();
                        if (this.WayCombo.SelectedIndex == 0)
                        {
                            this.method_4(network);
                        }
                        else if (this.WayCombo.SelectedIndex == 1)
                        {
                            this.method_6(geometricNetwork);
                        }
                        else if (this.WayCombo.SelectedIndex == 2)
                        {
                            this.method_5(geometricNetwork);
                        }
                        workspaceEdit.StopEditOperation();
                        MessageBox.Show("操作完成!");
                        base.Close();
                    }
                }
            }
        }
Beispiel #6
0
 public void AddFeatureLayer(IFeatureLayer iFLayer, List <IFeatureLayer> pListLayers)
 {
     try
     {
         if (iFLayer != null)
         {
             IFeatureClass featureClass = iFLayer.FeatureClass;
             if ((featureClass.ShapeType == (esriGeometryType.esriGeometryLine)
                 ? true
                 : featureClass.ShapeType == (esriGeometryType.esriGeometryPolyline)))
             {
                 INetworkClass networkClass = featureClass as INetworkClass;
                 if ((networkClass == null ? false : networkClass.GeometricNetwork != null))
                 {
                     pListLayers.Add(iFLayer);
                 }
             }
         }
     }
     catch (Exception exception)
     {
     }
 }
        //TODO: Implement load and save

        protected override void OnLoad(Stream inStrm)
        {
            SetupOp setupOp = null;

            try
            {
                // NOTE: Do not close or dispose BinaryReader, as this will close the Stream
                BinaryReader reader  = new BinaryReader(inStrm);
                int          version = reader.ReadInt32();

                // NOTE: With change to Add-In architecture, this extension is NOT backwards compatible with versions 1 and 2

                if (version == 3)
                {
                    //// Version 3:
                    //// Item 1: FeatureClassName: The orphan junction feature class of the Geometric Network for the underground conveyance system.
                    //// Item 2: FeatureClassName: The inlet feature class
                    //// Item 3: RasterDatasetName: The DEM dataset
                    //// Item 4: Boolean: Whether to smooth boundaries
                    //// Item 5: Boolean: Whether to include upstream pipe ends
                    //// Item 6: Boolean: Whether to exclude downstream pipe ends
                    //// Item 7: RasterDatasetName: The flow direction dataset
                    //// Item 8: FeatureClassName: The catchment feature class
                    //// Item 9: Boolean: Whether to exclude disabled nodes

                    setupOp = new SetupOp();
                    setupOp.ResultsDirectory = this.MxDocDirectoryName;
                    setupOp.ScratchDirectory = this.TemporaryDirectory;

                    FeatureClassName networkJunctionName = null;
                    PersistenceHelper.Load <FeatureClassName>(inStrm, ref networkJunctionName);
                    INetworkClass junctionClass = _SafeOpen(networkJunctionName) as INetworkClass;
                    if (junctionClass != null)
                    {
                        setupOp.GeometricNetwork = junctionClass.GeometricNetwork;
                    }

                    FeatureClassName inletClassName = null;
                    PersistenceHelper.Load <FeatureClassName>(inStrm, ref inletClassName);
                    setupOp.InletClass = _SafeOpen(inletClassName) as IFeatureClass;

                    RasterDatasetName demName = null;
                    PersistenceHelper.Load <RasterDatasetName>(inStrm, ref demName);
                    IRasterDataset demDataset = _SafeOpen(demName) as IRasterDataset;
                    if (demDataset != null)
                    {
                        setupOp.DEM = demDataset.CreateDefaultRaster();
                    }

                    setupOp.SmoothBoundaries          = reader.ReadBoolean();
                    setupOp.IncludeUpstreamPipeEnds   = reader.ReadBoolean();
                    setupOp.ExcludeDownstreamPipeEnds = reader.ReadBoolean();

                    RasterDatasetName flowDirName = null;
                    PersistenceHelper.Load <RasterDatasetName>(inStrm, ref flowDirName);
                    IRasterDataset flowDirDataset = _SafeOpen(flowDirName) as IRasterDataset;
                    if (flowDirDataset != null)
                    {
                        setupOp.FlowDirection = flowDirDataset.CreateDefaultRaster();
                    }

                    FeatureClassName catchmentClassName = null;
                    PersistenceHelper.Load <FeatureClassName>(inStrm, ref catchmentClassName);
                    setupOp.Catchments = _SafeOpen(catchmentClassName) as IFeatureClass;

                    setupOp.ExcludeDisabledNodes = reader.ReadBoolean();
                }

                _setupOp = setupOp;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.GetType().FullName + ": " + ex.Message);
            }
        }
        private void StartAnalysis(IFeature feature)
        {
            if (feature.FeatureType != esriFeatureType.esriFTSimpleJunction)
            {
                MessageService.Current.Warn("请选择管线点");
                return;
            }
            if (!_pipelineConfig.IsPipelineLayer(feature.Class.AliasName, enumPipelineDataType.Point))
            {
                MessageService.Current.Warn("请选择管线点");
                return;
            }
            double snapDist = CommonUtils.ConvertPixelsToMapUnits(_context.ActiveView,
                                                                  _context.Config.SnapTolerance);
            IBasicLayerInfo lineConfig =
                _plugin.PipeConfig.GetBasicLayerInfo(feature.Class as IFeatureClass) as IBasicLayerInfo;

            if (this._startPoint == null && _startEid == 0)
            {
                //开始记录起始点
                IPipelineLayer oldLayer = _pipelineConfig.GetPipelineLayer(feature.Class.AliasName,
                                                                           enumPipelineDataType.Point);
                if (oldLayer == null)
                {
                    MessageService.Current.Warn("你选择的图层不是合法的管线图层!");
                    return;
                }
                List <IBasicLayerInfo> basicInfos = oldLayer.GetLayers(enumPipelineDataType.Junction);

                IFeatureClass featureClass = basicInfos.Count > 0 ? basicInfos[0].FeatureClass : null;
                if (featureClass == null)
                {
                    MessageService.Current.Warn("管线图层没有构建网络图层!");
                    return;
                }
                INetworkClass networkClass = featureClass as INetworkClass;
                _geometricNetwork = networkClass.GeometricNetwork;
                IPointToEID pnToEid = new PointToEIDClass();
                pnToEid.GeometricNetwork = _geometricNetwork;
                pnToEid.SnapTolerance    = snapDist;
                pnToEid.SourceMap        = _context.FocusMap;
                pnToEid.GetNearestJunction(feature.Shape as IPoint, out _startEid, out _startPoint);
                return;
            }
            IPipelineLayer newLayer = _pipelineConfig.GetPipelineLayer(feature.Class.AliasName,
                                                                       enumPipelineDataType.Point);

            if (newLayer == null)
            {
                MessageService.Current.Warn("你选择的图层不是合法的管线图层!");
                return;
            }
            List <IBasicLayerInfo> basicInfos1 = newLayer.GetLayers(enumPipelineDataType.Junction);

            IFeatureClass featureClass2 = basicInfos1.Count > 0 ? basicInfos1[0].FeatureClass : null;

            if (featureClass2 == null)
            {
                MessageService.Current.Warn("第二个管线图层没有构建网络图层!");
                return;
            }
            INetworkClass networkClass2 = featureClass2 as INetworkClass;

            if (networkClass2.GeometricNetwork != _geometricNetwork)
            {
                if (MessageService.Current.Ask("两个点位属于不同的网络图层,使用第二个网络图层作为分析图层吗?") == false)
                {
                    return;
                }
                _geometricNetwork = networkClass2.GeometricNetwork;
                IPointToEID pnToEid = new PointToEIDClass();
                pnToEid.GeometricNetwork = _geometricNetwork;
                pnToEid.SnapTolerance    = snapDist;
                pnToEid.SourceMap        = _context.FocusMap;
                pnToEid.GetNearestJunction(feature.Shape as IPoint, out _startEid, out _startPoint);
                return;
            }

            try
            {
                IPointToEID pntEid = new PointToEIDClass();
                pntEid.GeometricNetwork = _geometricNetwork;
                pntEid.SourceMap        = _context.FocusMap;
                pntEid.SnapTolerance    = snapDist;

                pntEid.GetNearestJunction(feature.Shape as IPoint, out _endEid, out _endPoint);
                if (_endEid < 1)
                {
                    MessageService.Current.Warn("未能找到第二个分析点!");
                    return;
                }
                if (_startEid == _endEid)
                {
                    MessageService.Current.Warn("起点终点为同一个点!");
                    return;
                }

                INetElements  netElements  = _geometricNetwork.Network as INetElements;
                INetworkClass networkClass = feature.Class as INetworkClass;

                IJunctionFlag[] array   = new JunctionFlag[2];
                INetFlag        netFlag = new JunctionFlag() as INetFlag;

                int userClassID;
                int userID;
                int userSubID;
                netElements.QueryIDs(_endEid, esriElementType.esriETJunction, out userClassID, out userID, out userSubID);
                netFlag.UserClassID = (userClassID);
                netFlag.UserID      = (userID);
                netFlag.UserSubID   = (userSubID);
                IJunctionFlag value = netFlag as IJunctionFlag;
                array.SetValue(value, 0);
                INetFlag netFlag2 = new JunctionFlag() as INetFlag;
                netElements.QueryIDs(_startEid, esriElementType.esriETJunction, out userClassID,
                                     out userID, out userSubID);
                netFlag2.UserClassID = (userClassID);
                netFlag2.UserID      = (userID);
                netFlag2.UserSubID   = (userSubID);
                value = (netFlag2 as IJunctionFlag);
                array.SetValue(value, 1);
                ITraceFlowSolverGEN traceFlowSolverGEN = new TraceFlowSolver() as ITraceFlowSolverGEN;
                INetSolver          netSolver          = traceFlowSolverGEN as INetSolver;
                netSolver.SourceNetwork = _geometricNetwork.Network;
                traceFlowSolverGEN.PutJunctionOrigins(ref array);
                object[]    array2 = new object[1];
                IEnumNetEID enumNetEID;
                IEnumNetEID enumNetEID2;
                traceFlowSolverGEN.FindPath((esriFlowMethod)2, (esriShortestPathObjFn)1, out enumNetEID,
                                            out enumNetEID2, 1, ref array2);
                if (this.ipolyline_0 == null)
                {
                    this.ipolyline_0 = new Polyline() as IPolyline;
                }
                IGeometryCollection geometryCollection = this.ipolyline_0 as IGeometryCollection;
                geometryCollection.RemoveGeometries(0, geometryCollection.GeometryCount);
                if (enumNetEID2.Count <= 0)
                {
                    this.ifeature_0 = null;
                    MessageBox.Show("两点之间不存在路径可以连通!");
                }
                else
                {
                    ShowShortObjectForm showShortObjectForm = new ShowShortObjectForm(_context);
                    showShortObjectForm.pApp = _context;
                    ISpatialReference spatialReference = _context.FocusMap.SpatialReference;
                    IEIDHelper        eIDHelperClass   = new EIDHelper();
                    eIDHelperClass.GeometricNetwork       = (networkClass.GeometricNetwork);
                    eIDHelperClass.OutputSpatialReference = (spatialReference);
                    eIDHelperClass.ReturnGeometries       = (true);
                    eIDHelperClass.ReturnFeatures         = (true);
                    IEnumEIDInfo enumEIDInfo = eIDHelperClass.CreateEnumEIDInfo(enumNetEID2);
                    int          count       = enumEIDInfo.Count;
                    enumEIDInfo.Reset();
                    for (int i = 0; i < count; i++)
                    {
                        IEIDInfo  iEIDInfo = enumEIDInfo.Next();
                        IGeometry geometry = iEIDInfo.Geometry;
                        if (i == 0)
                        {
                            showShortObjectForm.AddPipeName(this.string_0);
                        }
                        showShortObjectForm.AddFeature(iEIDInfo.Feature);
                        geometryCollection.AddGeometryCollection(geometry as IGeometryCollection);
                    }
                    showShortObjectForm.AddShortPath(this.ipolyline_0);
                    showShortObjectForm.AddLenght(this.ipolyline_0.Length);
                    this.ifeature_2 = feature;
                    EsriUtils.ZoomToGeometry(this.ipolyline_0, _context.MapControl.Map, 1.3);
                    FlashUtility.FlashGeometry(this.ipolyline_0, _context.MapControl);
                    this.ifeature_0   = null;
                    _startEid         = 0;
                    _startPoint       = null;
                    _geometricNetwork = null;
                    showShortObjectForm.Show();
                }
            }
            catch (Exception ex)
            {
                this.ifeature_0 = null;
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #9
0
        //!在这儿进行修改,将对高程埋深数据存储在不同位置进行统一处理
        private void method_2()
        {
            IMap         map         = m_context.FocusMap;
            IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection;
            IFeature     feature     = enumFeature.Next();
            bool         isMUsing    = false;
            int          qdgcIndex   = -1;
            int          qdmsIndex   = -1;
            int          zdgcIndex   = -1;
            int          zdmsIndex   = -1;

            if (feature == null)
            {
                return;
            }
            if (feature.FeatureType != esriFeatureType.esriFTSimpleEdge)
            {
                return;
            }

            this.arrayList_1.Clear();
            this.arrayList_2.Clear();
            int num = 0;

            while (feature != null)
            {
                IPolyline egLine    = feature.Shape as IPolyline;
                IPoint    newCenter = new PointClass();
                egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter);
                IEdgeFeature  pEgFeature    = feature as IEdgeFeature;
                IFeatureClass pClass        = feature.Class as IFeatureClass;
                INetworkClass pNetworkClass = pClass as INetworkClass;
                INetElements  network       = pNetworkClass.GeometricNetwork.Network as INetElements;
                IEnumFeature  enumFeatures  = pNetworkClass.GeometricNetwork.SearchForNetworkFeature(newCenter,
                                                                                                     esriFeatureType.esriFTSimpleEdge);

                ISimpleEdgeFeature simpleEdgeFeature = enumFeatures.Next() as ISimpleEdgeFeature;

                IFeature realFeature = null;

                int userClassID, userID, userSubID;

                network.QueryIDs(simpleEdgeFeature.EID, esriElementType.esriETEdge, out userClassID, out userID,
                                 out userSubID);
                if (pClass.FeatureClassID == userClassID)
                {
                    realFeature = pClass.GetFeature(userID);
                }
                else
                {
                    IEnumDataset dses = pNetworkClass.FeatureDataset.Subsets;
                    dses.Reset();
                    IDataset ds = dses.Next();
                    while (ds != null)
                    {
                        if (ds is IFeatureClass)
                        {
                            IFeatureClass pClass2 = ds as IFeatureClass;
                            if (pClass2.FeatureClassID == userClassID)
                            {
                                realFeature = pClass2.GetFeature(userID);
                                break;
                            }
                        }
                    }
                }

                IMAware mAware = realFeature.Shape as IMAware;
                isMUsing = mAware.MAware;
                IFeatureLayer   pLayer     = MapHelper.GetLayerByFeature(map as IBasicMap, realFeature);
                IBasicLayerInfo lineConfig =
                    PipeConfig.GetBasicLayerInfo(realFeature.Class.AliasName) as IBasicLayerInfo;


                if (!isMUsing)
                {
                    qdgcIndex =
                        realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.QDGC));
                    qdmsIndex =
                        realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.QDMS));
                    zdgcIndex =
                        realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.ZDGC));
                    zdmsIndex =
                        realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS));
                }
                PipeLine         pipeLine        = new PipeLine();
                IPolyline        polyline        = (IPolyline)feature.Shape;
                IPointCollection pointCollection = (IPointCollection)polyline;
                int pointCount = pointCollection.PointCount;
                pipeLine.Clear();
                if (isMUsing)
                {
                    for (int i = 0; i < pointCount; i++)
                    {
                        IPoint point = new ESRI.ArcGIS.Geometry.Point();
                        if (((SortInfo)this.arrayList_0[num]).bRightDirection)
                        {
                            point = pointCollection.get_Point(i);
                        }
                        else
                        {
                            point = pointCollection.get_Point(pointCount - i - 1);
                        }

                        if (double.IsNaN(point.M))
                        {
                            pipeLine.PushBack(point.X, point.Y, point.Z, point.Z + 1.0);
                        }
                        else
                        {
                            pipeLine.PushBack(point.X, point.Y, point.Z - point.M, point.Z);
                        }
                    }
                }
                else
                {
                    double height = 0;
                    double qdgc   = GetDoubleValue(realFeature, qdgcIndex, out height);
                    double zdgc   = GetDoubleValue(realFeature, zdgcIndex, out height);
                    double qdms   = GetDoubleValue(realFeature, qdmsIndex, out height);
                    double zdms   = GetDoubleValue(realFeature, zdmsIndex, out height);
                    if (qdms == 0)
                    {
                        qdms = 1;
                    }
                    if (zdms == 0)
                    {
                        zdms = 1;
                    }
                    IPoint startPoint = pointCollection.Point[0];
                    IPoint endPoint   = pointCollection.Point[pointCollection.PointCount - 1];
                    pipeLine.PushBack(startPoint.X, startPoint.Y, qdgc - qdms, qdgc);
                    pipeLine.PushBack(endPoint.X, endPoint.Y, zdgc - zdms, zdgc);
                }
                //string text = "管线性质";
                string text = lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ) == ""
                    ? "管线性质"
                    : lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ);

                int    num2  = realFeature.Fields.FindField(text);
                string text2 = "";
                if (num2 != -1)
                {
                    object obj = realFeature.get_Value(num2);
                    if (obj == null || Convert.IsDBNull(obj))
                    {
                        text2 = "";
                    }
                    else
                    {
                        text2 = obj.ToString();
                    }
                }
                pipeLine.ID          = Convert.ToInt32(realFeature.get_Value(0).ToString());
                pipeLine.DatasetName = text2;
                int num3 = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ));
                pipeLine.Material = num3 == -1 ? "" : realFeature.get_Value(num3).ToString();

                //管径
                num3 = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                string text3 = num3 == -1 ? "" : realFeature.get_Value(num3).ToString();

                //断面尺寸
                num3 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                string text4 = num3 == -1 ? "" : realFeature.get_Value(num3).ToString();

                Color featureColor = CommonUtils.GetFeatureColor(map, realFeature.Class.AliasName, realFeature);
                pipeLine.Red   = (int)featureColor.R;
                pipeLine.Green = (int)featureColor.G;
                pipeLine.Blue  = (int)featureColor.B;
                if (text3 != "")
                {
                    pipeLine.PipeWidthHeight = text3;
                }
                if (text4 != "")
                {
                    pipeLine.PipeWidthHeight = text4;
                }
                if (pipeLine.PipeWidthHeight == null)
                {
                    pipeLine.PipeWidthHeight = "";
                }
                this.arrayList_1.Add(pipeLine);
                IFeature feature2 = (IFeature)((IEdgeFeature)realFeature).FromJunctionFeature;
                IFeature feature3 = (IFeature)((IEdgeFeature)realFeature).ToJunctionFeature;
                IFeature feature4;
                if (num == 0)
                {
                    PipePoint pipePoint = new PipePoint();
                    if (((SortInfo)this.arrayList_0[num]).bRightDirection)
                    {
                        feature4 = feature2;
                    }
                    else
                    {
                        feature4 = feature3;
                    }
                    pipePoint.nID             = Convert.ToInt32(feature4.get_Value(0));
                    pipePoint.nAtPipeSegID    = pipeLine.ID;
                    pipePoint.bstrDatasetName = text2;

                    IBasicLayerInfo pointConfig =
                        PipeConfig.GetBasicLayerInfo(feature4.Class.AliasName) as IBasicLayerInfo;
                    num3 = feature4.Fields.FindField(pointConfig.GetFieldName(PipeConfigWordHelper.PointWords.FSW));
                    if (num3 == -1)
                    {
                        pipePoint.bstrPointKind = "";
                    }
                    else
                    {
                        pipePoint.bstrPointKind = feature4.get_Value(num3).ToString();
                    }
                    Color featureColor2 = CommonUtils.GetFeatureColor(map, feature4.Class.AliasName, feature4);
                    pipePoint.Red   = (int)featureColor2.R;
                    pipePoint.Green = (int)featureColor2.G;
                    pipePoint.Blue  = (int)featureColor2.B;
                    this.arrayList_2.Add(pipePoint);
                }
                PipePoint pipePoint2 = new PipePoint();
                if (((SortInfo)this.arrayList_0[num]).bRightDirection)
                {
                    feature4 = feature3;
                }
                else
                {
                    feature4 = feature2;
                }
                pipePoint2.nID             = Convert.ToInt32(feature4.get_Value(0));
                pipePoint2.nAtPipeSegID    = pipeLine.ID;
                pipePoint2.bstrDatasetName = text2;
                IBasicLayerInfo pointConfig3 =
                    PipeConfig.GetBasicLayerInfo(feature4.Class.AliasName) as IBasicLayerInfo;
                num3 = feature4.Fields.FindField(pointConfig3.GetFieldName(PipeConfigWordHelper.PointWords.FSW));
                if (num3 == -1)
                {
                    pipePoint2.bstrPointKind = "";
                }
                else
                {
                    pipePoint2.bstrPointKind = feature4.get_Value(num3).ToString();
                }
                Color featureColor3 = CommonUtils.GetFeatureColor(map, feature4.Class.AliasName, feature4);
                pipePoint2.Red   = (int)featureColor3.R;
                pipePoint2.Green = (int)featureColor3.G;
                pipePoint2.Blue  = (int)featureColor3.B;
                this.arrayList_2.Add(pipePoint2);
                feature = enumFeature.Next();
                num++;
            }
            this.method_3(this.arrayList_2, this.arrayList_1);
            this.method_4(this.arrayList_3, this.arrayList_1);
            this.method_5(this.arrayList_4, this.arrayList_2);
            this.method_6();
            this.method_7(this.arrayList_3);
        }
Beispiel #10
0
        public bool loadDialog()
        {
            IMxDocument       mxdoc    = null;
            ILayer            layer    = null;
            IFeatureLayer     fLayer   = null;
            IFeatureClass     fc       = null;
            IFeatureSelection fSel     = null;
            INetworkClass     netFC    = null;
            IEnumIDs          pEnumIDs = null;

            try
            {
                lstMergeFeatures.Items.Clear();
                mxdoc = _app.Document as IMxDocument;
                layer = mxdoc.SelectedLayer as ILayer;
                if (layer == null)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("TOC_6") + Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("TOC_5"));
                    return(false);
                }

                //Verify that it is a feature layer
                fLayer = layer as IFeatureLayer;
                if (fLayer == null)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("TOC_1"));
                    return(false);
                }

                //Get the Feature layer and feature class

                fc   = fLayer.FeatureClass;
                fSel = fLayer as IFeatureSelection;

                //Verify that it is a line layer
                if (fc.ShapeType != esriGeometryType.esriGeometryPolyline)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("TOC_2"));
                    return(false);
                }
                //Verify that the layer is part of a geometric network if using the establish flow by AnicillaryRole
                //IGeometricNetwork gnet = default(IGeometricNetwork);
                //IUtilityNetwork unet = default(IUtilityNetwork);
                //INetElements netelems = default(INetElements);

                netFC = fc as INetworkClass;
                if (netFC == null)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("TOC_3"));
                    return(false);
                }


                //IEnumFeature pEnumFeature;
                //IFeature pFeature;

                pEnumIDs = fSel.SelectionSet.IDs;


                //pEnumFeature = m_editor.EditSelection;
                //pEnumFeature.Reset();

                m_colFeatures = new Hashtable();
                int pFeatID = pEnumIDs.Next();
                while (pFeatID != -1)
                {
                    m_colFeatures.Add(pFeatID.ToString(), fc.GetFeature(pFeatID));
                    lstMergeFeatures.Items.Add(pFeatID.ToString());
                    pFeatID = pEnumIDs.Next();
                }
                //pFeature = pEnumFeature.Next();
                //while (pFeature != null)
                //{
                //    if (pFeature.Class.CLSID.Value.ToString() == fc.CLSID.Value.ToString())
                //    {
                //        m_colFeatures.Add(pFeature.OID.ToString(), pFeature);
                //        lstMergeFeatures.Items.Add(pFeature.OID.ToString());

                //    }

                //    pFeature = pEnumFeature.Next();

                //}
                if (m_colFeatures.Count == 0)
                {
                    return(false);
                }
                if (m_colFeatures.Count == 1)
                {
                    return(false);
                }

                m_FeatLay = fLayer;
                if (m_Config[0].MergeSplitElev.ToUpper() == "TRUE")
                {
                    chkMergeElevationData.Checked = true;
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorOn") + A4LGSharedFunctions.Localizer.GetString("MergeOprt_1") + "\r\n" + ex.ToString());
                return(false);
            }
            finally
            {
                mxdoc    = null;
                layer    = null;
                fLayer   = null;
                fc       = null;
                fSel     = null;
                netFC    = null;
                pEnumIDs = null;
            }
        }
Beispiel #11
0
        private void SetButton_Click(object obj, EventArgs eventArgs)
        {
            int count  = this.listJunctionFlag.Count;
            int count2 = this.listEdgeFlag.Count;
            int count3 = this.listJunctionBarrier.Count;
            int count4 = this.listEdgeBarrier.Count;

            if (count < 1 && count2 < 1)
            {
                MessageBox.Show("请用户选择要分析的点或线!");
            }
            else
            {
                IEdgeFlag[]     array        = new EdgeFlag[count2];
                IJunctionFlag[] array2       = new JunctionFlag[count];
                INetwork        network      = null;
                INetworkClass   networkClass = null;
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        IFeature feature = this.listJunctionFlag[i];
                        networkClass = (feature.Class as INetworkClass);
                        network      = networkClass.GeometricNetwork.Network;
                        INetElements           netElements           = network as INetElements;
                        INetFlag               netFlag               = new JunctionFlag() as INetFlag;
                        ISimpleJunctionFeature simpleJunctionFeature = feature as ISimpleJunctionFeature;
                        int userClassID;
                        int userID;
                        int userSubID;
                        netElements.QueryIDs(simpleJunctionFeature.EID, (esriElementType)1, out userClassID, out userID,
                                             out userSubID);
                        netFlag.UserClassID = (userClassID);
                        netFlag.UserID      = (userID);
                        netFlag.UserSubID   = (userSubID);
                        IJunctionFlag junctionFlag = netFlag as IJunctionFlag;
                        array2[i] = junctionFlag;
                    }
                }
                if (count2 > 0)
                {
                    for (int j = 0; j < count2; j++)
                    {
                        IFeature feature2 = this.listEdgeFlag[j];
                        networkClass = (feature2.Class as INetworkClass);
                        network      = networkClass.GeometricNetwork.Network;
                        INetElements       netElements2      = network as INetElements;
                        INetFlag           netFlag2          = new EdgeFlag() as INetFlag;
                        ISimpleEdgeFeature simpleEdgeFeature = feature2 as ISimpleEdgeFeature;
                        int userClassID2;
                        int userID2;
                        int userSubID2;
                        netElements2.QueryIDs(simpleEdgeFeature.EID, (esriElementType)2, out userClassID2, out userID2,
                                              out userSubID2);
                        netFlag2.UserClassID = (userClassID2);
                        netFlag2.UserID      = (userID2);
                        netFlag2.UserSubID   = (userSubID2);
                        IEdgeFlag edgeFlag = netFlag2 as IEdgeFlag;
                        array[j] = edgeFlag;
                    }
                }
                ITraceFlowSolverGEN    traceFlowSolverGEN    = new TraceFlowSolver() as ITraceFlowSolverGEN;
                INetSolver             netSolver             = traceFlowSolverGEN as INetSolver;
                INetElementBarriersGEN netElementBarriersGEN = new NetElementBarriers();
                netElementBarriersGEN.Network     = (network);
                netElementBarriersGEN.ElementType = (esriElementType)(1);
                int[] array3 = new int[count3];
                int   num    = 0;
                if (count3 > 0)
                {
                    for (int k = 0; k < count3; k++)
                    {
                        IFeature feature3 = this.listJunctionBarrier[k];
                        networkClass = (feature3.Class as INetworkClass);
                        network      = networkClass.GeometricNetwork.Network;
                        INetElements netElements3 = network as INetElements;
                        new EdgeFlag();
                        ISimpleJunctionFeature simpleJunctionFeature2 = feature3 as ISimpleJunctionFeature;
                        int num2;
                        int num3;
                        netElements3.QueryIDs(simpleJunctionFeature2.EID, (esriElementType)1, out num, out num2,
                                              out num3);
                        array3[k] = num2;
                    }
                    netElementBarriersGEN.SetBarriers(num, ref array3);
                    netSolver.set_ElementBarriers((esriElementType)1, (INetElementBarriers)netElementBarriersGEN);
                }
                INetElementBarriersGEN netElementBarriersGEN2 = new NetElementBarriers();
                netElementBarriersGEN2.Network     = (network);
                netElementBarriersGEN2.ElementType = (esriElementType)(2);
                int[] array4 = new int[count4];
                if (count4 > 0)
                {
                    for (int l = 0; l < count4; l++)
                    {
                        IFeature feature4 = this.listEdgeBarrier[l];
                        networkClass = (feature4.Class as INetworkClass);
                        network      = networkClass.GeometricNetwork.Network;
                        INetElements netElements4 = network as INetElements;
                        new EdgeFlag();
                        ISimpleEdgeFeature simpleEdgeFeature2 = feature4 as ISimpleEdgeFeature;
                        int num4;
                        int num5;
                        netElements4.QueryIDs(simpleEdgeFeature2.EID, (esriElementType)2, out num, out num4, out num5);
                        array4[l] = num4;
                    }
                    netElementBarriersGEN2.SetBarriers(num, ref array4);
                    netSolver.set_ElementBarriers((esriElementType)2, (INetElementBarriers)netElementBarriersGEN2);
                }
                netSolver.SourceNetwork = (network);
                if (count > 0)
                {
                    traceFlowSolverGEN.PutJunctionOrigins(ref array2);
                }
                if (count2 > 0)
                {
                    traceFlowSolverGEN.PutEdgeOrigins(ref array);
                }
                IEnumNetEID enumNetEID  = null;
                IEnumNetEID enumNetEID2 = null;
                object[]    array5      = new object[1];
                if (this.WayCom.SelectedIndex == 0)
                {
                    traceFlowSolverGEN.FindSource(0, (esriShortestPathObjFn)1, out enumNetEID, out enumNetEID2,
                                                  count + count2, ref array5);
                }
                if (this.WayCom.SelectedIndex == 1)
                {
                    traceFlowSolverGEN.FindSource((esriFlowMethod)1, (esriShortestPathObjFn)1, out enumNetEID,
                                                  out enumNetEID2, count + count2, ref array5);
                }
                IPolyline           polyline           = new Polyline() as IPolyline;
                IGeometryCollection geometryCollection = polyline as IGeometryCollection;
                ISpatialReference   spatialReference   = this.m_iApp.FocusMap.SpatialReference;
                IEIDHelper          iEIDHelper         = new EIDHelper();
                iEIDHelper.GeometricNetwork       = (networkClass.GeometricNetwork);
                iEIDHelper.OutputSpatialReference = (spatialReference);
                iEIDHelper.ReturnGeometries       = (true);
                iEIDHelper.ReturnFeatures         = (true);
                int selectedIndex = this.LayerCom.SelectedIndex;
                if (selectedIndex >= 0 && this.MapControl != null)
                {
                    this.LayerCom.SelectedItem.ToString();
                    IFeatureLayer ifeatureLayer_ = ((TrackingAnalyForm.LayerInfo) this.LayerCom.SelectedItem)._layer;
                    if (ifeatureLayer_ != null)
                    {
                        IFeatureSelection featureSelection = (IFeatureSelection)ifeatureLayer_;
                        featureSelection.Clear();
                        if (enumNetEID2 != null)
                        {
                            IEnumEIDInfo enumEIDInfo = iEIDHelper.CreateEnumEIDInfo(enumNetEID2);
                            int          count5      = enumEIDInfo.Count;
                            enumEIDInfo.Reset();
                            for (int m = 0; m < count5; m++)
                            {
                                IEIDInfo iEIDInfo = enumEIDInfo.Next();
                                featureSelection.Add(iEIDInfo.Feature);
                                IGeometry geometry = iEIDInfo.Geometry;
                                geometryCollection.AddGeometryCollection(geometry as IGeometryCollection);
                            }
                        }
                        featureSelection.SelectionSet.Refresh();
                        IActiveView activeView = this.m_iApp.ActiveView;
                        activeView.Refresh();
                        CMapOperator.ShowFeatureWithWink(this.m_iApp.ActiveView.ScreenDisplay, polyline);
                    }
                }
            }
        }
        public override void OnMouseDown(int button, int Shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }

            this.SelectByClick(x, y);
            IMap         map         = _context.FocusMap;
            IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection;
            IFeature     feature     = enumFeature.Next();

            if (feature == null)
            {
                if (Shift == 1)
                {
                    this.m_SectionControl.RebuildSelection();
                }
                else
                {
                    this.m_SectionControl.LayerName = "";
                    this.m_SectionControl.Clear();
                    this._context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, _context.ActiveView.Extent);
                }
            }
            else
            {
                string aliasName = feature.Class.AliasName;
                int    oID;
                if (feature.HasOID)
                {
                    oID = feature.OID;
                }
                else
                {
                    if (feature.FeatureType == esriFeatureType.esriFTSimpleEdge ||
                        feature.FeatureType == esriFeatureType.esriFTComplexEdge)
                    {
                        IPolyline egLine    = feature.Shape as IPolyline;
                        IPoint    newCenter = new PointClass();
                        egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter);
                        IEdgeFeature  pEgFeature    = feature as IEdgeFeature;
                        IFeatureClass pClass        = feature.Class as IFeatureClass;
                        INetworkClass pNetworkClass = pClass as INetworkClass;
                        INetElements  network       = pNetworkClass.GeometricNetwork.Network as INetElements;
                        IPointToEID   pntEID        = new PointToEIDClass();
                        pntEID.GeometricNetwork = pNetworkClass.GeometricNetwork;
                        pntEID.SourceMap        = _context.FocusMap;
                        pntEID.SnapTolerance    = CommonHelper.ConvertPixelsToMapUnits(_context.ActiveView, 5.0);
                        double percent;
                        int    edgeID;
                        IPoint location;
                        pntEID.GetNearestEdge(newCenter, out edgeID, out location, out percent);
                        if (percent == 0)
                        {
                            return;
                        }

                        int userClassID, userID, userSubID;

                        network.QueryIDs(edgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID);
                        if (pClass.FeatureClassID == userClassID)
                        {
                            feature = pClass.GetFeature(userID);
                        }
                        else
                        {
                            IEnumDataset dses = pNetworkClass.FeatureDataset.Subsets;
                            dses.Reset();
                            IDataset ds = dses.Next();
                            while (ds != null)
                            {
                                if (ds is IFeatureClass)
                                {
                                    IFeatureClass pClass2 = ds as IFeatureClass;
                                    if (pClass2.FeatureClassID == userClassID)
                                    {
                                        feature = pClass2.GetFeature(userID);
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    oID = feature.OID;
                }
                if (Shift != 1)
                {
                    this.m_SectionControl.Clear();
                    this.m_SectionControl.LayerName = aliasName;
                    this.m_SectionControl.Add(oID);
                }
                else if (this.m_SectionControl.Count == 0)
                {
                    this.m_SectionControl.LayerName = aliasName;
                    this.m_SectionControl.Add(oID);
                }
                else if (this.m_SectionControl.IsInSameLayer(aliasName))
                {
                    this.m_SectionControl.LayerName = aliasName;
                    this.m_SectionControl.Add(oID);
                }
            }
        }
Beispiel #13
0
        public override void GetSelectedData()
        {
            this.method_3();
            IMap map = this.m_context.FocusMap;
            ITopologicalOperator topologicalOperator = (ITopologicalOperator)this.m_pBaseLine;
            IGeometry            geometry            = topologicalOperator.Buffer(0.0);

            map.ClearSelection();
            ISelectionEnvironment selectionEnvironment = new SelectionEnvironment();

            map.SelectByShape(geometry, selectionEnvironment, false);
            IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection;
            IFeature     feature     = enumFeature.Next();

            while (feature != null)
            {
                if (feature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                {
                    IPolyline egLine    = feature.Shape as IPolyline;
                    IPoint    newCenter = new PointClass();
                    egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter);

                    IEdgeFeature pEgFeature = feature as IEdgeFeature;


                    IFeatureClass pClass        = feature.Class as IFeatureClass;
                    INetworkClass pNetworkClass = pClass as INetworkClass;
                    INetElements  network       = pNetworkClass.GeometricNetwork.Network as INetElements;
                    IPointToEID   pntEID        = new PointToEIDClass();
                    pntEID.GeometricNetwork = pNetworkClass.GeometricNetwork;
                    pntEID.SourceMap        = m_context.FocusMap;
                    pntEID.SnapTolerance    = CommonHelper.ConvertPixelsToMapUnits(m_context.ActiveView, 5.0);
                    double percent;
                    int    edgeID;
                    IPoint location;
                    pntEID.GetNearestEdge(newCenter, out edgeID, out location, out percent);
                    if (percent == 0)
                    {
                        feature = enumFeature.Next();
                        continue;
                    }

                    int userClassID, userID, userSubID;

                    network.QueryIDs(edgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID);
                    if (pClass.FeatureClassID == userClassID)
                    {
                        feature = pClass.GetFeature(userID);
                    }
                    else
                    {
                        IEnumDataset dses = pNetworkClass.FeatureDataset.Subsets;
                        dses.Reset();
                        IDataset ds = dses.Next();
                        while (ds != null)
                        {
                            if (ds is IFeatureClass)
                            {
                                IFeatureClass pClass2 = ds as IFeatureClass;
                                if (pClass2.FeatureClassID == userClassID)
                                {
                                    feature = pClass2.GetFeature(userID);
                                    break;
                                }
                            }
                        }
                    }
                }
                string  smpClassName = CommonUtils.GetSmpClassName(feature.Class.AliasName);
                IMAware mWAware      = feature.Shape as IMAware;
                bool    isMUsing     = mWAware.MAware;

                IBasicLayerInfo lineConfig = PipeConfig.GetBasicLayerInfo(feature.Class.AliasName) as IBasicLayerInfo;
                if (lineConfig == null && !smpClassName.ToUpper().Contains("JT_JT_L") &&
                    !smpClassName.ToUpper().Contains("SY_ZX_L") && !smpClassName.ToUpper().Contains("ZB_LD_R"))
                {
                    feature = enumFeature.Next();
                }
                else
                {
                    IGeometry shape = feature.Shape;
                    if (shape.GeometryType != esriGeometryType.esriGeometryPolyline &&
                        shape.GeometryType != esriGeometryType.esriGeometryPolygon)
                    {
                        feature = enumFeature.Next();
                    }
                    else
                    {
                        IPolyline polyline;
                        if (shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                        {
                            polyline = this.PolygonToPolyline((IPolygon)shape);
                        }
                        else
                        {
                            polyline = (IPolyline)shape;
                        }
                        GPoints gPoints = null;
                        if (isMUsing)
                        {
                            gPoints = this.CalculateIntersections(this.m_pBaseLine, polyline);
                        }
                        else
                        {
                            gPoints = this.CalculateIntersections(this.m_pBaseLine, feature, lineConfig);
                        }

                        //string text = "管线性质";
                        string text            = lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ);
                        string bstrDatasetName = "";
                        int    num             = feature.Fields.FindField(text);
                        if (num != -1)
                        {
                            object obj = feature.get_Value(num);
                            if (obj == null || Convert.IsDBNull(obj))
                            {
                                bstrDatasetName = "";
                            }
                            else
                            {
                                bstrDatasetName = obj.ToString();
                            }
                        }
                        if (gPoints == null)
                        {
                            feature = enumFeature.Next();
                        }
                        else
                        {
                            int num2 = gPoints.Size();
                            for (int i = 0; i < num2; i++)
                            {
                                GPoint gPoint = gPoints[i];

                                PipePoint pipePoint = new PipePoint();
                                if (smpClassName.ToUpper().Contains("JT_JT_L"))
                                {
                                    pipePoint.PointType = PipePoint.SectionPointType.sptRoadBorder;
                                }
                                else if (smpClassName.ToUpper().Contains("SY_ZX_L"))
                                {
                                    pipePoint.PointType = PipePoint.SectionPointType.sptMidRoadLine;
                                }
                                else if (smpClassName.ToUpper().Contains("ZB_LD_R"))
                                {
                                    pipePoint.PointType = PipePoint.SectionPointType.sptMidGreen;
                                }
                                else
                                {
                                    pipePoint.PointType = PipePoint.SectionPointType.sptPipe;
                                }
                                pipePoint.x = gPoint.X;
                                pipePoint.y = gPoint.Y;
                                pipePoint.z = gPoint.Z;
                                pipePoint.m = gPoint.M;
                                pipePoint.bstrDatasetName = bstrDatasetName;
                                //  int num3 = feature.Fields.FindField(base.PipeConfig.get_Material());
                                int num3 =
                                    feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ));
                                if (num3 == -1)
                                {
                                    pipePoint.strMaterial = "";
                                }
                                else
                                {
                                    object obj2 = feature.get_Value(num3);
                                    if (obj2 != null)
                                    {
                                        pipePoint.strMaterial = feature.get_Value(num3).ToString();
                                    }
                                    else
                                    {
                                        pipePoint.strMaterial = "";
                                    }
                                }
                                // num3 = feature.Fields.FindField(base.PipeConfig.get_Diameter());
                                num3 =
                                    feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                                string text2;
                                if (num3 != -1 && feature.get_Value(num3) != null)
                                {
                                    text2 = feature.get_Value(num3).ToString();
                                }
                                else
                                {
                                    text2 = "";
                                }
                                num3 =
                                    feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                                string text3;
                                if (num3 != -1 && feature.get_Value(num3) != null)
                                {
                                    text3 = feature.get_Value(num3).ToString();
                                }
                                else
                                {
                                    text3 = "";
                                }
                                if (text2 != "")
                                {
                                    pipePoint.strPipeWidthHeight = text2;
                                }
                                if (text3 != "")
                                {
                                    pipePoint.strPipeWidthHeight = text3;
                                }
                                Color featureColor = CommonUtils.GetFeatureColor(map, feature.Class.AliasName, feature);
                                pipePoint.Red   = (int)featureColor.R;
                                pipePoint.Green = (int)featureColor.G;
                                pipePoint.Blue  = (int)featureColor.B;
                                this.m_arrPipePoints.Add(pipePoint);
                            }
                            feature = enumFeature.Next();
                        }
                    }
                }
            }
            map.ClearSelection();
            IPointCollection pointCollection = (IPointCollection)this.m_pBaseLine;
            int pointCount = pointCollection.PointCount;

            if (pointCount != 0)
            {
                for (int j = 0; j < pointCount; j++)
                {
                    IPoint    point      = pointCollection.get_Point(j);
                    double    x          = point.X;
                    double    y          = point.Y;
                    PipePoint pipePoint2 = new PipePoint();
                    pipePoint2.x         = x;
                    pipePoint2.y         = y;
                    pipePoint2.PointType = PipePoint.SectionPointType.sptDrawPoint;
                    this.m_arrPipePoints.Add(pipePoint2);
                }
                this.fEswZsmwIx((PipePoint)this.m_arrPipePoints[this.m_arrPipePoints.Count - 2]);
                this.method_1();
                if (this.method_2())
                {
                    this.method_5(this.m_arrPipePointsDraw, this.m_arrPipePoints);
                    this.method_4();
                    this.method_7(this.m_arrPipePointsDraw);
                }
            }
        }
        private string CreateSchLayers(IEnumLayer pLayers)
        {
            if (pLayers == null)
            {
                return("");
            }
            ILayer        pLayer = pLayers.Next();
            IFeatureLayer featureLayer;
            IFeatureClass featureClass;
            string        pStrLayerNames = "";
            IDataset      pDataset;

            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            System.Windows.Forms.Cursor.Show();

            m_pSDS.DesignMode = true;
            m_pSDI            = (ESRI.ArcGIS.Schematic.ISchematicDatasetImport)m_pSDS;

            Dictionary <string, IFeatureClass> myDictionary = new Dictionary <string, IFeatureClass>();
            IGeometricNetwork gn = null;

            do
            {
                featureLayer = (IFeatureLayer)pLayer;
                featureClass = featureLayer.FeatureClass;
                pDataset     = (IDataset)featureClass;

                if (featureClass.FeatureType == esriFeatureType.esriFTSimpleJunction || featureClass.FeatureType == esriFeatureType.esriFTSimpleEdge || featureClass.FeatureType == esriFeatureType.esriFTComplexEdge || featureClass.FeatureType == esriFeatureType.esriFTComplexJunction)
                {
                    //The FeatureType property of feature classes that implement this interface will be esriFTSimpleJunction, esriDTSimpleEdge, esriFTComplexJunction, or esriFTComplexEdge.
                    INetworkClass networkClass = (INetworkClass)featureLayer.FeatureClass;

                    if (networkClass.GeometricNetwork != null)
                    {
                        //we have a network class
                        if ((gn == null) || (gn != networkClass.GeometricNetwork))
                        {
                            //need to process all the classes
                            Dictionary <string, IFeatureClass> localDictionary = new Dictionary <string, IFeatureClass>();
                            gn = networkClass.GeometricNetwork;
                            IEnumFeatureClass fcComplexEdge = networkClass.GeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
                            IEnumFeatureClass fcComplexNode = networkClass.GeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
                            IEnumFeatureClass fcSimpleEdge  = networkClass.GeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
                            IEnumFeatureClass fcSimpleNode  = networkClass.GeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
                            localDictionary = ProcessFCs(fcComplexEdge, fcComplexNode, fcSimpleEdge, fcSimpleNode);
                            if (myDictionary.Count == 0)                              //just copy it
                            {
                                myDictionary = localDictionary;
                            }
                            else                             //merge
                            {
                                Dictionary <string, IFeatureClass> .KeyCollection keyColl = localDictionary.Keys;

                                foreach (string s in keyColl)
                                {
                                    IFeatureClass fc;
                                    bool          bln = localDictionary.TryGetValue(s, out fc);
                                    myDictionary.Add(s, fc);
                                }
                            }
                        }
                        //Build up the string that will go to the select items to reduce form
                        pStrLayerNames += pDataset.Name.ToString();
                        pStrLayerNames += ";";

                        //Build up the string for just the node feature classes
                        if (featureClass.FeatureType == esriFeatureType.esriFTSimpleJunction || featureClass.FeatureType == esriFeatureType.esriFTComplexJunction)
                        {
                            strNodeLayers += pDataset.Name.ToString();
                            strNodeLayers += ";";
                        }

                        //create the fields collections to be used by the frmAdvanced form
                        IFields pFields = featureClass.Fields;
                        if (pFields.FieldCount > 0)
                        {
                            for (int i = 0; i < pFields.FieldCount; i++)
                            {
                                //don't mess with objectid or shape or GlobalID
                                if ((pFields.get_Field(i).Name.ToString() != "OBJECTID") && (pFields.get_Field(i).Name.ToString() != "SHAPE") && (pFields.get_Field(i).Name.ToString() != "GlobalID") && (pFields.get_Field(i).Name.ToString() != featureClass.OIDFieldName.ToString()) && (pFields.get_Field(i).Name.ToString() != featureClass.ShapeFieldName.ToString()))
                                {
                                    m_myCol.Add(pDataset.Name.ToString(), pFields.get_Field(i).Name.ToString());
                                }
                            }
                        }

                        //remove the layer from the list of dictionary classes
                        if (myDictionary.ContainsKey(featureClass.AliasName))
                        {
                            myDictionary.Remove(featureClass.AliasName);
                        }

                        m_pSDI.ImportFeatureLayer(featureLayer, m_pSDT, true, true, true);
                    }
                }
                pLayer = pLayers.Next();
            } while (pLayer != null);

            //handle any feature classes that were not in the map
            if (myDictionary.Count > 0)
            {
                Dictionary <string, IFeatureClass> .KeyCollection keyColl = myDictionary.Keys;
                foreach (string s in keyColl)
                {
                    IFeatureClass fc;
                    bool          bln = myDictionary.TryGetValue(s, out fc);
                    IObjectClass  o   = (IObjectClass)fc;
                    pDataset = (IDataset)fc;

                    pStrLayerNames += pDataset.Name.ToString();
                    pStrLayerNames += ";";

                    //Build up the string for just the node feature classes
                    if (fc.FeatureType == esriFeatureType.esriFTSimpleJunction || featureClass.FeatureType == esriFeatureType.esriFTComplexJunction)
                    {
                        strNodeLayers += pDataset.Name.ToString();
                        strNodeLayers += ";";
                    }

                    //create the fields collections to be used by the frmAdvanced form
                    IFields pFields = fc.Fields;
                    if (pFields.FieldCount > 0)
                    {
                        for (int i = 0; i < pFields.FieldCount; i++)
                        {
                            //don't mess with objectid or shape or GlobalID
                            if ((pFields.get_Field(i).Name.ToString() != "OBJECTID") && (pFields.get_Field(i).Name.ToString() != "SHAPE") && (pFields.get_Field(i).Name.ToString() != "GlobalID") && (pFields.get_Field(i).Name.ToString() != fc.OIDFieldName.ToString()) && (pFields.get_Field(i).Name.ToString() != fc.ShapeFieldName.ToString()))
                            {
                                m_myCol.Add(pDataset.Name.ToString(), pFields.get_Field(i).Name.ToString());
                            }
                        }
                    }
                    if ((fc.FeatureType == esriFeatureType.esriFTComplexJunction) || (fc.FeatureType == esriFeatureType.esriFTSimpleJunction))
                    {
                        //node
                        m_pSDI.ImportObjectClass(o, m_pSDT, true, esriSchematicElementType.esriSchematicNodeType);
                    }
                    else
                    {
                        //link
                        m_pSDI.ImportObjectClass(o, m_pSDT, true, esriSchematicElementType.esriSchematicLinkType);
                    }
                }
            }

            m_pSDS.Save(ESRI.ArcGIS.esriSystem.esriArcGISVersion.esriArcGISVersionCurrent, true);
            m_pSDS.DesignMode = false;
            return(pStrLayerNames);
        }
Beispiel #15
0
        // Uses Geometric Network to find connected edges which determine desired rotation of point

        public Nullable <double> GetRotationUsingConnectedEdges(IFeature inFeature)
        {
            Nullable <double> rotationAngle = null;

            if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                try
                {
                    double         diameter       = 0;
                    List <double>  angles         = new List <double>();
                    List <double>  diameters      = new List <double>();
                    List <Boolean> flipDirections = new List <Boolean>();

                    IPoint                 pnt     = (ESRI.ArcGIS.Geometry.IPoint)inFeature.Shape;
                    INetworkFeature        netFeat = (INetworkFeature)inFeature;
                    ISimpleJunctionFeature simpleJunctionFeature = (ISimpleJunctionFeature)netFeat;
                    INetworkClass          netClass    = (INetworkClass)inFeature.Class;
                    IGeometricNetwork      geomNetwork = (IGeometricNetwork)netClass.GeometricNetwork;
                    INetwork               network     = (INetwork)geomNetwork.Network;
                    INetElements           netElements = (INetElements)network;

                    IFeatureClass      fc;
                    IFeature           feat;
                    IGeometry          geometry;
                    IPolyline          polyline;
                    ISegmentCollection segmentCollection;
                    ISegmentCollection segColTest;
                    ISegment           testSegment;
                    IEnumSegment       enumSegment;
                    System.Object      edgeWeight;
                    Boolean            edgeOrient;
                    int    partIndex    = 0;
                    int    segmentIndex = 0;
                    int    edgesCount;
                    int    edgeEID;
                    int    classId; int userId; int subId;
                    int    posField; double angle;
                    object Missing = Type.Missing;

                    IPoint toPoint;
                    ITopologicalOperator topoOp;
                    IPolygon             poly;
                    IRelationalOperator  relOp;

                    IForwardStarGEN forwardStar = (IForwardStarGEN)network.CreateForwardStar(false, null, null, null, null);
                    forwardStar.FindAdjacent(0, simpleJunctionFeature.EID, out edgesCount);


                    for (int i = 0; i < edgesCount; i++)
                    {
                        forwardStar.QueryAdjacentEdge(i, out edgeEID, out edgeOrient, out edgeWeight);
                        geometry = geomNetwork.get_GeometryForEdgeEID(edgeEID);
                        polyline = (IPolyline5)geometry;

                        //Special case for reducer
                        if (m_useDiameter & (edgesCount == 2))
                        {
                            netElements.QueryIDs(edgeEID, esriElementType.esriETEdge, out classId, out userId, out subId);
                            fc       = GetFeatureClassByClassId(classId, geomNetwork);
                            feat     = fc.GetFeature(userId);
                            posField = GetFieldPosition(m_diameterFieldName, feat);
                            if (posField > -1)
                            {
                                diameter = (double)feat.get_Value(posField);
                            }
                        }

                        //given line and point, return angles of all touching segments
                        segmentCollection = (ISegmentCollection)polyline;
                        enumSegment       = (IEnumSegment)segmentCollection.EnumSegments;
                        enumSegment.Next(out testSegment, ref partIndex, ref segmentIndex);

                        while (testSegment != null)
                        {
                            angle   = GetAngleOfSegment(testSegment);
                            toPoint = testSegment.ToPoint;
                            topoOp  = toPoint as ITopologicalOperator;
                            poly    = topoOp.Buffer(0.01) as IPolygon;

                            //ML: 20090617 Added test for segment touching point to be rotated
                            segColTest = new PolylineClass();
                            segColTest.AddSegment(testSegment, ref Missing, ref Missing);
                            relOp = segColTest as IRelationalOperator;

                            if (relOp.Touches(pnt))
                            {
                                relOp = poly as IRelationalOperator;
                                flipDirections.Add(relOp.Contains(pnt));
                                diameters.Add(diameter);
                                angles.Add(angle);
                            }
                            enumSegment.Next(out testSegment, ref partIndex, ref segmentIndex);
                        }

                        ///end of possible function returning list of angles
                    }
                    switch (angles.Count)
                    {
                    case 0:
                        break;

                    case 1:
                        // End cap or plug fitting or simliar.
                        rotationAngle = angles[0];
                        if (flipDirections[0])
                        {
                            rotationAngle += 180;
                        }
                        break;

                    case 2:
                        if (m_useDiameter & (diameters[0] < diameters[1]))
                        {
                            rotationAngle = angles[0];
                            if (flipDirections[0])
                            {
                                rotationAngle += 180;
                            }
                        }
                        else if (m_useDiameter & (diameters[0] >= diameters[1]))
                        {
                            rotationAngle = angles[1];
                            if (flipDirections[1])
                            {
                                rotationAngle += 180;
                            }
                        }
                        else
                        {
                            rotationAngle = angles[0];
                        }

                        break;

                    case 3:
                        //Tee or Tap fitting or similiar.  Rotate toward the odd line.
                        int tee = FindTee(angles[0], angles[1], angles[2]);
                        rotationAngle = angles[tee];
                        if (flipDirections[tee])
                        {
                            rotationAngle += 180;
                        }
                        break;

                    case 4:
                        // Cross fitting or similar. Any of the angles should work.
                        rotationAngle = (int)angles[0];
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    return(-1);
                }
            }


            //If needed, convert to geographic degrees(zero north clockwise)
            if (rotationAngle > 360)
            {
                rotationAngle -= 360;
            }
            if (rotationAngle < 0)
            {
                rotationAngle += 360;
            }
            if (rotationAngle != null & m_rotationType == esriSymbolRotationType.esriRotateSymbolGeographic)
            {
                int a = (int)rotationAngle;

                if (a > 0 & a <= 90)
                {
                    rotationAngle = 90 - a;
                }
                else if (a > 90 & a <= 360)
                {
                    rotationAngle = 450 - a;
                }
            }

            //Apply any spin angle
            if (rotationAngle != null)
            {
                rotationAngle += m_spinAngle;
                if (rotationAngle > 360)
                {
                    rotationAngle -= 360;
                }
                if (rotationAngle < 0)
                {
                    rotationAngle += 360;
                }
            }


            return(rotationAngle);
        }