Esempio n. 1
0
        private void method_6(IGeometricNetwork geometricNetwork)
        {
            INetwork        network        = geometricNetwork.Network;
            IUtilityNetwork utilityNetwork = (IUtilityNetwork)network;
            IEnumNetEID     enumNetEID     = network.CreateNetBrowser((esriElementType)2);
            IEIDHelper      eIDHelperClass = new EIDHelper();

            eIDHelperClass.GeometricNetwork           = (geometricNetwork);
            eIDHelperClass.DisplayEnvelope            = (null);
            eIDHelperClass.OutputSpatialReference     = (null);
            eIDHelperClass.ReturnFeatures             = (false);
            eIDHelperClass.ReturnGeometries           = (true);
            eIDHelperClass.PartialComplexEdgeGeometry = (true);
            IEnumEIDInfo enumEIDInfo = eIDHelperClass.CreateEnumEIDInfo(enumNetEID);

            enumEIDInfo.Reset();
            long num  = (long)enumEIDInfo.Count;
            int  num2 = 0;

            while ((long)num2 < num)
            {
                IEIDInfo          iEIDInfo          = enumEIDInfo.Next();
                int               eID               = iEIDInfo.EID;
                IGeometry         geometry          = iEIDInfo.Geometry;
                esriFlowDirection esriFlowDirection = this.method_7(geometry);
                utilityNetwork.SetFlowDirection(eID, esriFlowDirection);
                num2++;
            }
        }
Esempio n. 2
0
        private void method_5(IGeometricNetwork geometricNetwork)
        {
            INetwork        network        = geometricNetwork.Network;
            IUtilityNetwork utilityNetwork = (IUtilityNetwork)network;
            IEnumNetEID     enumNetEID     = network.CreateNetBrowser((esriElementType)2);
            IEIDHelper      eIDHelperClass = new EIDHelper();

            eIDHelperClass.GeometricNetwork           = (geometricNetwork);
            eIDHelperClass.DisplayEnvelope            = (null);
            eIDHelperClass.OutputSpatialReference     = (null);
            eIDHelperClass.ReturnFeatures             = (true);
            eIDHelperClass.ReturnGeometries           = (true);
            eIDHelperClass.PartialComplexEdgeGeometry = (true);
            IEnumEIDInfo enumEIDInfo = eIDHelperClass.CreateEnumEIDInfo(enumNetEID);

            enumEIDInfo.Reset();
            long num  = (long)enumEIDInfo.Count;
            int  num2 = 0;

            while ((long)num2 < num)
            {
                IEIDInfo iEIDInfo = enumEIDInfo.Next();
                int      eID      = iEIDInfo.EID;
                IFeature feature  = iEIDInfo.Feature;
                int      num3     = feature.Fields.FindField("流向");
                if (num3 < 0)
                {
                    utilityNetwork.SetFlowDirection(eID, (esriFlowDirection)1);
                }
                if (Convert.ToBoolean(feature.get_Value(num3)))
                {
                    utilityNetwork.SetFlowDirection(eID, (esriFlowDirection)2);
                }
                else
                {
                    utilityNetwork.SetFlowDirection(eID, (esriFlowDirection)1);
                }
                num2++;
            }
        }
        private static void ProfileGetRelatedElevData(IApplication app, List<ProfileGraphDetails> ProfileGraph, IGeometricNetwork pGeometricNet,
                  IEnumNetEID pResultEdges, IEnumNetEID pResultJunctions, int CurrentDetail,
                  ref IFeatureLayer pFLManhole, ref IFeatureLayer pFLMain, ref IFeatureLayer pFLTap)
        {
            List<mainDetails> SewerColMains = null;
            List<manholeDetails> SewerColManholes = null;
            List<tapDetails> SewerColTap = null;

            IEIDHelper pEIDHelperEdges = null;
            IEnumEIDInfo pEnumEIDInfoEdges = null;

            IEIDHelper pEIDHelperJunctions = null;
            IEnumEIDInfo pEnumEIDInfoJunctions = null;

            IPolyline pPolyline = null;
            IPointCollection pPtColl = null;

            IEIDInfo pEIDInfo = null;
            IPoint pNewPt = null;
            ISegmentCollection pSegColl = null;
            IMSegmentation pMSegmentation = null;
            IMAware pMAware = null;

            IPointCollection pPtCollection = null;
            IEnumVertex pEnumVertex;

            IHitTest pHtTest = null;
            IPoint pHitPntOne = null;
            IPoint pHitPntTwo = null;
            IFeature pFeature = null;
            Hashtable pFeatureAdded = null;
            mainDetails mainDet = null;

            IEdgeFeature pEdge = null;

            IPoint pGeoOne = null;
            IPoint pGeoTwo = null;
            IField pFld = null;
            IJunctionFeature pJunc = null;
            tapDetails tapDet = null;
            manholeDetails manDet = null;
            IFeatureLayer pFl = null;
            ISpatialFilter pSpatFilt = null;
            IFeatureCursor pFC = null;

            try
            {

                SewerColMains = new List<mainDetails>();
                SewerColManholes = new List<manholeDetails>();
                SewerColTap = new List<tapDetails>();

                pEIDHelperEdges = new EIDHelper();
                pEIDHelperEdges.GeometricNetwork = pGeometricNet;
                pEIDHelperEdges.ReturnFeatures = true;

                pEIDHelperEdges.ReturnGeometries = true;
                pEIDHelperEdges.PartialComplexEdgeGeometry = true;
                pEnumEIDInfoEdges = pEIDHelperEdges.CreateEnumEIDInfo(pResultEdges);

                pEnumEIDInfoEdges.Reset();  //edges

                pEIDHelperJunctions = new EIDHelperClass();
                pEIDHelperJunctions.GeometricNetwork = pGeometricNet;
                pEIDHelperJunctions.ReturnFeatures = true;
                pEIDHelperJunctions.ReturnGeometries = true;
                pEIDHelperJunctions.PartialComplexEdgeGeometry = true;
                pEnumEIDInfoJunctions = pEIDHelperJunctions.CreateEnumEIDInfo(pResultJunctions);
                pEnumEIDInfoJunctions.Reset();// junctions

                pPolyline = new PolylineClass();
                pPolyline.SpatialReference = (pFLMain as IGeoDataset).SpatialReference;

                pPtColl = (IPointCollection)pPolyline;  //QI

                for (int i = 0; i < pEnumEIDInfoJunctions.Count; i++)
                {

                    pEIDInfo = pEnumEIDInfoJunctions.Next();
                    pNewPt = (IPoint)pEIDInfo.Geometry;

                    pPtColl.AddPoint(pNewPt);

                }

                pSegColl = (ISegmentCollection)pPolyline;

                pPolyline.Densify(50, 0.01);

                pMAware = (IMAware)pPolyline;//'QI
                pMAware.MAware = true;
                pMSegmentation = (IMSegmentation)pPolyline;
                // get the M values, put the distance in m, 0 to Length
                pMSegmentation.SetMsAsDistance(false);

                pPtCollection = (IPointCollection)pPolyline;

                pEnumVertex = pPtCollection.EnumVertices;
                pEnumVertex.Reset();

                pHtTest = pPolyline as IHitTest;

                pHitPntOne = new PointClass();
                pHitPntTwo = new PointClass();
                double pHitDistOne = -1;
                double pHitDistTwo = -1;
                int pHitPrtOne = -1;
                int pHitPrtTwo = -1;
                int pHitSegOne = -1;
                int pHitSegTwo = -1;
                bool pHitSideOne = false;
                bool pHitSideTwo = false;

                pFeatureAdded = new Hashtable();

                pEnumEIDInfoEdges.Reset();  //edges
                int intUpStreamFld = pFLMain.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Line_UpStreamElevationField);
                int intDownStreamFld = pFLMain.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Line_DownStreamElevationField);
                if (intDownStreamFld < 0)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19c") + ProfileGraph[CurrentDetail].Line_DownStreamElevationField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19b"));
                }
                if (intUpStreamFld < 0)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19d") + ProfileGraph[CurrentDetail].Line_UpStreamElevationField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19b"));
                }
                for (int i = 0; i < pResultEdges.Count; i++)
                {
                    pEIDInfo = pEnumEIDInfoEdges.Next();
                    pFeature = pEIDInfo.Feature;
                    if (((IDataset)pFeature.Class).Name != ((IDataset)pFLMain.FeatureClass).Name)
                        continue;
                    if (pFeatureAdded.ContainsValue(pFeature.OID))
                        continue;

                    mainDet = new mainDetails();

                    pEdge = (IEdgeFeature)pFeature;

                    pGeoOne = (IPoint)pEdge.FromJunctionFeature.get_OriginalGeometryForJunctionElement(0);
                    pGeoTwo = (IPoint)pEdge.ToJunctionFeature.get_OriginalGeometryForJunctionElement(0);

                    pFeature = ((IFeatureClass)pFeature.Class).GetFeature(pFeature.OID);

                    bool bHitOne = pHtTest.HitTest(pGeoOne, .1,
                                            esriGeometryHitPartType.esriGeometryPartVertex,
                                            pHitPntOne, ref pHitDistOne, ref pHitPrtOne, ref pHitSegOne, ref pHitSideOne);
                    bool bHitTwo = pHtTest.HitTest(pGeoTwo, .1,
                                   esriGeometryHitPartType.esriGeometryPartVertex,
                                   pHitPntTwo, ref pHitDistTwo, ref pHitPrtTwo, ref pHitSegTwo, ref pHitSideTwo);
                    if (bHitOne && bHitTwo)
                    {
                        if (pHitPntOne.M < pHitPntTwo.M)
                        {
                            mainDet.UpM = pHitPntOne.M;
                            mainDet.DownM = pHitPntTwo.M;
                            if (intUpStreamFld > 0)
                            {
                                if (pFeature.get_Value(intUpStreamFld).ToString() != "")
                                {
                                    mainDet.UpElev = Convert.ToDouble(pFeature.get_Value(intUpStreamFld));
                                }
                                else
                                    mainDet.UpElev = -9999;
                            }
                            else
                                mainDet.UpElev = -9999;

                            if (intDownStreamFld > 0)
                            {
                                if (pFeature.get_Value(intDownStreamFld).ToString() != "")
                                {
                                    mainDet.DownElev = Convert.ToDouble(pFeature.get_Value(intDownStreamFld));
                                }
                                else
                                    mainDet.DownElev = -9999;
                            }
                            else
                                mainDet.DownElev = -9999;
                        }
                        else
                        {
                            mainDet.DownM = pHitPntOne.M;
                            mainDet.UpM = pHitPntTwo.M;
                            if (intUpStreamFld > 0)
                            {
                                if (pFeature.get_Value(intUpStreamFld) != null && pFeature.get_Value(intUpStreamFld).ToString() != "")
                                {
                                    mainDet.DownElev = Convert.ToDouble(pFeature.get_Value(intUpStreamFld));
                                }
                                else
                                    mainDet.DownElev = -9999;
                            }
                            else
                                mainDet.DownElev = -9999;

                            if (intDownStreamFld > 0)
                            {
                                if (pFeature.get_Value(intDownStreamFld) != null && pFeature.get_Value(intDownStreamFld).ToString() != "")
                                {
                                    mainDet.UpElev = Convert.ToDouble(pFeature.get_Value(intDownStreamFld));
                                }
                                else
                                    mainDet.UpElev = -9999;
                            }
                            else
                                mainDet.UpElev = -9999;

                        }
                        string label = "";
                        for (int l = 0; l < ProfileGraph[CurrentDetail].Line_Labels.Length; l++)
                        {
                            if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_Labels[l]) > 0)
                            {
                                int fldIdx = pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_Labels[l]);

                                pFld = pFeature.Fields.get_Field(fldIdx);

                                if (pFeature.get_Value(fldIdx) != null)
                                {
                                    if (label == "")
                                    {
                                        label = Globals.GetDomainDisplay(pFeature.get_Value(fldIdx), pFeature, pFld);
                                    }
                                    else
                                    {

                                        label = label + "\r\n" + Globals.GetDomainDisplay(pFeature.get_Value(fldIdx), pFeature, pFld);

                                    }
                                }
                            }
                        }

                        mainDet.Label = label;

                    }

                    if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_IDField) > 0)
                    {
                        if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_IDField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_IDField)).ToString() != "")
                        {
                            mainDet.MainID = Convert.ToString(pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_IDField)));
                        }
                        else
                            mainDet.MainID = "Unk";
                    }
                    else
                        mainDet.MainID = "Unk";

                    pFeatureAdded.Add(pFeature.OID, pFeature.OID);
                    SewerColMains.Add(mainDet);

                }

                pFeatureAdded = new Hashtable();

                pEnumEIDInfoJunctions.Reset();
                for (int i = 0; i < pEnumEIDInfoJunctions.Count; i++)
                {

                    pEIDInfo = pEnumEIDInfoJunctions.Next();
                    pFeature = pEIDInfo.Feature;
                    if (pFLTap != null)
                    {
                        if (((IDataset)pFeature.Class).Name == ((IDataset)pFLTap.FeatureClass).Name)
                        {
                            pJunc = (IJunctionFeature)pFeature;
                            pFeature = ((IFeatureClass)pFeature.Class).GetFeature(pFeature.OID);
                            pHitPntOne = new PointClass();
                            bool bHit = pHtTest.HitTest(pFeature.Shape as IPoint, .1,
                                                    esriGeometryHitPartType.esriGeometryPartVertex,
                                                    pHitPntOne, ref pHitDistOne, ref pHitPrtOne, ref pHitSegOne, ref pHitSideOne);

                            if (bHit)
                            {
                                tapDet = new tapDetails();

                                tapDet.M = pHitPntOne.M;

                                if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_IDField) > 0)
                                {
                                    if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_IDField)) != null &&
                                        pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_IDField)).ToString() != "")
                                    {
                                        tapDet.tapID = pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_IDField)).ToString();
                                    }
                                    else
                                        tapDet.tapID = "Unk";
                                }
                                else
                                    tapDet.tapID = "Unk";

                                string label = "";
                                for (int l = 0; l < ProfileGraph[CurrentDetail].PointAlong_Labels.Length; l++)
                                {
                                    if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_Labels[l]) > 0)
                                    {
                                        int fldIdx = pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_Labels[l]);

                                        pFld = pFeature.Fields.get_Field(fldIdx);

                                        if (pFeature.get_Value(fldIdx) != null)
                                        {
                                            if (label == "")
                                            {
                                                label = Globals.GetDomainDisplay(pFeature.get_Value(fldIdx), pFeature, pFld);
                                            }
                                            else
                                            {

                                                label = label + "\r\n" + Globals.GetDomainDisplay(pFeature.get_Value(fldIdx), pFeature, pFld);

                                            }
                                        }
                                    }
                                }

                                tapDet.tapLabel = label;
                                SewerColTap.Add(tapDet);
                            }

                        }
                    }
                    if (((IDataset)pFeature.Class).Name == ((IDataset)pFLManhole.FeatureClass).Name)
                    {
                        if (pFeatureAdded.ContainsValue(pFeature.OID))
                            continue;

                        pJunc = (IJunctionFeature)pFeature;
                        pFeature = ((IFeatureClass)pFeature.Class).GetFeature(pFeature.OID);
                        pHitPntOne = new PointClass();
                        bool bHit = pHtTest.HitTest(pFeature.Shape as IPoint, .1,
                                                esriGeometryHitPartType.esriGeometryPartVertex,
                                                pHitPntOne, ref pHitDistOne, ref pHitPrtOne, ref pHitSegOne, ref pHitSideOne);

                        if (bHit)
                        {
                            manDet = new manholeDetails();

                            manDet.M = pHitPntOne.M;

                            if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_TopElevationField) > 0)
                            {
                                if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_TopElevationField)) != null &&
                                    pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_TopElevationField)).ToString() != "")
                                {
                                    manDet.Top = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_TopElevationField));
                                }
                                else
                                    manDet.Top = -9999;
                            }
                            else
                                manDet.Top = -9999;

                            if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationField) > 0)
                            {
                                if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationField)) != null &&
                                    pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationField)).ToString() != "")
                                {
                                    manDet.Bottom = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationField));
                                    if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField) > 0)
                                    {
                                        if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField)) != null &&
                                            pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField)).ToString() != "")
                                        {
                                            if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField)).ToString().ToUpper() == "INVERT")
                                                manDet.Bottom = manDet.Top - (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField));
                                        }
                                    }

                                }
                                else
                                    manDet.Bottom = -9999;
                            }
                            else
                                manDet.Bottom = -9999;

                            //if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertElevationField) > 0)
                            //{
                            //    if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertElevationField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertElevationField)).ToString() != "")
                            //    {
                            //        manDet.InvertElev = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertElevationField));
                            //    }
                            //    else
                            //        manDet.InvertElev = -9999;
                            //}
                            //else
                            //    manDet.InvertElev = -9999;

                            //if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertField) > 0)
                            //{
                            //    if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertField)).ToString() != "")
                            //    {
                            //        manDet.Invert = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertField));
                            //    }
                            //    else
                            //        manDet.Invert = -9999;
                            //}
                            //else
                            //    manDet.Invert = -9999;

                            //if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_RimElevationField) > 0)
                            //{
                            //    if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_RimElevationField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_RimElevationField)).ToString() != "")
                            //    {
                            //        manDet.Rim = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_RimElevationField));
                            //    }
                            //    else
                            //        manDet.Rim = -9999;
                            //}
                            //else
                            //    manDet.Rim = -9999;

                            if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_IDField) > 0)
                            {
                                if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_IDField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_IDField)).ToString() != "")
                                {
                                    manDet.ManholeID = pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_IDField)).ToString();
                                }
                                else
                                    manDet.ManholeID = "UNK";
                            }
                            else
                                manDet.ManholeID = "UNK";

                            pFeatureAdded.Add(pFeature.OID, pFeature.OID);
                            SewerColManholes.Add(manDet);
                        }
                    }

                }
                if (ProfileGraph[CurrentDetail].Lines_Along != null)
                {
                    if (ProfileGraph[CurrentDetail].Lines_Along.Length > 0)
                    {

                        pSpatFilt = new SpatialFilterClass();
                        pSpatFilt.Geometry = pPolyline;
                        pSpatFilt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                        for (int i = 0; i < ProfileGraph[CurrentDetail].Lines_Along.Length; i++)
                        {
                            bool FCorLayerTemp = true;
                            pFl = (IFeatureLayer)Globals.FindLayer(app, ProfileGraph[CurrentDetail].Lines_Along[i].Layer_Name, ref FCorLayerTemp);
                            if (pFl != null)
                            {

                                intUpStreamFld = pFl.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Lines_Along[i].Line_UpStreamElevationField);
                                intDownStreamFld = pFl.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Lines_Along[i].Line_DownStreamElevationField);
                                int intIdFld = pFl.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Lines_Along[i].Line_IDField);
                                if (intIdFld < 0)
                                {
                                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19f") + ProfileGraph[CurrentDetail].Lines_Along[i].Line_IDField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19e") + ProfileGraph[CurrentDetail].Lines_Along[i].Layer_Name);
                                }
                                if (intDownStreamFld < 0)
                                {
                                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19c") + ProfileGraph[CurrentDetail].Lines_Along[i].Line_DownStreamElevationField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19e") + ProfileGraph[CurrentDetail].Lines_Along[i].Layer_Name);
                                }
                                if (intUpStreamFld < 0)
                                {
                                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19d") + ProfileGraph[CurrentDetail].Lines_Along[i].Line_UpStreamElevationField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19e") + ProfileGraph[CurrentDetail].Lines_Along[i].Layer_Name);
                                }

                                pSpatFilt.GeometryField = pFl.FeatureClass.ShapeFieldName;

                                pFC = pFl.Search(pSpatFilt, true);

                            }
                        }
                    }
                }

                ProfileCreateGraph(app, ProfileGraph, pPolyline, SewerColMains, SewerColManholes, SewerColTap, CurrentDetail);

            }
            catch (Exception Ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + "ProfileGetRelatedSewerElevData " + Ex.Message);
            }
            finally
            {

                SewerColMains = null;
                SewerColManholes = null;
                SewerColTap = null;

                pEIDHelperEdges = null;
                pEnumEIDInfoEdges = null;

                pEIDHelperJunctions = null;
                if (pEnumEIDInfoJunctions != null)
                    Marshal.ReleaseComObject(pEnumEIDInfoJunctions);

                pEnumEIDInfoJunctions = null;

                pPolyline = null;
                pPtColl = null;

                pEIDInfo = null;
                pNewPt = null;
                pSegColl = null;
                pMSegmentation = null;
                pMAware = null;

                pPtCollection = null;
                pEnumVertex = null;

                pHtTest = null;
                pHitPntOne = null;
                pHitPntTwo = null;
                pFeature = null;
                pFeatureAdded = null;
                mainDet = null;

                pEdge = null;

                pGeoOne = null;
                pGeoTwo = null;
                pFld = null;
                pJunc = null;
                tapDet = null;
                manDet = null;
                pFl = null;
                pSpatFilt = null;
                if (pFC != null)
                    Marshal.ReleaseComObject(pFC);

                pFC = null;

            }
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
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);
                    }
                }
            }
        }