Пример #1
0
        //根据多段线和阀门数组创建高程剖面 
        public static void ProfileCreateGraph(MainFrm pMainFrm, IPolyline pPolyline, IArray pSewerElevArray)
        {
            AxMapControl axMap = pMainFrm.getMapControl();
            IZ pPolylineZ = pPolyline as IZ;
            IRasterLayer pRasterLyr = FindRasterLayer("Elevation", pMainFrm);
            //获得表面进行插值
            ISurface pSurface = GetSurface(pRasterLyr);
            //创建Polyline z-ware;
            IZAware pZAwareLineZ = pPolyline as IZAware;
            pZAwareLineZ.ZAware = true;
            //'* work around for InterpolateFromSurface sometimes flipping polyline
            IPoint pPtOrigFrom = pPolyline.FromPoint;
            IPoint pPtOrigTo = pPolyline.ToPoint;
            //添加Z值到多边形上
            pPolylineZ.InterpolateFromSurface(pSurface);
            if (pPolyline.FromPoint.X != pPtOrigFrom.X || pPolyline.FromPoint.Y != pPtOrigFrom.Y)
                pPolyline.ReverseOrientation();
            //添加M值到线上
            IMSegmentation pMSegmentation = pPolyline as IMSegmentation;
            IMAware pMAware = pPolyline as IMAware;
            pMAware.MAware = true;
            pMSegmentation.SetMsAsDistance(false);
            //创建表格
            ITable pTable = ProfileCreateTable();
            int i=0;
            if (pTable != null)
            {
                //在图层列表控件中要确保该表格还不存在,如果存在则删除它
                IStandaloneTableCollection pStandAloneTabColl = axMap.ActiveView.FocusMap as IStandaloneTableCollection;
                for ( i = 0; i<=pStandAloneTabColl.StandaloneTableCount - 1; i++)
                {
                    if (pStandAloneTabColl.get_StandaloneTable(i).Name == "xxprofiletable")
                        pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.get_StandaloneTable(i));
                }
                //创建一个新的独立表,并把它添加到地图集合中
                IStandaloneTable pStandAloneTab = new StandaloneTableClass();
                pStandAloneTab.Table = pTable;
                pStandAloneTabColl = axMap.ActiveView.FocusMap as IStandaloneTableCollection;
                pStandAloneTabColl.AddStandaloneTable(pStandAloneTab);
                pTable = pStandAloneTab as ITable;
                                //为两个字段设置别名 
                ITableFields pTableFields = pStandAloneTab as ITableFields;
                IFieldInfo pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("Z"));
                pFieldInfo.Alias = "Ground Elevation";
                pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("SewerElev"));
                pFieldInfo.Alias = "Sewer Line Elevation";
                //为表格获得一个插入光标 
                ICursor pCursor=pTable.Insert(true);
                IRowBuffer pRowBuff;
                //
                IPointCollection pPtCollection = pPolyline as IPointCollection;
                IEnumVertex pEnumVertex = pPtCollection.EnumVertices;
                pEnumVertex.Reset();
                IPoint pPT;
                 int iPartIndex;
                int iVertexIndex;
                  i = 0;
                //添加节点XYZ到新表格中
                pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex);
                while (pPT != null)
                {
                    pRowBuff = pTable.CreateRowBuffer();
                    pRowBuff.set_Value(pRowBuff.Fields.FindField("X"),pPT.X);
                    pRowBuff.set_Value(pRowBuff.Fields.FindField("Y"),pPT.Y);
                    pRowBuff.set_Value(pRowBuff.Fields.FindField("Z"),pPT.Z);
                    pRowBuff.set_Value( pRowBuff.Fields.FindField("M"),pPT.M);
                    pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), Convert.ToDouble(pSewerElevArray.get_Element(i)));
                    pCursor.InsertRow(pRowBuff);
                    pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex);
                    i = i + 1;
                }
                pCursor.Flush();
                pCursor = null;
                pCursor = pTable.Search(null, false);
                IQueryFilter pQueryFilter = new QueryFilterClass();
                pQueryFilter.WhereClause = "SewerElev <> -99";
                ICursor pCursorSewerElev = pTable.Search(pQueryFilter, false);

                pCursor = null;
                pCursor = pTable.Update(null, false);
                pRowBuff = pCursor.NextRow();
                double m = 0;
                double Mmin=0;
                double Mmax=0;
                double deltaM=0;
                double deltaSewerElev=0;
                double sewerelev=0;
                double newZ=0;
                int j = 0;
                double minSewerElev=0;
                double maxSewerElev=0;
                IRow pRowSewerElev;
                while (pRowBuff != null)
                {
                    if (Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("SewerElev"))) == -99)
                    {
                        m = Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("M")));
                        newZ = (((m - Mmin) / deltaM) * deltaSewerElev) + sewerelev;
                        pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), newZ);
                        pCursor.UpdateRow(pRowBuff as IRow);
                    }
                    else
                    {
                        if (j == 0)
                        {
                            pRowSewerElev = pCursorSewerElev.NextRow();
                            minSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev")));
                            Mmin = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")));
                            pRowSewerElev = pCursorSewerElev.NextRow();
                            maxSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev")));
                            Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")));
                        }
                        else
                        {
                            pRowSewerElev = pCursorSewerElev.NextRow();
                            if (pRowSewerElev != null)
                            {
                                minSewerElev = maxSewerElev;
                                Mmin = Mmax;
                                maxSewerElev =Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev")));
                                Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")));
                            }
                        }
                        deltaSewerElev = maxSewerElev - minSewerElev;
                        deltaM = Mmax - Mmin;
                        sewerelev = minSewerElev;
                        j = j + 1;
                    }
                    pRowBuff = pCursor.NextRow() as IRowBuffer;
                }
                pCursor.Flush();    
                //从表格中创建图形
                m_SewerElevStructArray = new ArrayClass();
               
                pCursor = null;
                pCursor = pTable.Search(null, false);
                pRowSewerElev = null;
                pRowSewerElev = pCursor.NextRow();
                while (pRowSewerElev != null)
                {
                    clsProfileStruct pProfileDataStruct = new clsProfileStruct();
                    pProfileDataStruct.M = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M")));
                    pProfileDataStruct.Z = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Z")));
                    pProfileDataStruct.dSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Sewerelev")));
                    m_SewerElevStructArray.Add(pProfileDataStruct);
                    pRowSewerElev = pCursor.NextRow();
                }

                frmDrawProfile frmDrawProfile1 = new frmDrawProfile(m_SewerElevStructArray);
                frmDrawProfile1.Show();
            }
        }
Пример #2
0
        //绘制HATCH
        public static void HatchDraw(MainFrm pMainFrm,ISimpleLineSymbol pHatchSymMajor, ISimpleLineSymbol pHatchSymMinor, ITextSymbol pTxtSym, IFeatureLayer pFeatLayer, bool bEnds, bool bEndsOnly, double dHatchLen, double dTxtInterval, double dHatchOffset, double dMajorAngle, bool bOverRideMajor, string graphicslayername)
        {
            AxMapControl axMap = pMainFrm.getMapControl();
            //设置图形图层为SEWER TV测绘图层
            IFeatureCursor pFeatCursor = pFeatLayer.Search(null, true);
            SetGraphicsLayer(pMainFrm, pFeatLayer.Name, graphicslayername);
            //设置SEWER TV测绘图形图层
            IGraphicsContainer pGraphicsContainer = axMap.ActiveView.FocusMap.ActiveGraphicsLayer as IGraphicsContainer;
            //清除图形图层
            pGraphicsContainer.DeleteAllElements();

            IFeature pFeature = pFeatCursor.NextFeature();
            IPolyline pMajorHatchPL = new PolylineClass();
            IPolyline pMinorHatchPL = new PolylineClass();
            IPolyline pPL;
            IMAware pPLM;
            IMCollection pMColl;
            IGeometryCollection pGeomColl;
            ILineElement pLineElement;
            IElement pElement = null; 
            int cnt;
            IPath pPath;
            string txt;
            double txtlen;
            IPath pTxtPath;
            double angle;
            IPoint pTxtPt;
            ISegmentCollection pSC;
            ISegment pSeg;
            ISegmentM pSegM;
            double m1=0;
            double m2=0;
            IPoint pFromPt;
            IMarkerSymbol pMSym;
            IMask pMask;
            ITextElement pTextElement;
            ISegmentCollection pSegment;
            ISegmentCollection pPolyline;
            while (pFeature != null)
            {
                pPL = pFeature.Shape as IPolyline ;
                pPLM = pPL as IMAware;
                if (pPLM.MAware)
                {
                    if (bEndsOnly)
                    {
                        MakeHatchesEndsOnly(pPL, bEnds, pMajorHatchPL, pMinorHatchPL, dHatchLen, dTxtInterval, dHatchOffset);
                    }
                    else
                    {
                         
                    }
                    // Draw the major hatches if they are lines
                    if (pHatchSymMajor is ILineSymbol)
                    {
                        pLineElement = new LineElementClass();
                        pLineElement.Symbol = pHatchSymMajor ;
                        pElement = pLineElement as IElement;
                        pElement.Geometry = pMajorHatchPL as IGeometry ;
                        pGraphicsContainer.AddElement(pElement, 0);
                    }
                    // Draw the major hatches if they are markers and the text...
                    pGeomColl = pMajorHatchPL as IGeometryCollection;
                    cnt = pGeomColl.GeometryCount - 1;
                    for (int j = 0; j <= cnt; j++)
                    {
                        pPath = pGeomColl.get_Geometry(j) as IPath ;
                        if (bOverRideMajor)
                            angle = dMajorAngle;
                        else
                            angle = GetAngle(pPath) + dMajorAngle;
                        pSC = pPath as ISegmentCollection;
                        pSeg = pSC.get_Segment(0);
                        pSegM = pSeg as ISegmentM;
                        txt = Convert.ToString(Math.Round(m1, 1));
                        txtlen = pTxtSym.Size;
                        angle = GetAngle(pPath as ICurve);
                        if (ShouldFlip(angle))
                        {
                            pTxtPath = MakeTextPath(pPath, txtlen * 2);
                            angle += 180;
                            pTxtSym.RightToLeft = false;
                            pTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                            pTxtSym.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;

                        }
                        else
                        {
                            angle = angle;
                            pTxtPath = MakeTextPath(pPath, txtlen);
                            pTxtSym.RightToLeft = false;
                            pTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                            pTxtSym.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                        }
                        pTxtSym.Angle = angle;
                        //为文本创建MASK,如果没有符号,将作为背景
                        pMask = pTxtSym as IMask;
                        pMask.MaskSize = 2;
                        pMask.MaskStyle = esriMaskStyle.esriMSHalo;

                        pTextElement = new TextElementClass();
                        pTextElement.Symbol = pTxtSym;
                        pTextElement.Text = txt + " ";
                        pElement = pTextElement as IElement ;

                        pSegment = pTxtPath as ISegmentCollection ;
                        pPolyline = new PolylineClass();
                        pPolyline.AddSegmentCollection(pSegment);
                        pElement.Geometry = pPolyline as IGeometry ;
                        pGraphicsContainer.AddElement(pElement, 0);
                    }
                }
                pFeature = pFeatCursor.NextFeature();
            }

        }
Пример #3
0
        public static void SetGraphicsLayer(MainFrm pMainFrm,string strFeatLayerName, string strGraphicsLayerName)
        {
            try
            {
                AxMapControl axMap = pMainFrm.getMapControl();
                IGraphicsLayer pGraphicsLayer=null;
                ICompositeGraphicsLayer pComGraphicsLayer;
                ICompositeLayer pComLayer;
                IFeatureLayer pFeatLayer;
                bool found = false;
                if (strGraphicsLayerName.ToUpper() == "<DEFAULT>")
                {
                    pGraphicsLayer = axMap.ActiveView.FocusMap.BasicGraphicsLayer;
                }
                else
                {
                    pComGraphicsLayer = axMap.ActiveView.FocusMap.BasicGraphicsLayer as ICompositeGraphicsLayer ;
                    pComLayer = pComGraphicsLayer as ICompositeLayer;
                    for (int i = 0; i <= pComLayer.Count - 1; i++)
                    {
                        if (pComLayer.get_Layer(i).Name == strGraphicsLayerName)
                        {
                            //layer is found so set it as the graphics layer
                            pGraphicsLayer = pComGraphicsLayer.FindLayer(strGraphicsLayerName);
                            found = true;
                            break;
                        }
                    }
                    //如果是图形图层不能被找到,将创建它
                    if ((found==false)&& strFeatLayerName!="")
                    {
                        pFeatLayer = Utility.FindFeatLayer(strFeatLayerName, pMainFrm);
                        pComGraphicsLayer = axMap.ActiveView.FocusMap.BasicGraphicsLayer as ICompositeGraphicsLayer ;
                        pGraphicsLayer = pComGraphicsLayer.AddLayer(strGraphicsLayerName, pFeatLayer);
                        pGraphicsLayer.UseAssociatedLayerVisibility = true;
                    }
                }
                pGraphicsLayer.Activate(axMap.ActiveView.ScreenDisplay);
                ILayer pLayer = pGraphicsLayer as ILayer;
                axMap.ActiveView.FocusMap.ActiveGraphicsLayer = pLayer;
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
Пример #4
0
        public static void ProfileFindPath(MainFrm pMainFrm, IArray pNetFlagArray, IGeometricNetwork pGeoNetwork)
        {
            try
            {
                AxMapControl axMap = pMainFrm.getMapControl();
                IEnumNetEID m_ipEnumNetEID_Junctions, m_ipEnumNetEID_Edges;//用来存放搜索结果的Junctions和Edges
                IJunctionFlag[] pArrayJFlag = new IJunctionFlag[2];
                pArrayJFlag[0] = pNetFlagArray.get_Element(0) as IJunctionFlag;
                pArrayJFlag[1] = pNetFlagArray.get_Element(1) as IJunctionFlag;
                ITraceFlowSolverGEN ipTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;

                //get the inetsolver interface
                INetSolver ipNetSolver = ipTraceFlowSolver as INetSolver;
                ipNetSolver.SourceNetwork = pGeoNetwork.Network;
                
                ipTraceFlowSolver.PutJunctionOrigins(ref pArrayJFlag);

                ipTraceFlowSolver.TraceIndeterminateFlow = false;

                object[] totalCost = new object[1];


                //ipTraceFlowSolver.FindSource(esriFlowMethod.esriFMUpstream,esriShortestPathObjFn.esriSPObjFnMinSum,out m_ipEnumNetEID_Junctions,out m_ipEnumNetEID_Edges,1,ref totalCost);

                ipTraceFlowSolver.FindPath(esriFlowMethod.esriFMConnected,
                    esriShortestPathObjFn.esriSPObjFnMinMax,
                    out m_ipEnumNetEID_Junctions,
                    out m_ipEnumNetEID_Edges, 1, ref totalCost);
                //清除数组中的交叉点元素
                pNetFlagArray.RemoveAll();
                SpatialHelperFunction.pathToPolyline(pGeoNetwork, axMap.ActiveView, m_ipEnumNetEID_Edges);
  ProfileGetRelatedSewerElevData(pMainFrm,pGeoNetwork,m_ipEnumNetEID_Edges, m_ipEnumNetEID_Junctions  );
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
Пример #5
0
        //查看管线测绘视频资料
        public static void TVScansHatchRoutes(MainFrm pMainFrm)
        {
            IFeatureLayer pFeatTVSurveyLayer = Utility.FindFeatLayer("Sewer TV Surveys", pMainFrm);
            //创建文本符号
            ITextSymbol pTxtSymbol = new TextSymbolClass();
            IRgbColor pRgbColor = new RgbColorClass();
            pRgbColor.Red = 255;
            stdole.IFontDisp pFont = (stdole.IFontDisp)new stdole.StdFontClass();
            pFont.Name = "Arial";
            pFont.Bold = true;
            pTxtSymbol.Font = pFont;
            pTxtSymbol.Size = 13;
            pTxtSymbol.Angle = 0;
            pTxtSymbol.Color = pRgbColor as IColor;
            pTxtSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
            pTxtSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            //使用线符号测试
            ISimpleLineSymbol pHatchSymbol = new SimpleLineSymbolClass();
            pHatchSymbol.Color = pRgbColor as IColor;
            pHatchSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            pHatchSymbol.Width = 2;
            //使用线符号测试小的HATCH
            ISimpleLineSymbol pHatchSymbol2 = new SimpleLineSymbolClass();
            pHatchSymbol2.Style = esriSimpleLineStyle.esriSLSSolid;
            pHatchSymbol2.Color = pRgbColor as IColor;

            bool bEnds = true;
            bool bEndsOnly = true;
            double dHatchLen = 5;
            double dTxtInterval = 1;
            double dHatchOffset = 0;
            bool bOverRideMajor = false;
            double dMajorAngle = 0;
            string graphicslayername = "Sewer TV Surveys Graphics Layer";
            HatchDraw(pMainFrm, pHatchSymbol, pHatchSymbol2, pTxtSymbol, pFeatTVSurveyLayer, bEnds, bEndsOnly, dHatchLen, dTxtInterval, dHatchOffset, dMajorAngle, bOverRideMajor, graphicslayername);
            AxMapControl axMap = pMainFrm.getMapControl();
            axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

        }
Пример #6
0
        //上朔追踪查找管线涉及的地块
        public static void UpStreamFindParcels(MainFrm pMainFrm, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork)
        {
            try
            {
                AxMapControl axMap = pMainFrm.getMapControl();
                IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", pMainFrm);
                IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", pMainFrm);
                //从所选择的Sewer线特征中创建几何包
               
                IGeometryCollection pGeomBag = new GeometryBagClass();
                object missing = Type.Missing;
                int lEID;
                int iUserClassID;
                int iUserID;
                int iUserSubID;
                INetElements pNetElements = pGeoNetwork.Network as INetElements;
                pEnumResultEdges.Reset();
                IFeature pFeature;

                for (int j = 0; j <= pEnumResultEdges.Count - 1; j++)
                {
                    lEID = pEnumResultEdges.Next();
                    pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID);
                    pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID);
                    pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing);
                    // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString());
                }                                
                                //进行空间拓扑叠加操作以用于查找地块信息
                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry = pGeomBag as IGeometry ;
                pSpatialFilter.GeometryField = "Shape";
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
                                
                
                //获得交叉到的地块信息
                 IFeatureCursor pFeatCursor=pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false);
                //增加被选择的地块数据到地图的图形图层数据中
                ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass();
                ILayer pLayer = pComGraphicLayer as ILayer ;
                pLayer.Name = "受影响的地块";
                IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer;
                //增加所选择的地块到图形容器中
                ISimpleFillSymbol pSymFill=new SimpleFillSymbolClass();
                IFillSymbol pFillSymbol=pSymFill as IFillSymbol;
                IRgbColor pRgbColor=new RgbColorClass();
                pRgbColor.Red=0;
                pRgbColor.Green=200;
                pRgbColor.Blue=100;
                pFillSymbol.Color=pRgbColor as IColor;
                ICartographicLineSymbol pCartoLine=new CartographicLineSymbolClass();
                IRgbColor pRgbColor2=new RgbColorClass();
                pRgbColor2.Red=100;
                pRgbColor2.Green=200;
                pRgbColor2.Blue=100;
                pCartoLine.Width=2;
                pCartoLine.Color =pRgbColor2 as IColor;
                pFillSymbol.Outline=pCartoLine;
                //创建存放所有地块特征的数组
                IArray pFeatArray = new ArrayClass();
                pFeature=pFeatCursor.NextFeature();
                while (pFeature != null)
                {
                    IElement pPolyElement = new PolygonElementClass();
                    IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement;
                    pPolyElement.Geometry = pFeature.Shape;
                    pFillShapeElement.Symbol = pFillSymbol;
                    pGraphicContainer.AddElement(pPolyElement, 0);
                    pFeatArray.Add(pFeature);
                    pFeature = pFeatCursor.NextFeature();
                }
                axMap.AddLayer(pGraphicContainer as ILayer);
                axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);
                frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(pMainFrm,pFeatLayerParcels, pFeatArray);
                frmUpstreamCreateOwnerList1.Show();
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }

        }
Пример #7
0
        //////////////////////////////////进行剖面分析前设置交叉点小旗
        public static void ProfileSetJunctionFlag(MainFrm pMainFrm, ref IArray pNetFlagArray,IPoint pPoint, IGeometricNetwork pGeoNetwork)
        {
            
            try
            {
                AxMapControl axMap = pMainFrm.getMapControl();
                //清除地图的选择
                axMap.ActiveView.FocusMap.ClearSelection();
                INetElements pNetElements = pGeoNetwork.Network as INetElements;
                IPointToEID pPtToEID = new PointToEIDClass();
                int pJunctionID = 0;
                int iUserClassID;
                int iUserID;
                int iUserSubID;
                IPoint pLocation;

                pPtToEID.SourceMap = axMap.ActiveView.FocusMap;
                pPtToEID.GeometricNetwork = pGeoNetwork;
                pPtToEID.SnapTolerance = axMap.ActiveView.Extent.Envelope.Width / 100;
                pPtToEID.GetNearestJunction(pPoint, out pJunctionID, out pLocation);
                if (pJunctionID == 0)
                {
                    MessageBox.Show("没有查找相临近的点");
                }
                else
                {
                  
                    pNetElements.QueryIDs(pJunctionID, esriElementType.esriETJunction, out iUserClassID, out iUserID, out iUserSubID);
                    INetFlag ipNetFlag = new JunctionFlagClass();
                    ipNetFlag.UserClassID = iUserClassID;
                    ipNetFlag.UserID = iUserID;
                    ipNetFlag.UserSubID = iUserSubID;

                    IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass();
                    IRgbColor pRGBColor = new RgbColorClass();
                    pRGBColor.Red = 255;
                    pRGBColor.Green = 0;
                    pRGBColor.Blue = 0;
                    pMarkerSym.Color = pRGBColor;
                    pMarkerSym.Size = 20;
                    //绘制该点
                    IScreenDisplay pScreenDisplay = axMap.ActiveView.ScreenDisplay;
                    pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0);
                    pScreenDisplay.SetSymbol(pMarkerSym as ISymbol);
                    pScreenDisplay.DrawPoint(pLocation);
                    pScreenDisplay.FinishDrawing();
                    if (pLocation != null)
                    {
                        pNetFlagArray.Add(ipNetFlag);
                    }
                    if (pNetFlagArray.Count == 2)
                    {

                        //查找追踪结果
                        ProfileFindPath(pMainFrm, pNetFlagArray, pGeoNetwork);
                    }
                }
               
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }

        }
Пример #8
0
        //查找追踪的结果
        public static void FindStreamTraceResult(MainFrm pMainFrm,INetFlag ipNetFlag, IGeometricNetwork pGeoNetwork)
        {
            try
            {
                AxMapControl axMap = pMainFrm.getMapControl();
                IEnumNetEID m_ipEnumNetEID_Junctions, m_ipEnumNetEID_Edges;//用来存放搜索结果的Junctions和Edges
                IJunctionFlag[] pArrayJFlag = new IJunctionFlag[1];
                pArrayJFlag[0] = ipNetFlag as IJunctionFlag;
                ITraceFlowSolverGEN ipTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;

                //get the inetsolver interface
                INetSolver ipNetSolver = ipTraceFlowSolver as INetSolver;
                ipNetSolver.SourceNetwork = pGeoNetwork.Network;

                ipTraceFlowSolver.PutJunctionOrigins(ref pArrayJFlag);

                ipTraceFlowSolver.TraceIndeterminateFlow = false;

                object[] totalCost = new object[1];


                //ipTraceFlowSolver.FindSource(esriFlowMethod.esriFMUpstream,esriShortestPathObjFn.esriSPObjFnMinSum,out m_ipEnumNetEID_Junctions,out m_ipEnumNetEID_Edges,1,ref totalCost);

                ipTraceFlowSolver.FindFlowElements(esriFlowMethod.esriFMUpstream,
                    esriFlowElements.esriFEEdges,
                    out m_ipEnumNetEID_Junctions,
                    out m_ipEnumNetEID_Edges);


                SpatialHelperFunction.pathToPolyline(pGeoNetwork, axMap.ActiveView, m_ipEnumNetEID_Edges);
                UpStreamFindParcels(pMainFrm, m_ipEnumNetEID_Edges,pGeoNetwork);
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
Пример #9
0
        public static void UpStreamTrace(MainFrm pMainFrm,IPoint pPoint,IGeometricNetwork pGeoNetwork)
        {
            try
            {
                AxMapControl axMap = pMainFrm.getMapControl();
                //清除地图的选择
                axMap.ActiveView.FocusMap.ClearSelection();
                INetElements pNetElements = pGeoNetwork.Network as INetElements;
                IPointToEID pPtToEID = new PointToEIDClass();
                int pJunctionID=0;
                int iUserClassID;
                int iUserID;
                int iUserSubID;
                IPoint pLocation;
              
                pPtToEID.SourceMap = axMap.ActiveView.FocusMap;
                pPtToEID.GeometricNetwork = pGeoNetwork;
                pPtToEID.SnapTolerance = axMap.ActiveView.Extent.Envelope.Width / 100;
                pPtToEID.GetNearestJunction(pPoint,  out pJunctionID, out pLocation);
                if (pJunctionID == 0)
                {
                    MessageBox.Show("没有查找相临近的点");
                }
                else
                {
                    pNetElements.QueryIDs(pJunctionID, esriElementType.esriETJunction, out iUserClassID, out iUserID, out iUserSubID);
                    INetFlag ipNetFlag = new JunctionFlagClass();
                    ipNetFlag.UserClassID = iUserClassID;
                    ipNetFlag.UserID = iUserID;
                    ipNetFlag.UserSubID = iUserSubID;

                    IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass();
                    IRgbColor pRGBColor = new RgbColorClass();
                    pRGBColor.Red = 255;
                    pRGBColor.Green = 0;
                    pRGBColor.Blue = 0;
                    pMarkerSym.Color = pRGBColor;
                    pMarkerSym.Size = 20;
                    //创建新的Flag

                    IEdgeFlagDisplay pEdgeFlagDisplay = new EdgeFlagDisplayClass();
                    IFlagDisplay pFlagDisplay = pEdgeFlagDisplay as IFlagDisplay;
                    pFlagDisplay.Symbol = pMarkerSym as ISymbol;
                    pFlagDisplay.Geometry = pLocation;
                    pFlagDisplay.FeatureClassID = iUserClassID;
                    pFlagDisplay.FID = iUserID;
                    pFlagDisplay.SubID = iUserSubID;

                    //绘制该点
                    IScreenDisplay pScreenDisplay = axMap.ActiveView.ScreenDisplay;
                    pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0);
                    pScreenDisplay.SetSymbol(pMarkerSym as ISymbol);
                    pScreenDisplay.DrawPoint(pLocation as IGeometry);
                    pScreenDisplay.FinishDrawing();
                    //查找追踪结果
                    FindStreamTraceResult(pMainFrm, ipNetFlag, pGeoNetwork);
                }
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
Пример #10
0
 //////////////上朔追踪分析////////
 public static IFeatureLayer FindFeatLayer(string sLayerName, MainFrm pMainFrm)
 {
     AxMapControl axMap = pMainFrm.getMapControl();
     IFeatureLayer pFeatLayer;
     for (int i = 0; i <= axMap.ActiveView.FocusMap.LayerCount - 1; i++)
     {
         if (axMap.ActiveView.FocusMap.get_Layer(i) is IFeatureLayer)
         {
             pFeatLayer = axMap.ActiveView.FocusMap.get_Layer(i) as IFeatureLayer;
             if (pFeatLayer.Name == sLayerName)
             {
                 return pFeatLayer;
             }
         }
     }
     return null;
 }
Пример #11
0
        //----------------------上朔分析------------------------
       

        //-----------------///----------------------------------
		//打开特征数据并添加到地图中
		public static void AddFeatureLayer(MainFrm pMainFrm)
		{
			int startX,endX;
			string fileName;
			string shpDir,shpFile;
			object Missing = Type.Missing;	 

			OpenFileDialog openFileDialog1=new OpenFileDialog();
			openFileDialog1.Title="选择要添加的数据文件";
			openFileDialog1.InitialDirectory="c:\\temp";
			openFileDialog1.Filter="特征数据(*.Lyr, *.shp)|*.shp|栅格数据(*.Grid)|*.Grid|图像数据(*.img)|*.img";
			if(openFileDialog1.ShowDialog()==DialogResult.OK)
			{
				fileName=openFileDialog1.FileName;
				shpDir =fileName.Substring(0, fileName.LastIndexOf("\\")); 
				startX=fileName.LastIndexOf("\\");
				endX=fileName.Length;
				shpFile=fileName.Substring(startX+1,endX-startX-1);
                AxMapControl axMap = pMainFrm.getMapControl();
				if(openFileDialog1.FilterIndex==1)
				{
					IFeatureClass pFClass=Utility.OpenFeatureClassFromShapefile(shpDir,shpFile);
					IFeatureLayer pFeatLyr=new FeatureLayerClass();
                    pFeatLyr.FeatureClass=pFClass;
					pFeatLyr.Name=pFClass.AliasName;
					pFeatLyr.Visible=true;
					
					axMap.AddLayer(pFeatLyr,0);
					axMap.Refresh();
				}
                else if (openFileDialog1.FilterIndex == 3)
                {
                    IRasterDataset pRsDataset = Utility.OpenRasterDataset(shpDir, shpFile);
                    IRaster pInRaster=pRsDataset.CreateDefaultRaster();
                    IRasterLayer pRsLayer = new RasterLayerClass();
                    pRsLayer.CreateFromRaster(pInRaster);
                    axMap.AddLayer(pRsLayer, 0);
                    axMap.Refresh();
                }
			}
	

			
		}
Пример #12
0
		//打开已有的地图文档
		public static void OpenMxdDocument(MainFrm pMainFrm)
		{
			OpenFileDialog openFileDialog1=new OpenFileDialog();
			openFileDialog1.Title="打开已有的地图文档";
			openFileDialog1.InitialDirectory="c:\\temp";
			openFileDialog1.Filter="地图文档(*.mxd, *.mxt, *.pmf)|*.mxd;*.mxt;*.pmf";
			if(openFileDialog1.ShowDialog()==DialogResult.OK)
			{
				pMainFrm.modPublicClass.pMapDocument.Open(openFileDialog1.FileName,"");
			}
			AxMapControl axMap=pMainFrm.getMapControl();
            AxMapControl overviewMap = pMainFrm.getOverviewControl();
			if(axMap.CheckMxFile(pMainFrm.modPublicClass.pMapDocument.DocumentFilename )==true)
			{
				axMap.LoadMxFile(pMainFrm.modPublicClass.pMapDocument.DocumentFilename ,null,null);
			 	overviewMap.LoadMxFile(pMainFrm.modPublicClass.pMapDocument.DocumentFilename ,null,null);
			}
			else
			{
				MessageBox.Show("所选择的文档视图文件不存在,请重新指定!","错误提示");
			}
		}