Ejemplo n.º 1
0
 private bool method_0(IEdgeFeature edgeFeature, IEdgeFeature edgeFeature2)
 {
     return(edgeFeature.FromJunctionEID == edgeFeature2.FromJunctionEID ||
            edgeFeature.FromJunctionEID == edgeFeature2.ToJunctionEID ||
            edgeFeature.ToJunctionEID == edgeFeature2.FromJunctionEID
         ? false
         : edgeFeature.ToJunctionEID != edgeFeature2.ToJunctionEID);
 }
Ejemplo n.º 2
0
        private bool JustifyPipeLine(IFeature pFeatureLine)
        {
            IEdgeFeature edgeFeature = null;

            if (pFeatureLine is IEdgeFeature)
            {
                edgeFeature = (pFeatureLine as IEdgeFeature);
            }
            if (edgeFeature == null)
            {
                return(false);
            }
            IFeature feature  = edgeFeature.FromJunctionFeature as IFeature;
            IFeature feature2 = edgeFeature.ToJunctionFeature as IFeature;
            IFields  fields   = feature.Fields;
            string   text     = this.cmbPipePointFields.Text.Trim();
            int      num      = fields.FindField(text);
            object   obj      = feature.Value[num];
            string   a;

            if (obj == null || Convert.IsDBNull(obj))
            {
                a = "";
            }
            else
            {
                a = obj.ToString();
            }
            object obj2 = feature2.get_Value(num);
            string a2;

            if (obj2 == null || Convert.IsDBNull(obj2))
            {
                a2 = "";
            }
            else
            {
                a2 = obj2.ToString();
            }
            bool flag  = a == this.lstBoxPipePointValues.Text.Trim();
            bool flag2 = a2 == this.lstBoxPipePointValues.Text.Trim();

            if (flag)
            {
                this.m_alPipePoint.Add(feature);
            }
            if (flag2)
            {
                this.m_alPipePoint.Add(feature2);
            }
            return(flag || flag2);
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        public double RotatePointByNetwork(IMap pMap, INetworkFeature pPointFeature, bool bArithmeticAngle, string strDiameterFld, string strLayerName)
        {
            //This routine is used by both RotateDuringCreateFeature and RotateSelectedFeature.
            //It contains all of logic for determining the rotation angle.

            const int iAngleTol   = 5;
            double    dblAngle    = 0;
            double    dblDiameter = 0;
            double    ltest       = 0;

            int iLineDiameterFieldPos = 0;

            IPoint pPoint = default(IPoint);
            ISimpleJunctionFeature pSimpJunc = null;
            IEdgeFeature           pEdgeFeat = default(IEdgeFeature);

            List <string> pLstInt    = new List <string>();
            List <double> cAngles    = new List <double>();
            List <double> cDiameters = new List <double>();
            UID           pId        = new UID();
            IFeature      pTempFeat  = null;

            try
            {
                pPoint = (IPoint)((IFeature)pPointFeature).Shape;
                if (pPoint.IsEmpty)
                {
                    return(0);
                }
                //Create spatial filter to find intersecting features at this given point


                pSimpJunc = (ISimpleJunctionFeature)pPointFeature;


                for (int i = 0; i <= pSimpJunc.EdgeFeatureCount - 1; i++)
                {
                    pEdgeFeat = pSimpJunc.get_EdgeFeature(i);

                    if (pLstInt.Count > 0)
                    {
                        if (pLstInt.Contains(((IFeature)pEdgeFeat).Class.ObjectClassID + " " + ((IFeature)pEdgeFeat).OID))
                        {
                            continue;
                        }
                    }

                    pTempFeat = (IFeature)pEdgeFeat;

                    if (strLayerName == Globals.getClassName((IDataset)pTempFeat.Class) || strLayerName == "" || strLayerName == null)
                    {
                        pLstInt.Add(((IFeature)pEdgeFeat).Class.ObjectClassID.ToString() + " " + ((IFeature)pEdgeFeat).OID.ToString());

                        dblAngle = Globals.GetAngleOfLineAtPoint((IPolyline)pTempFeat.ShapeCopy, pPoint, Globals.GetXYTolerance(pPoint));
                        dblAngle = Globals.ConvertRadsToDegrees(dblAngle);


                        //Convert to geographic degrees(zero north clockwise)
                        if (!(bArithmeticAngle))
                        {
                            dblAngle = Globals.ConvertArithmeticToGeographic(dblAngle);
                        }



                        //Round angle
                        dblAngle = Math.Round(dblAngle, 4);

                        //Find diameter field, if it exists
                        iLineDiameterFieldPos = ((IFeature)pEdgeFeat).Fields.FindField(strDiameterFld);

                        //Get diameter of line
                        if (iLineDiameterFieldPos < 0)
                        {
                            dblDiameter = -9999;
                        }
                        else if (((IFeature)pEdgeFeat).get_Value(iLineDiameterFieldPos) == null)
                        {
                            dblDiameter = -9999;
                        }
                        else if (object.ReferenceEquals(((IFeature)pEdgeFeat).get_Value(iLineDiameterFieldPos), DBNull.Value))
                        {
                            dblDiameter = -9999;
                        }
                        else
                        {
                            double.TryParse(((IFeature)pEdgeFeat).get_Value(iLineDiameterFieldPos).ToString(), out dblDiameter);
                        }


                        //add this line (angle and diameter) to a collection of line info for this point
                        cAngles.Add(dblAngle);

                        if (dblDiameter != -9999)
                        {
                            cDiameters.Add(dblDiameter);
                        }
                    }
                }

                //Read the collection of line segment angles and diameters
                //and use them to derive a symbol rotation angle for the point
                switch (cAngles.Count)
                {
                case 0:
                    //One line such as at valves

                    return(0.0);

                case 1:
                    //One line such as at valves
                    return(cAngles[0]);

                case 2:
                    //Two lines such as at reducers Or at tee fittings where line is not broken

                    if (cDiameters.Count == 2)
                    {
                        //If cDiameters(0) Is Nothing Or cDiameters(1) Is Nothing Then
                        //    Return cAngles.Item(0)
                        //Else
                        if (cDiameters[0] > cDiameters[1])
                        {
                            return(cAngles[1]);
                            //If cAngles.Item(0) = cAngles.Item(1) Then
                            //    Return cAngles.Item(1)
                            //Else
                            //    Return cAngles.Item(1) - 180
                            //End If
                        }
                        else
                        {
                            return(cAngles[0]);
                            //If cAngles.Item(0) = cAngles.Item(1) Then
                            //    Return cAngles.Item(0) - 180
                            //Else
                            //    Return cAngles.Item(1)
                            //End If
                        }
                    }
                    else
                    {
                        return(cAngles[0]);
                    }

                    break;

                case 3:
                    //Three lines such as at tee fittings where line is broken
                    ltest = Math.Abs(cAngles[0] - cAngles[1]);
                    if (ltest >= 180 - iAngleTol & ltest <= 180 + iAngleTol)
                    {
                        return(cAngles[2]);
                    }
                    else
                    {
                        ltest = Math.Abs(cAngles[0] - cAngles[2]);
                        if (ltest >= 180 - iAngleTol & ltest <= 180 + iAngleTol)
                        {
                            return(cAngles[1]);
                        }
                        else
                        {
                            ltest = Math.Abs(cAngles[1] - cAngles[2]);
                            if (ltest >= 180 - iAngleTol & ltest <= 180 + iAngleTol)
                            {
                                return(cAngles[0]);
                            }
                            else
                            {
                                return(-360);
                            }
                        }
                    }
                    break;

                case 4:
                    //Four lines such as at crosses
                    //the angle of any of the four lines should work since the symbol should be symetrically
                    return(cAngles[0]);

                default:
                    return(0);
                }

                //Clear collections
            }
            catch
            {
                return(0);
            }
            finally
            {
                pPoint    = null;
                pSimpJunc = null;
                pEdgeFeat = null;

                pLstInt.Clear();
                cAngles.Clear();
                cDiameters.Clear();
                pId       = null;
                pTempFeat = null;
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public void GetFlow(IMap pMap)
        {
            int num4;

            this.m_pPointcol = new MultipointClass();
            this.m_eFlowDirection.Clear();
            this.m_angle.Clear();
            INetwork        network  = NetworkAnalyst.m_pAnalystGN.Network;
            IUtilityNetwork network2 = network as IUtilityNetwork;
            IEnumNetEID     netEIDs  = network.CreateNetBrowser(esriElementType.esriETEdge);
            IEnumNetEID     teid2    = network.CreateNetBrowser(esriElementType.esriETJunction);

            netEIDs.Reset();
            int        count  = netEIDs.Count;
            int        num2   = teid2.Count;
            IEIDHelper helper = new EIDHelperClass
            {
                GeometricNetwork       = NetworkAnalyst.m_pAnalystGN,
                OutputSpatialReference = pMap.SpatialReference,
                ReturnGeometries       = true,
                ReturnFeatures         = true
            };
            IEnumEIDInfo info = helper.CreateEnumEIDInfo(teid2);
            int          num3 = info.Count;

            teid2.Reset();
            info.Reset();
            IPointCollection points = new MultipointClass();
            object           before = Missing.Value;

            for (num4 = 0; num4 < num2; num4++)
            {
                IPoint inPoint = info.Next().Geometry as IPoint;
                points.AddPoint(inPoint, ref before, ref before);
            }
            info = null;
            info = helper.CreateEnumEIDInfo(netEIDs);
            num3 = info.Count;
            netEIDs.Reset();
            info.Reset();
            IList list  = new ArrayList();
            ILine line  = new LineClass();
            IList list2 = new ArrayList();
            int   num5  = 0;

            for (num4 = 0; num4 < count; num4++)
            {
                int edgeEID = netEIDs.Next();
                this.m_eFlowDirection.Add(network2.GetFlowDirection(edgeEID));
                IEIDInfo         info2         = info.Next();
                IGeometry        geometry      = info2.Geometry;
                IEdgeFeature     feature       = info2.Feature as IEdgeFeature;
                IPointCollection points2       = geometry as IPointCollection;
                int                 pointCount = points2.PointCount;
                IPoint              other      = new PointClass();
                IPoint[]            pointArray = new IPoint[pointCount];
                IRelationalOperator @operator  = points as IRelationalOperator;
                IPointCollection    points3    = new MultipointClass();
                int                 num8       = 0;
                for (int i = 0; i < pointCount; i++)
                {
                    other = points2.get_Point(i);
                    if (@operator.Contains(other))
                    {
                        IPoint point3 = points2.get_Point(i);
                        points3.AddPoint(point3, ref before, ref before);
                        pointArray[i] = point3;
                    }
                    else
                    {
                        pointArray[i] = null;
                    }
                }
                IPoint[] pointArray2 = new IPoint[pointCount];
                num8 = points3.PointCount;
                int index = -1;
                if (num5 < (points3.PointCount - 1))
                {
                    for (int j = 0; j < pointCount; j++)
                    {
                        if (pointArray[j] != null)
                        {
                            index++;
                        }
                        if (index == num5)
                        {
                            index = j;
                            break;
                        }
                    }
                    IPoint point4 = new PointClass();
                    pointArray2[index]     = pointArray[index];
                    pointArray2[index + 1] = points2.get_Point(index + 1);
                    point4.X = (pointArray2[index].X + pointArray2[index + 1].X) / 2.0;
                    point4.Y = (pointArray2[index].Y + pointArray2[index + 1].Y) / 2.0;
                    this.m_pPointcol.AddPoint(point4, ref before, ref before);
                    line.FromPoint = pointArray2[index];
                    line.ToPoint   = pointArray2[index + 1];
                    this.m_angle.Add(line.Angle);
                    num5++;
                    if (num5 == (num8 - 1))
                    {
                        num5 = 0;
                    }
                }
            }
            this.ShowFlow(pMap as IActiveView);
        }
Ejemplo n.º 7
0
        public Nullable <double> RotatePointByNetwork(IMap pMap, INetworkFeature pPointFeature, bool bArithmeticAngle, string strDiameterFld, string strLayerName)
        {
            //This routine is used by both RotateDuringCreateFeature and RotateSelectedFeature.
            //It contains all of logic for determining the rotation angle.
            double xyTol;

            const int         iAngleTol = 5;
            diameterMeterFeat diamPnt   = null;

            IPoint pPoint = default(IPoint);
            ISimpleJunctionFeature pSimpJunc = null;
            IEdgeFeature           pEdgeFeat = default(IEdgeFeature);

            List <string> pLstInt = new List <string>();

            List <diameterMeterFeat> diametersWithPoints = new List <diameterMeterFeat>();


            UID      pId       = new UID();
            IFeature pTempFeat = null;

            try
            {
                pPoint = (IPoint)((IFeature)pPointFeature).Shape;
                if (pPoint.IsEmpty)
                {
                    return(0);
                }
                //Create spatial filter to find intersecting features at this given point

                xyTol     = Globals.GetXYTolerance(pPoint);
                pSimpJunc = (ISimpleJunctionFeature)pPointFeature;


                for (int i = 0; i <= pSimpJunc.EdgeFeatureCount - 1; i++)
                {
                    pEdgeFeat = pSimpJunc.get_EdgeFeature(i);

                    if (pLstInt.Count > 0)
                    {
                        if (pLstInt.Contains(((IFeature)pEdgeFeat).Class.ObjectClassID + " " + ((IFeature)pEdgeFeat).OID))
                        {
                            continue;
                        }
                    }

                    pTempFeat = (IFeature)pEdgeFeat;

                    if (strLayerName == Globals.getClassName((IDataset)pTempFeat.Class) || strLayerName == "" || strLayerName == null)
                    {
                        string listInt;
                        diamPnt = null;
                        angleLogic(pPoint, pTempFeat, bArithmeticAngle, strDiameterFld, xyTol, out listInt, out diamPnt);
                        pLstInt.Add(listInt);

                        diametersWithPoints.Add(diamPnt);
                    }
                }
                return(getAngle(diametersWithPoints, iAngleTol));
            }
            catch
            {
                return(0);
            }
            finally
            {
                diamPnt   = null;
                pPoint    = null;
                pSimpJunc = null;
                pEdgeFeat = null;

                pLstInt.Clear();

                diametersWithPoints.Clear();
                pId       = null;
                pTempFeat = null;
            }
        }
Ejemplo n.º 8
0
        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);
                }
            }
        }
Ejemplo n.º 9
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);
                }
            }
        }
Ejemplo n.º 10
0
        private void method_7(ILayer layer)
        {
            string str;
            string str1;
            string str2;

            if (layer is IFeatureLayer)
            {
                IFeatureLayer featureLayer = layer as IFeatureLayer;
                if (featureLayer.Visible)
                {
                    IGeometry      geometry           = ((ITopologicalOperator)this.m_pBaseLine).Buffer(this.m_dBufferRadius);
                    ISpatialFilter spatialFilterClass = new SpatialFilter();
                    spatialFilterClass.Geometry   = (geometry);
                    spatialFilterClass.SpatialRel = (esriSpatialRelEnum)(1);
                    IFeatureClass   featureClass = featureLayer.FeatureClass;
                    IBasicLayerInfo lineConfig   = PipeConfig.GetBasicLayerInfo(featureClass.AliasName) as IBasicLayerInfo;
                    if (lineConfig != null)
                    {
                        IFeatureCursor featureCursor = featureClass.Search(spatialFilterClass, false);
                        IFeature       feature       = featureCursor.NextFeature();
                        while (feature != null)
                        {
                            if ((!feature.HasOID || feature == null ? false : feature.FeatureType == (esriFeatureType)8))
                            {
                                IGeometry shape = feature.Shape;
                                int       num   =
                                    feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                                str = (num == -1 ? "" : feature.get_Value(num).ToString());
                                num =
                                    feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                                str1 = (num == -1 ? "" : feature.get_Value(num).ToString());
                                string str3 = "";
                                if (str != "")
                                {
                                    str3 = str;
                                }
                                if (str1 != "")
                                {
                                    str3 = str1;
                                }
                                this.m_dDiameterDst = this.GetDiameterFromString(str3.Trim());
                                if (shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                {
                                    double num1 = ((IProximityOperator)this.m_pBaseLine).ReturnDistance(shape);
                                    if (num1 > 1E-07)
                                    {
                                        num1 =
                                            Math.Abs(num1 - 0.0005 * (double)this.m_dDiameter -
                                                     0.0005 * (double)this.m_dDiameterDst);
                                    }
                                    if (!(this.m_nAnalyseType != DistAnalyseType.emHrzDist ? true : num1 >= 1E-08))
                                    {
                                        feature = featureCursor.NextFeature();
                                    }
                                    else if ((this.m_nAnalyseType != DistAnalyseType.emVerDist ? true : num1 <= 1E-08))
                                    {
                                        double num2 = 0;
                                        //this.m_nHeightFlagBase = this.PipeConfig.getLineConfig_HeightFlag(this.m_strLayerName);
                                        //this.m_nHeightFlagDst = this.PipeConfig.getLineConfig_HeightFlag(feature.Class.AliasName);

                                        this.m_nHeightFlagBase = (int)lineConfig.HeightType;
                                        this.m_nHeightFlagDst  = (int)lineConfig.HeightType;
                                        if ((this.m_nAnalyseType == DistAnalyseType.emVerDist
                                            ? true
                                            : this.m_nAnalyseType == DistAnalyseType.emHitDist))
                                        {
                                            num2 = (num1 >= 1E-07
                                                ? this.method_3(this.m_pBaseLine, (IPolyline)shape)
                                                : this.method_2(this.m_pBaseLine, (IPolyline)shape));
                                        }
                                        if (feature.FeatureType == (esriFeatureType)8)
                                        {
                                            IEdgeFeature edgeFeature = (IEdgeFeature)feature;
                                            if (edgeFeature != null)
                                            {
                                                int    fromJunctionEID = edgeFeature.FromJunctionEID;
                                                int    toJunctionEID   = edgeFeature.ToJunctionEID;
                                                string str4            =
                                                    lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ);
                                                string str5 = "";
                                                int    num3 = feature.Fields.FindField(str4);
                                                if (num3 != -1)
                                                {
                                                    object value = feature.get_Value(num3);
                                                    str5 = ((value == null ? false : !Convert.IsDBNull(value))
                                                        ? value.ToString()
                                                        : "");
                                                }
                                                // int num4 = feature.Fields.FindField("埋设方式");
                                                int num4 =
                                                    feature.Fields.FindField(
                                                        lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.MSFS));
                                                str2 = (num4 == -1 ? "" : this.method_6(feature.get_Value(num4)));
                                                if (this.method_1(this.m_nBaseLineFromID, this.m_nBaseLineToID,
                                                                  fromJunctionEID, toJunctionEID))
                                                {
                                                    DstLineItem dstLineItem = new DstLineItem()
                                                    {
                                                        m_pPolyline    = CommonUtils.GetPolylineDeepCopy((IPolyline)shape),
                                                        m_strLayerName = str5,
                                                        m_nFID         = (int)feature.get_Value(0)
                                                    };
                                                    if (num1 <= 1E-07)
                                                    {
                                                        dstLineItem.m_dResultDistH = 0f;
                                                    }
                                                    else
                                                    {
                                                        float single =
                                                            Math.Abs((float)num1 - (float)this.m_dDiameter / 2000f);
                                                        dstLineItem.m_dResultDistH =
                                                            CommonUtils.GetFloatThreePoint(single);
                                                    }
                                                    if (num2 <= 1E-07)
                                                    {
                                                        dstLineItem.m_dResultDistV = 0f;
                                                    }
                                                    else
                                                    {
                                                        float single1 = Math.Abs((float)num2);
                                                        dstLineItem.m_dResultDistV =
                                                            CommonUtils.GetFloatThreePoint(single1);
                                                    }
                                                    dstLineItem.m_nDstLineFromID = fromJunctionEID;
                                                    dstLineItem.m_nDstLineToID   = toJunctionEID;
                                                    dstLineItem.m_dPipeWidth     = 0;
                                                    dstLineItem.m_dPipeHeight    = 0;
                                                    if (str != "")
                                                    {
                                                        dstLineItem.m_strPipeWidthAndHeight = str3;
                                                    }
                                                    if (str1 != "")
                                                    {
                                                        dstLineItem.m_strPipeWidthAndHeight = str3;
                                                    }
                                                    if (!this.HighOpAnother(this.m_pBaseLine, dstLineItem.m_pPolyline))
                                                    {
                                                        dstLineItem.m_dTolDistH =
                                                            CommonUtils.GetPipeLineAlarmHrzDistByFeatureClassName2(
                                                                ipipeConfig_0,
                                                                CommonUtils.GetSmpClassName(feature.Class.AliasName),
                                                                CommonUtils.GetSmpClassName(this.m_strLayerName),
                                                                feature, this.m_pFeature);
                                                        dstLineItem.m_dTolDistV =
                                                            CommonUtils.GetPipeLineAlarmVerDistByFeatureClassName(
                                                                ipipeConfig_0,
                                                                CommonUtils.GetSmpClassName(feature.Class.AliasName),
                                                                CommonUtils.GetSmpClassName(this.m_strLayerName), str2,
                                                                this.m_strBuryKind);
                                                    }
                                                    else
                                                    {
                                                        dstLineItem.m_dTolDistH =
                                                            CommonUtils.GetPipeLineAlarmHrzDistByFeatureClassName2(
                                                                ipipeConfig_0,
                                                                CommonUtils.GetSmpClassName(this.m_strLayerName),
                                                                CommonUtils.GetSmpClassName(feature.Class.AliasName),
                                                                this.m_pFeature, feature);
                                                        dstLineItem.m_dTolDistV =
                                                            CommonUtils.GetPipeLineAlarmVerDistByFeatureClassName(
                                                                ipipeConfig_0,
                                                                CommonUtils.GetSmpClassName(this.m_strLayerName),
                                                                CommonUtils.GetSmpClassName(feature.Class.AliasName),
                                                                this.m_strBuryKind, str2);
                                                    }
                                                    this.m_arrDstPipeline.Add(dstLineItem);
                                                }
                                                feature = featureCursor.NextFeature();
                                            }
                                            else
                                            {
                                                feature = featureCursor.NextFeature();
                                            }
                                        }
                                        else
                                        {
                                            feature = featureCursor.NextFeature();
                                        }
                                    }
                                    else
                                    {
                                        feature = featureCursor.NextFeature();
                                    }
                                }
                                else
                                {
                                    feature = featureCursor.NextFeature();
                                }
                            }
                            else
                            {
                                feature = featureCursor.NextFeature();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private void method_1(IEdgeFeature iedgeFeature_0)
        {
            int                    edgeFeatureCount;
            int                    i;
            IEdgeFeature           edgeFeature;
            IPoint                 shape;
            ILineMovePointFeedback lineMovePointFeedbackClass;
            IHitTest               hitTest;
            IPoint                 pointClass;
            double                 num;
            int                    num1;
            int                    num2;
            bool                   flag;
            int                    pointCount;
            int                    j;
            IPath                  geometry;

            if (!(iedgeFeature_0 is IComplexEdgeFeature))
            {
                int       oID       = (iedgeFeature_0 as IFeature).OID;
                IGeometry shapeCopy = (iedgeFeature_0 as IFeature).ShapeCopy;
                if (this.imoveGeometryFeedback_0 == null)
                {
                    this.imoveGeometryFeedback_0 = new MoveGeometryFeedback()
                    {
                        Display = this.iscreenDisplay_0
                    };
                }
                this.imoveGeometryFeedback_0.AddGeometry(shapeCopy);
                int fromJunctionEID = iedgeFeature_0.FromJunctionEID;
                IJunctionFeature fromJunctionFeature = iedgeFeature_0.FromJunctionFeature;
                if (fromJunctionFeature is ISimpleJunctionFeature)
                {
                    edgeFeatureCount = (fromJunctionFeature as ISimpleJunctionFeature).EdgeFeatureCount;
                    for (i = 0; i < edgeFeatureCount; i++)
                    {
                        edgeFeature = (fromJunctionFeature as ISimpleJunctionFeature).EdgeFeature[i];
                        if ((edgeFeature as IFeature).OID != oID && !this.iset_0.Find(edgeFeature) &&
                            !this.iset_1.Find(edgeFeature))
                        {
                            this.iset_1.Add(edgeFeature);
                            shapeCopy = (edgeFeature as IFeature).Shape;
                            if (!(edgeFeature is ISimpleEdgeFeature))
                            {
                                shape      = (fromJunctionFeature as IFeature).Shape as IPoint;
                                hitTest    = shapeCopy as IHitTest;
                                pointClass = new ESRI.ArcGIS.Geometry.Point();
                                num        = 0;
                                num1       = -1;
                                num2       = -1;
                                flag       = false;
                                if (hitTest.HitTest(shape, 0, esriGeometryHitPartType.esriGeometryPartVertex, pointClass,
                                                    ref num, ref num1, ref num2, ref flag))
                                {
                                    lineMovePointFeedbackClass = new LineMovePointFeedback()
                                    {
                                        Display = this.iscreenDisplay_0
                                    };
                                    pointCount = 0;
                                    for (j = 0; j < num1; j++)
                                    {
                                        geometry   = (IPath)((IGeometryCollection)hitTest).Geometry[j];
                                        pointCount = pointCount + (geometry as IPointCollection).PointCount;
                                    }
                                    num2 = num2 + pointCount;
                                    lineMovePointFeedbackClass.Start(hitTest as IPolyline, num2, shape);
                                    this.ilist_0.Add(lineMovePointFeedbackClass);
                                    this.ilist_1.Add(shape);
                                }
                            }
                            else
                            {
                                shape = null;
                                lineMovePointFeedbackClass = new LineMovePointFeedback()
                                {
                                    Display = this.iscreenDisplay_0
                                };
                                if (edgeFeature.FromJunctionEID != fromJunctionEID)
                                {
                                    shape =
                                        (shapeCopy as IPointCollection).Point[
                                            (shapeCopy as IPointCollection).PointCount - 1];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline,
                                                                     (shapeCopy as IPointCollection).PointCount - 1, shape);
                                }
                                else
                                {
                                    shape = (shapeCopy as IPointCollection).Point[0];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline, 0, shape);
                                }
                                this.ilist_0.Add(lineMovePointFeedbackClass);
                                this.ilist_1.Add(shape);
                            }
                        }
                    }
                }
                fromJunctionEID = iedgeFeature_0.ToJunctionEID;
                IJunctionFeature toJunctionFeature = iedgeFeature_0.ToJunctionFeature;
                if (toJunctionFeature is ISimpleJunctionFeature)
                {
                    edgeFeatureCount = (toJunctionFeature as ISimpleJunctionFeature).EdgeFeatureCount;
                    for (i = 0; i < edgeFeatureCount; i++)
                    {
                        edgeFeature = (toJunctionFeature as ISimpleJunctionFeature).EdgeFeature[i];
                        if ((edgeFeature as IFeature).OID != oID && !this.iset_0.Find(edgeFeature) &&
                            !this.iset_1.Find(edgeFeature))
                        {
                            this.iset_1.Add(edgeFeature);
                            shape = null;
                            lineMovePointFeedbackClass = new LineMovePointFeedback()
                            {
                                Display = this.iscreenDisplay_0
                            };
                            shapeCopy = (edgeFeature as IFeature).Shape;
                            if (!(edgeFeature is ISimpleEdgeFeature))
                            {
                                IPoint point = (toJunctionFeature as IFeature).Shape as IPoint;
                                hitTest    = shapeCopy as IHitTest;
                                pointClass = new ESRI.ArcGIS.Geometry.Point();
                                num        = 0;
                                num1       = -1;
                                num2       = -1;
                                flag       = false;
                                if (hitTest.HitTest(point, 0, esriGeometryHitPartType.esriGeometryPartVertex, pointClass,
                                                    ref num, ref num1, ref num2, ref flag))
                                {
                                    lineMovePointFeedbackClass = new LineMovePointFeedback()
                                    {
                                        Display = this.iscreenDisplay_0
                                    };
                                    pointCount = 0;
                                    for (j = 0; j < num1; j++)
                                    {
                                        geometry   = (IPath)((IGeometryCollection)hitTest).Geometry[j];
                                        pointCount = pointCount + (geometry as IPointCollection).PointCount;
                                    }
                                    num2 = num2 + pointCount;
                                    lineMovePointFeedbackClass.Start(hitTest as IPolyline, num2, point);
                                    this.ilist_0.Add(lineMovePointFeedbackClass);
                                    this.ilist_1.Add(point);
                                }
                            }
                            else
                            {
                                if (edgeFeature.FromJunctionEID != fromJunctionEID)
                                {
                                    shape =
                                        (shapeCopy as IPointCollection).Point[
                                            (shapeCopy as IPointCollection).PointCount - 1];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline,
                                                                     (shapeCopy as IPointCollection).PointCount - 1, shape);
                                }
                                else
                                {
                                    shape = (shapeCopy as IPointCollection).Point[0];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline, 0, shape);
                                }
                                this.ilist_0.Add(lineMovePointFeedbackClass);
                                this.ilist_1.Add(shape);
                            }
                        }
                    }
                }
            }
            else
            {
                this.method_2(iedgeFeature_0 as IComplexEdgeFeature);
            }
        }
Ejemplo n.º 12
0
        private void method_2(IComplexEdgeFeature icomplexEdgeFeature_0)
        {
            ILineMovePointFeedback lineMovePointFeedbackClass;
            int       oID       = (icomplexEdgeFeature_0 as IFeature).OID;
            IGeometry shapeCopy = (icomplexEdgeFeature_0 as IFeature).ShapeCopy;

            if (this.imoveGeometryFeedback_0 == null)
            {
                this.imoveGeometryFeedback_0 = new MoveGeometryFeedback()
                {
                    Display = this.iscreenDisplay_0
                };
            }
            this.imoveGeometryFeedback_0.AddGeometry(shapeCopy);
            for (int i = 0; i < icomplexEdgeFeature_0.JunctionFeatureCount; i++)
            {
                IJunctionFeature junctionFeature = icomplexEdgeFeature_0.JunctionFeature[i];
                if (junctionFeature is ISimpleJunctionFeature)
                {
                    int    eID              = (junctionFeature as ISimpleJunctionFeature).EID;
                    IPoint point            = (junctionFeature as IFeature).ShapeCopy as IPoint;
                    int    edgeFeatureCount = (junctionFeature as ISimpleJunctionFeature).EdgeFeatureCount;
                    for (int j = 0; j < edgeFeatureCount; j++)
                    {
                        IEdgeFeature edgeFeature = (junctionFeature as ISimpleJunctionFeature).EdgeFeature[j];
                        if ((edgeFeature as IFeature).OID != oID && !this.iset_0.Find(edgeFeature) &&
                            !this.iset_1.Find(edgeFeature))
                        {
                            this.iset_1.Add(edgeFeature);
                            shapeCopy = (edgeFeature as IFeature).Shape;
                            IPoint point1 = null;
                            if (!(edgeFeature is ISimpleEdgeFeature))
                            {
                                IHitTest shape      = (edgeFeature as IFeature).Shape as IHitTest;
                                IPoint   pointClass = new ESRI.ArcGIS.Geometry.Point();
                                double   num        = 0;
                                int      num1       = -1;
                                int      num2       = -1;
                                bool     flag       = false;
                                if (shape.HitTest(point, 0, esriGeometryHitPartType.esriGeometryPartVertex, pointClass,
                                                  ref num, ref num1, ref num2, ref flag))
                                {
                                    lineMovePointFeedbackClass = new LineMovePointFeedback()
                                    {
                                        Display = this.iscreenDisplay_0
                                    };
                                    int pointCount = 0;
                                    for (int k = 0; k < num1; k++)
                                    {
                                        IPath geometry = (IPath)((IGeometryCollection)shape).Geometry[k];
                                        pointCount = pointCount + (geometry as IPointCollection).PointCount;
                                    }
                                    num2 = num2 + pointCount;
                                    lineMovePointFeedbackClass.Start(shape as IPolyline, num2, point);
                                    this.ilist_0.Add(lineMovePointFeedbackClass);
                                    this.ilist_1.Add(point);
                                }
                            }
                            else
                            {
                                lineMovePointFeedbackClass = new LineMovePointFeedback()
                                {
                                    Display = this.iscreenDisplay_0
                                };
                                if (edgeFeature.FromJunctionEID != eID)
                                {
                                    point1 =
                                        (shapeCopy as IPointCollection).Point[
                                            (shapeCopy as IPointCollection).PointCount - 1];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline,
                                                                     (shapeCopy as IPointCollection).PointCount - 1, point1);
                                }
                                else
                                {
                                    point1 = (shapeCopy as IPointCollection).Point[0];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline, 0, point1);
                                }
                                this.ilist_0.Add(lineMovePointFeedbackClass);
                                this.ilist_1.Add(point1);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public void GetBaseLine()
        {
            string str;
            string str1;
            string str2;

            this.timer_0.Stop();
            this.dataGridView1.Rows.Clear();
            IMap         map = this.m_app.FocusMap;
            IEnumFeature featureSelection = (IEnumFeature)map.FeatureSelection;

            featureSelection.Reset();
            IFeature feature = featureSelection.Next();

            if ((feature == null ? false : feature.FeatureType == (esriFeatureType)8))
            {
                CommonUtils.GetSmpClassName(feature.Class.AliasName);
                if (_config.IsPipelineLayer(feature.Class.AliasName))
                {
                    IGeometry shape = feature.Shape;
                    if (shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        this.ipolyline_0 = CommonUtils.GetPolylineDeepCopy((IPolyline)shape);
                        IBasicLayerInfo layerInfo = _config.GetBasicLayerInfo(feature.Class.AliasName);
                        this.m_commonDistAls.m_pFeature     = feature;
                        this.m_commonDistAls.m_pBaseLine    = this.ipolyline_0;
                        this.m_commonDistAls.m_strLayerName = feature.Class.AliasName;
                        int num = feature.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.MSFS));
                        str = (num == -1 ? "" : this.method_0(feature.get_Value(num)));
                        this.m_commonDistAls.m_strBuryKind = str;
                        int num1 = feature.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                        str1 = (num1 == -1 ? "" : this.method_0(feature.get_Value(num1)));
                        num1 = feature.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                        str2 = (num1 == -1 ? "" : this.method_0(feature.get_Value(num1)));
                        string str3 = "";
                        if (str1 != "")
                        {
                            str3 = str1;
                        }
                        if (str2 != "")
                        {
                            str3 = str2;
                        }
                        this.m_commonDistAls.m_dDiameter = this.m_commonDistAls.GetDiameterFromString(str3.Trim());
                        IEdgeFeature edgeFeature = (IEdgeFeature)feature;
                        this.m_commonDistAls.m_nBaseLineFromID = edgeFeature.FromJunctionEID;
                        this.m_commonDistAls.m_nBaseLineToID   = edgeFeature.ToJunctionEID;
                        this.btAnalyse.Enabled             = this.m_commonDistAls.m_pBaseLine != null;
                        this.chitAnalyse_0.PipeLayer_Class = feature.Class as IFeatureClass;
                        this.chitAnalyse_0.BaseLine_OID    = feature.OID;
                    }
                    else
                    {
                        MessageBox.Show("所选择的管线多于一条,或者不是管线!");
                    }
                }
                else
                {
                    this.m_commonDistAls.m_pBaseLine = null;
                    this.btAnalyse.Enabled           = false;
                    this.m_app.FocusMap.ClearSelection();
                    this.m_app.ActiveView.Refresh();
                }
            }
            else
            {
                this.m_commonDistAls.m_pBaseLine = null;
                this.btAnalyse.Enabled           = false;
                this.m_app.FocusMap.ClearSelection();
                this.m_app.ActiveView.Refresh();
            }
        }
Ejemplo n.º 14
0
        public void GetBaseLine(IPoint point)
        {
            string str;
            string str1;
            string str2;

            this.timer_0.Stop();
            this.dataGridView1.Rows.Clear();
            IMap     map     = this.m_app.FocusMap;
            IFeature feature = ((IEnumFeature)map.FeatureSelection).Next();

            if (feature == null ? true : feature.FeatureType != esriFeatureType.esriFTSimpleEdge)
            {
                this.m_commonDistAls.m_pBaseLine = null;
                this.btAnalyse.Enabled           = false;
                this.m_app.FocusMap.ClearSelection();
                this.m_app.ActiveView.Refresh();
                //this.tbPipeWidthOrHeight.Text = "";
                return;
            }
            IFeatureLayer pLayer =
                CommonUtils.GetLayerByFeatureClassName(m_app.FocusMap, ((IDataset)feature.Class).Name) as IFeatureLayer;
            IPipelineLayer  pipeLayer = m_config.GetPipelineLayer(feature.Class as IFeatureClass);
            IBasicLayerInfo pipeLine  = m_config.GetBasicLayerInfo(feature.Class as IFeatureClass);

            if (pipeLine == null)
            {
                this.m_commonDistAls.m_pBaseLine = null;
                this.btAnalyse.Enabled           = false;
                this.m_app.FocusMap.ClearSelection();
                this.m_app.ActiveView.Refresh();
                return;
            }
            List <IBasicLayerInfo> basicInfos      = pipeLayer.GetLayers(enumPipelineDataType.Junction);
            IFeatureClass          junFeatureClass = basicInfos.Count > 0 ? basicInfos[0].FeatureClass : null;
            //需要重新获取边信息
            IGeometricNetwork      geometricNetwork = ((INetworkClass)junFeatureClass).GeometricNetwork;
            IFeatureClassContainer featureDataset   = geometricNetwork.FeatureDataset as IFeatureClassContainer;
            IPointToEID            pointToEIDClass  = new PointToEID();

            pointToEIDClass.SourceMap        = (m_app.FocusMap);
            pointToEIDClass.GeometricNetwork = (geometricNetwork);
            pointToEIDClass.SnapTolerance    = (m_app.ActiveView.Extent.Width / 200.0);
            int    edgeID   = 0;
            IPoint location = null;
            double percent  = 0;

            pointToEIDClass.GetNearestEdge(point, out edgeID, out location, out percent);
            if (edgeID == 0)
            {
                return;
            }

            int          userClassID;
            int          userID;
            int          userSubID;
            INetElements network = geometricNetwork.Network as INetElements;

            network.QueryIDs(edgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID);
            IFeatureClass lineClass   = featureDataset.ClassByID[userClassID] as IFeatureClass;
            IFeature      lineFeature = lineClass.GetFeature(userID);
            IGeometry     shape       = lineFeature.Shape;

            if (shape.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                this.ipolyline_0 = CommonUtils.GetPolylineDeepCopy((IPolyline)shape);
                this.m_commonDistAls.m_pFeature     = feature;
                this.m_commonDistAls.m_pBaseLine    = this.ipolyline_0;
                this.m_commonDistAls.m_strLayerName = feature.Class.AliasName;
                //int num = feature.Fields.FindField("埋设方式");
                int num = lineFeature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.MSFS));
                str = (num == -1 ? "" : this.GetDBObjectValue(lineFeature.get_Value(num)));
                this.m_commonDistAls.m_strBuryKind = str;
                int num1 = lineFeature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                str1 = (num1 == -1 ? "" : this.GetDBObjectValue(lineFeature.get_Value(num1)));
                num1 = feature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                str2 = (num1 == -1 ? "" : lineFeature.get_Value(num1).ToString());
                string str3 = "";
                if (str1 != "")
                {
                    str3 = str1;
                }
                if (str2 != "")
                {
                    str3 = str2;
                }
                this.m_commonDistAls.m_dDiameter = this.m_commonDistAls.GetDiameterFromString(str3.Trim());
                IEdgeFeature edgeFeature = (IEdgeFeature)lineFeature;
                this.m_commonDistAls.m_nBaseLineFromID = edgeFeature.FromJunctionEID;
                this.m_commonDistAls.m_nBaseLineToID   = edgeFeature.ToJunctionEID;
                this.btAnalyse.Enabled             = this.m_commonDistAls.m_pBaseLine != null;
                this.chitAnalyse_0.PipeLayer_Class = lineFeature.Class as IFeatureClass;
                this.chitAnalyse_0.BaseLine_OID    = lineFeature.OID;
                _baseLayerInfo = pipeLine;
            }
            else
            {
                MessageBox.Show("所选择的管线多于一条,或者不是管线!");
            }
        }