Ejemplo n.º 1
0
        //public async Task<QueryResult>
        //    QueryEntitiesByID(QueryEntitiesArgs args, string layerName)
        //{
        //    QueryResult queryResult = null;

        //    // Objs field must be filled
        //    if (_localFeatureService == null || args.Objs == null)
        //        return queryResult;

        //    EngineeringLayer eLayer = _eMap.GetELayerByName(layerName);
        //    if (eLayer == null)
        //        return queryResult;

        //    string url = _localFeatureService.UrlFeatureService
        //        + "/" + eLayer.LocalLayerID;

        //    QueryTask queryTask = new QueryTask(new Uri(url));

        //    Query query = new Query("1=1");
        //    query.OutFields.Add("*");
        //    query.ReturnGeometry = true;
        //    query.OutSpatialReference = _srEMap;
        //    query.Where = QueryCondition(args.Objs);

        //    try
        //    {
        //        IsBusy = true;
        //        queryResult = await queryTask.ExecuteAsync(query);
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //    IsBusy = false;
        //    return queryResult;
        //}

        //public async Task<QueryResult>
        //    QueryEntitiesByGeom(QueryEntitiesArgs args, EngineeringLayer layer)
        //{
        //    QueryResult queryResult = null;

        //    if (_localFeatureService == null || layer == null)
        //        return queryResult;

        //    string url = _localFeatureService.UrlFeatureService
        //        + "/" + layer.LocalLayerID;

        //    QueryTask queryTask = new QueryTask(new Uri(url));

        //    Query query = new Query("1=1");
        //    query.OutFields.Add("*");
        //    query.ReturnGeometry = true;
        //    query.OutSpatialReference = _srEMap;
        //    query.Geometry = args.Geometry;
        //    query.Where = args.Condition;

        //    try
        //    {
        //        IsBusy = true;
        //        queryResult = await queryTask.ExecuteAsync(query);
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //    IsBusy = false;
        //    return queryResult;
        //}
        #endregion

        #region map pan functions
        public void panToObjects(IEnumerable <DGObject> objs)
        {
            if (objs == null)
            {
                return;
            }
            IGraphicCollection allGraphics = new IS3GraphicCollection();

            foreach (DGObject obj in objs)
            {
                if (obj == null || obj.parent == null)
                {
                    continue;
                }
                string         layerID = obj.parent.definition.GISLayerName;
                IGraphicsLayer layer   = _map.Layers[layerID] as IGraphicsLayer;
                if (layer == null)
                {
                    continue;
                }
                IGraphicCollection gc = layer.getGraphics(obj);
                if (gc == null)
                {
                    continue;
                }
                allGraphics.Add(gc);
            }
            panToGraphics(allGraphics);
        }
        void StartAnalyzing()
        {
            //Get input view
            IView view = InputCB.SelectedItem as IView;

            _spatialRef = view.spatialReference;

            //create new layer
            view.removeLayer("Rectanglelayer");  //clear the previous layer
            string         layerID  = "Rectanglelayer";
            IGraphicsLayer mlayer   = Runtime.graphicEngine.newGraphicsLayer(layerID, layerID);
            var            sym_fill = GraphicsUtil.GetDefaultFillSymbol();
            var            renderer = Runtime.graphicEngine.newSimpleRenderer(sym_fill);

            mlayer.setRenderer(renderer);
            mlayer.Opacity = 1.0;
            view.addLayer(mlayer);

            //Define local variables
            IGraphic m;
            int      count  = 0;
            int      result = 5;
            double   monpointX;
            double   monpointY;

            _monpoints = _prj.getSelectedObjs(_monitoringDomain, "MonPoint");
            foreach (DGObject mp in _mps)
            {
                MonPoint _mp = mp as MonPoint;
                foreach (string key in _mp.readingsDict.Keys)
                {
                    List <MonReading> a = _mp.readingsDict[key];
                    foreach (MonReading b in a)
                    {
                        if (System.Math.Abs(b.value) > mptb)
                        {
                            count++;
                        }
                    }

                    if (count <= 50)
                    {
                        result = 5;
                    }
                    else if (count <= 150)
                    {
                        result = 4;
                    }
                    else if (count <= 250)
                    {
                        result = 3;
                    }
                    else if (count <= 350)
                    {
                        result = 2;
                    }
                    else
                    {
                        result = 1;
                    }
                    ISymbol symbol = GetSymbol(result);

                    //Obtain borehole coordinates
                    IGraphicsLayer     mplayer      = view.getLayer("MonPoint");
                    IGraphicCollection mpcollection = mplayer.getGraphics(_mp);
                    m = mpcollection[0];
                    IGeometry mpgeometry = m.Geometry;
                    IMapPoint mpmappoint = mpgeometry as IMapPoint;
                    monpointX = mpmappoint.X;
                    monpointY = mpmappoint.Y;

                    //Draw rectangle
                    IMapPoint p1 = Runtime.geometryEngine.newMapPoint(monpointX + 2200, monpointY + 2200, _spatialRef);
                    IMapPoint p2 = Runtime.geometryEngine.newMapPoint(monpointX + 2200, monpointY - 2200, _spatialRef);
                    IMapPoint p3 = Runtime.geometryEngine.newMapPoint(monpointX - 2200, monpointY - 2200, _spatialRef);
                    IMapPoint p4 = Runtime.geometryEngine.newMapPoint(monpointX - 2200, monpointY + 2200, _spatialRef);
                    m        = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4);
                    m.Symbol = symbol;
                    IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection();
                    gc.Add(m);
                    mlayer.addGraphics(gc);
                }
            }
        }
Ejemplo n.º 3
0
        void StartAnalysis()
        {
            double max = double.Parse(TB_Max.Text);
            //获取输入的view和复制坐标系
            IView view = InputCB.SelectedItem as IView;

            _spatialRef = view.spatialReference;

            //开始分析
            foreach (string MonLayerID in _selectedMonsDict.Keys)
            {
                //获取衬砌选中列表
                IEnumerable <DGObject> mons    = _selectedMonsDict[MonLayerID];
                List <DGObject>        monList = mons.ToList();
                IGraphicsLayer         gLayer  = _inputView.getLayer(MonLayerID);
                foreach (DGObject dg in monList)
                {
                    //获取单个监测点对象,计算监测状况
                    MonPoint mp = dg as MonPoint;

                    int grade = 0;
                    foreach (string key in mp.readingsDict.Keys)
                    {
                        List <MonReading> mrList = mp.readingsDict[key];
                        foreach (MonReading mr in mrList)
                        {
                            if (Math.Abs(mr.value) > max)
                            {
                                grade = 1;
                                break;
                            }
                        }
                        if (grade == 1)
                        {
                            break;
                        }
                    }


                    //根据评估等级获取图形样式
                    ISymbol symbol = GetSymbol(grade);

                    //为了演示,采用了较复杂的方法
                    //<简便方法 可替换下面代码>
                    //IGraphicCollection gcollection = gLayer.getGraphics(sl);
                    //IGraphic g = gcollection[0];
                    //g.Symbol = symbol;
                    //IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection();
                    //gc.Add(g);
                    //_slsGraphics[sl.id] = gc;
                    //</简便方法>

                    //获取衬砌图形
                    IGraphicCollection gcollection = gLayer.getGraphics(dg);
                    IGraphic           g           = gcollection[0];
                    IPolygon           ip          = g.Geometry as IPolygon; //获取端点
                    IPointCollection   ipc         = ip.GetPoints();
                    //导入的监测点不是点类型,是个圆所以要转换,如果是点,自己可以转换为IMapPoint
                    double centerX = 0;
                    double centerY = 0;
                    foreach (IMapPoint point in ipc)
                    {
                        centerX += point.X;
                        centerY += point.Y;
                    }
                    if (ipc.Count > 0)
                    {
                        centerX = centerX / ipc.Count;
                        centerY = centerY / ipc.Count;
                    }
                    double offset = 2;
                    //新建新的点,注意复制坐标系
                    IMapPoint p1 = Runtime.geometryEngine.newMapPoint(centerX - offset, centerY - offset, _spatialRef);
                    IMapPoint p2 = Runtime.geometryEngine.newMapPoint(centerX - offset, centerY + offset, _spatialRef);
                    IMapPoint p3 = Runtime.geometryEngine.newMapPoint(centerX + offset, centerY + offset, _spatialRef);
                    IMapPoint p4 = Runtime.geometryEngine.newMapPoint(centerX + offset, centerY - offset, _spatialRef);
                    ////生成新的图形
                    g        = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4);
                    g.Symbol = symbol;
                    IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection();
                    gc.Add(g);
                    _MonGraphics[dg.id] = gc; //保存结果
                }
            }
        }
Ejemplo n.º 4
0
        void StartAnalysis()
        {
            //获取输入的view和复制坐标系
            IView view = InputCB.SelectedItem as IView;

            _spatialRef = view.spatialReference;

            //开始分析
            foreach (string SLLayerID in _selectedSLsDict.Keys)
            {
                //获取衬砌选中列表
                IEnumerable <DGObject> sls    = _selectedSLsDict[SLLayerID];
                List <DGObject>        slList = sls.ToList();
                IGraphicsLayer         gLayer = _inputView.getLayer(SLLayerID);
                foreach (DGObject dg in slList)
                {
                    //获取单个衬砌对象,计算评估等级
                    SegmentLining           sl = dg as SegmentLining;
                    SLConvergenceRecordType slConvergenceRecordType = sl.ConstructionRecord.SLConvergenceRecords;
                    if (slConvergenceRecordType.SLConvergenceItems.Count == 0)
                    {
                        continue;
                    }

                    SLConvergenceItem slConvergenceItem = slConvergenceRecordType.SLConvergenceItems[0];
                    if (slConvergenceItem.HorizontalDev == double.NaN)
                    {
                        continue;
                    }
                    double raduis    = (double)slConvergenceItem.HorizontalRad;
                    double deviation = (double)slConvergenceItem.HorizontalDev;
                    double ratio     = deviation / (raduis - deviation) * 1000;

                    int grade;
                    if (ratio <= 3)
                    {
                        grade = 5;
                    }
                    else if (ratio <= 5)
                    {
                        grade = 4;
                    }
                    else if (ratio <= 8)
                    {
                        grade = 3;
                    }
                    else if (ratio <= 10)
                    {
                        grade = 2;
                    }
                    else
                    {
                        grade = 1;
                    }

                    //根据评估等级获取图形样式
                    ISymbol symbol = GetSymbol(grade);

                    //为了演示,采用了较复杂的方法
                    //<简便方法 可替换下面代码>
                    //IGraphicCollection gcollection = gLayer.getGraphics(sl);
                    //IGraphic g = gcollection[0];
                    //g.Symbol = symbol;
                    //IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection();
                    //gc.Add(g);
                    //_slsGraphics[sl.id] = gc;
                    //</简便方法>

                    //获取衬砌图形
                    IGraphicCollection gcollection     = gLayer.getGraphics(sl);
                    IGraphic           g               = gcollection[0];
                    IPolygon           polygon         = g.Geometry as IPolygon;
                    IPointCollection   pointCollection = polygon.GetPoints(); //获取端点
                    //衬砌为长方形,故有四个点
                    IMapPoint p1_temp = pointCollection[0];
                    IMapPoint p2_temp = pointCollection[1];
                    IMapPoint p3_temp = pointCollection[2];
                    IMapPoint p4_temp = pointCollection[3];
                    //新建新的点,注意复制坐标系
                    IMapPoint p1 = Runtime.geometryEngine.newMapPoint(p1_temp.X, p1_temp.Y, _spatialRef);
                    IMapPoint p2 = Runtime.geometryEngine.newMapPoint(p2_temp.X, p2_temp.Y, _spatialRef);
                    IMapPoint p3 = Runtime.geometryEngine.newMapPoint(p3_temp.X, p3_temp.Y, _spatialRef);
                    IMapPoint p4 = Runtime.geometryEngine.newMapPoint(p4_temp.X, p4_temp.Y, _spatialRef);
                    //生成新的图形
                    g        = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4);
                    g.Symbol = symbol;
                    IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection();
                    gc.Add(g);
                    _slsGraphics[sl.id] = gc; //保存结果
                }
            }
        }