Example #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);
        }
        public static IGraphicCollection GraphicsFromXml(XElement root)
        {
            if (root.Name != "IS3Graphics")
            {
                return(null);
            }

            IGraphicCollection gc = IS3Runtime.GraphicEngine.NewGraphicCollection();

            foreach (XElement node in root.Descendants())
            {
                IGraphic g = GraphicFromXml(node);
                if (g != null)
                {
                    gc.Add(g);
                }
            }
            if (gc.Count == 0)
            {
                return(null);
            }
            else
            {
                return(gc);
            }
        }
 public void addGraphics(IGraphicCollection gc)
 {
     foreach (IGraphic g in gc)
     {
         addGraphic(g);
     }
 }
        // Summary:
        //     Select objects by geometry
        // Remarks:
        //     The function selects graphics at first,
        //     then it returns the corresponding DGObjects as a list.
        //     If a graphic has no corresponding DGObject, it will
        //     still be in a selected state.
        public List <DGObject> selectObjectsByRect(IGeometry geom)
        {
            Esri.ArcGISRuntime.Geometry.Geometry rect = geom
                                                        as Esri.ArcGISRuntime.Geometry.Geometry;

            foreach (Graphic g in graphics)
            {
                if (!GeometryEngine.Contains(rect, g.Geometry))
                {
                    continue;
                }

                IGraphic ig = g as IGraphic;
                // make sure all graphics with the name is selected.
                if (_graphic2Objs != null &&
                    _graphic2Objs.ContainsKey(ig))
                {
                    DGObject           obj = _graphic2Objs[ig];
                    IGraphicCollection gc  = _obj2Graphics[obj];
                    foreach (IGraphic item in gc)
                    {
                        item.IsSelected = true;
                    }
                }
                else
                {
                    g.IsSelected = true;
                }
            }
            List <DGObject> objs = getHighlightedObjects();

            return(objs);
        }
Example #5
0
        public int highlightObject(DGObject obj, bool on = true)
        {
            int count = 0;

            if (_obj2Graphics != null)
            {
                KeyValuePair <DGObject, IGraphicCollection> result = _obj2Graphics.Where(x => x.Key.Name == obj.Name).FirstOrDefault();
                if (result.Key != null)
                {
                    IGraphicCollection gc = result.Value;
                    foreach (IGraphic g in gc)
                    {
                        if (g.IsSelected != on)
                        {
                            g.IsSelected = on;
                        }
                        count++;
                    }
                }
            }
            //old
            //if (_obj2Graphics != null &&
            //    _obj2Graphics.ContainsKey(obj))
            //{
            //    IGraphicCollection gc = _obj2Graphics[obj];
            //    foreach (IGraphic g in gc)
            //    {
            //        if (g.IsSelected != on)
            //            g.IsSelected = on;
            //    }
            //}
            return(count);
        }
Example #6
0
 public static XElement GraphicsToXml(IGraphicCollection graphics)
 {
     XElement parent = new XElement("IS3Graphics");
     foreach (IGraphic g in graphics)
     {
         XElement node = GraphicToXml(g);
         parent.Add(node);
     }
     return parent;
 }
        public static XElement GraphicsToXml(IGraphicCollection graphics)
        {
            XElement parent = new XElement("IS3Graphics");

            foreach (IGraphic g in graphics)
            {
                XElement node = GraphicToXml(g);
                parent.Add(node);
            }
            return(parent);
        }
Example #8
0
        public void panToGraphics(IGraphicCollection gc)
        {
            IEnvelope env = GraphicsUtil.GetGraphicsEnvelope(gc);

            if (env == null)
            {
                return;
            }
            IMapPoint p      = env.GetCenter();
            MapPoint  center = p as MapPoint;

            _mapView.SetView(center);
        }
        // Get the extent of a bunch of graphics
        public static IEnvelope GetGraphicsEnvelope(IGraphicCollection gc)
        {
            if (gc == null || gc.Count == 0)
            {
                return(null);
            }

            IEnvelope env = gc[0].Geometry.Extent;

            for (int i = 1; i < gc.Count; ++i)
            {
                env = env.Union(gc[i].Geometry.Extent);
            }
            return(env);
        }
Example #10
0
        public int highlightObject(DGObject obj, bool on = true)
        {
            if (_obj2Graphics == null)
            {
                return(0);
            }
            int count = 0;
            //foreach (IGraphic g in graphics)
            //{
            //    if (g.Attributes.ContainsKey("Name"))
            //    {
            //        string name = g.Attributes["Name"] as string;
            //        if (name == obj.name)
            //        {
            //            if (g.IsSelected != on)
            //                g.IsSelected = on;
            //        }
            //    }
            //}
            DGObject getobj = GetObjByID(obj.ID);

            if (_obj2Graphics != null && getobj != null &&
                _obj2Graphics.ContainsKey(getobj))
            {
                IGraphicCollection gc = _obj2Graphics[getobj];
                foreach (IGraphic g in gc)
                {
                    if (g.IsSelected != on)
                    {
                        g.IsSelected = on;
                    }
                }
            }
            return(count);

            //int count = 0;
            //if (_obj2Graphics != null &&
            //    _obj2Graphics.ContainsKey(obj))
            //{
            //    IGraphicCollection gc = _obj2Graphics[obj];
            //    foreach (IGraphic g in gc)
            //    {
            //        if (g.IsSelected != on)
            //            g.IsSelected = on;
            //    }
            //}
            //return count;
        }
Example #11
0
        //在view中加载图形,和同步图形
        void SyncToView()
        {
            IView view = InputCB.SelectedItem as IView;

            //为图形赋值“Name”属性,以便图形和数据关联
            foreach (int monID in _MonGraphics.Keys)
            {
                MonPoint           mp = _allMons[monID] as MonPoint;
                IGraphicCollection gc = _MonGraphics[monID];
                foreach (IGraphic g in gc)
                {
                    g.Attributes["Name"] = mp.name;
                }
            }

            //将图形添加到view中
            string         layerID = "DemoLayer";                 //图层ID
            IGraphicsLayer gLayer  = getDemoLayer(view, layerID); //获取图层函数

            foreach (int id in _MonGraphics.Keys)
            {
                IGraphicCollection gc = _MonGraphics[id];
                gLayer.addGraphics(gc);
            }

            //使数据与图形关联
            List <DGObject> sls = _allMons.merge();

            gLayer.syncObjects(sls);

            //计算新建图形范围,并在地图中显示该范围
            IEnvelope ext = null;

            foreach (IGraphicCollection gc in _MonGraphics.Values)
            {
                IEnvelope itemExt = GraphicsUtil.GetGraphicsEnvelope(gc);
                if (ext == null)
                {
                    ext = itemExt;
                }
                else
                {
                    ext = ext.Union(itemExt);
                }
            }
            _mainFrame.activeView = view;
            view.zoomTo(ext);
        }
        protected virtual void DefaultDrawingELayerToXml(XElement root)
        {
            IGraphicsLayer     gLayer = DefaultDrawingELayer.GraphicsLayer;
            IGraphicCollection gc     = IS3Runtime.GraphicEngine.NewGraphicCollection();

            foreach (IGraphic g in gLayer.Graphics)
            {
                gc.Add(g);
            }

            XElement parent = new XElement("DefaultDrawingELayer");
            XElement node   = GraphicsSerializer.GraphicsToXml(gc);

            parent.Add(node);
            root.Add(parent);
        }
        // Draw horizontal distributed load
        // Note: x1<x2, (x1,y1)-(x2,y1) is a horizontal line, (x1,y2)-(x2,y3) is a oblique line
        //
        public static IGraphicCollection DistributedLoad_Horizontal(double x1, double x2, double y1, double y2, double y3,
                                                                    ISymbol backgroundFillSymbol, ISymbol arrowFillSymbol, ISymbol lineSymbol)
        {
            IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection();

            IMapPoint p1 = Runtime.geometryEngine.newMapPoint(x1, y1);
            IMapPoint p2 = Runtime.geometryEngine.newMapPoint(x1, y2);
            IMapPoint p3 = Runtime.geometryEngine.newMapPoint(x2, y3);
            IMapPoint p4 = Runtime.geometryEngine.newMapPoint(x2, y1);
            IGraphic  g  = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4);

            g.Symbol = backgroundFillSymbol;
            gc.Add(g);

            IPointCollection pc = Runtime.geometryEngine.newPointCollection();

            pc.Add(p1);
            pc.Add(p2);
            pc.Add(p3);
            pc.Add(p4);
            pc.Add(p1);
            g        = Runtime.graphicEngine.newPolyline(pc);
            g.Symbol = lineSymbol;
            gc.Add(g);

            double x00, y00, y01;

            for (int i = 0; i <= 10; ++i)
            {
                x00 = x1 + i * (x2 - x1) / 10.0;
                y00 = y1;
                y01 = y2 + i * (y3 - y2) / 10.0;
                IMapPoint p00 = Runtime.geometryEngine.newMapPoint(x00, y00);
                IMapPoint p01 = Runtime.geometryEngine.newMapPoint(x00, y01);
                g        = Runtime.graphicEngine.newLine(p00, p01);
                g.Symbol = lineSymbol;
                gc.Add(g);

                pc       = GeomUtil.VectorArrowPoints(x00, y2, p00);
                g        = Runtime.graphicEngine.newPolygon(pc);
                g.Symbol = arrowFillSymbol;
                gc.Add(g);
            }
            return(gc);
        }
        public int highlightObject(DGObject obj, bool on = true)
        {
            int count = 0;

            if (_obj2Graphics != null &&
                _obj2Graphics.ContainsKey(obj))
            {
                IGraphicCollection gc = _obj2Graphics[obj];
                foreach (IGraphic g in gc)
                {
                    if (g.IsSelected != on)
                    {
                        g.IsSelected = on;
                    }
                }
            }
            return(count);
        }
Example #15
0
        void test()
        {
            IPointCollection pc = Runtime.geometryEngine.newPointCollection();
            IMapPoint        p1 = Runtime.geometryEngine.newMapPoint(0, 0);
            IMapPoint        p2 = Runtime.geometryEngine.newMapPoint(0, 100);
            IMapPoint        p3 = Runtime.geometryEngine.newMapPoint(100, 0);

            pc.Add(p1);
            pc.Add(p2);
            pc.Add(p3);

            IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection();
            IGraphic           g1 = Runtime.graphicEngine.newLine(p1, p2);
            IGraphic           g2 = Runtime.graphicEngine.newLine(p1, p3);

            gc.Add(g1);
            gc.Add(g2);

            IEnvelope env = GraphicsUtil.GetGraphicsEnvelope(gc);
        }
        protected virtual void DefaultDrawingELayerFromXml(XElement root)
        {
            XElement parent = root.Descendants().First();

            if (parent.Name != "DefaultDrawingELayer")
            {
                return;
            }

            XElement           node     = parent.Descendants().First();
            IGraphicCollection graphics =
                GraphicsSerializer.GraphicsFromXml(node);

            if (graphics == null)
            {
                return;
            }

            IGraphicsLayer gLayer = DefaultDrawingELayer.GraphicsLayer;

            _view.AddGraphics(gLayer, graphics);
        }
Example #17
0
 public void panToGraphics(IGraphicCollection gc)
 {
     IEnvelope env = GraphicsUtil.GetGraphicsEnvelope(gc);
     if (env == null)
         return;
     IMapPoint p = env.GetCenter();
     MapPoint center = p as MapPoint;
     _mapView.SetView(center);
 }
        private void DrawDisplacement(double x, double z, double r, LoadStructure loadStructure, IGraphicCollection resultGraphic)
        {
            double max_x = 0;
            double max_z = 0;
            double pi = 3.13159;
            double m = 0;
            double num = loadStructure.Result.Count();

            foreach (LoadStructure.NodeResult nr in loadStructure.Result)
            {
                if (Math.Abs(nr.x) > max_x)
                    max_x = Math.Abs(nr.x);
                if (Math.Abs(nr.y) > max_z)
                    max_z = Math.Abs(nr.y);
            }

            if (max_x > max_z)
                m = max_x;
            else
                m = max_z;
            IGraphic g;
            ISymbol lineSymbol = Runtime.graphicEngine.newSimpleLineSymbol(Colors.Transparent, SimpleLineStyle.Solid, 1.0);
            g = ShapeMappingUtility.NewCircle(x, z, r, _spatialRef);
            g.Symbol = lineSymbol;
            resultGraphic.Add(g);

            IPointCollection pc = Runtime.geometryEngine.newPointCollection();
            foreach (LoadStructure.NodeResult nr in loadStructure.Result)
            {
                double x1 = x - Math.Sin(2 * pi * (nr.n - 1) / num) * r + nr.x * 0.1 * r / m;
                double y1 = z + Math.Cos(2 * pi * (nr.n - 1) / num) * r + nr.y * 0.1 * r / m;

                IMapPoint p1 = Runtime.geometryEngine.newMapPoint(x1, y1, _spatialRef);
                pc.Add(p1);
            }
            double xf = x - Math.Sin(2 * pi * (loadStructure.Result[0].n - 1) / num) * r + loadStructure.Result[0].x * 0.1 * r / m;
            double yf = z + Math.Cos(2 * pi * (loadStructure.Result[0].n - 1) / num) * r + loadStructure.Result[0].y * 0.1 * r / m;
            IMapPoint first = Runtime.geometryEngine.newMapPoint(xf, yf, _spatialRef);
            pc.Add(first);

            ISymbol lineSymbol2 = Runtime.graphicEngine.newSimpleLineSymbol(Colors.Blue, SimpleLineStyle.Solid, 1.0);
            g = ShapeMappingUtility.NewPolyline(pc);
            g.Symbol = lineSymbol2;
            resultGraphic.Add(g);

            IGraphic text;
            for (int i = 1; i < 5; i++)
            {
                int n = i * 90;
                LoadStructure.NodeResult nr = loadStructure.Result[n - 1];
                double x1 = x - Math.Sin(2 * pi * (nr.n - 1) / num) * r;
                double y1 = z + Math.Cos(2 * pi * (nr.n - 1) / num) * r;

                IMapPoint p = Runtime.geometryEngine.newMapPoint(x1, y1, _spatialRef);
                text = Runtime.graphicEngine.newText(string.Format("x:{0:0.00000000},y:{1:0.00000000}", nr.x, nr.y), p, Colors.Red, "Arial", 12);
                resultGraphic.Add(text);
            }
        }
        private void DrawForce(double x, double z, double r, int num, int n, double value, double max, double min, IGraphicCollection resultGraphic)
        {
            double m;
            double pi = 3.14159;
            if (Math.Abs(max) > Math.Abs(min))
                m = Math.Abs(max);
            else
                m = Math.Abs(min);
            IGraphic g;

            double x1 = x - Math.Sin(2 * pi * (n - 1) / num) * r;
            double y1 = z + Math.Cos(2 * pi * (n - 1) / num) * r;
            double x2 = x - Math.Sin(2 * pi * n / num) * r;
            double y2 = z + Math.Cos(2 * pi * n / num) * r;
            double x3 = x - Math.Sin(2 * pi * n / num) * (r + 0.25 * r * value / m);
            double y3 = z + Math.Cos(2 * pi * n / num) * (r + 0.25 * r * value / m);
            double x4 = x - Math.Sin(2 * pi * (n - 1) / num) * (r + 0.25 * r * value / m);
            double y4 = z + Math.Cos(2 * pi * (n - 1) / num) * (r + 0.25 * r * value / m);

            IMapPoint p1 = Runtime.geometryEngine.newMapPoint(x1, y1, _spatialRef);
            IMapPoint p2 = Runtime.geometryEngine.newMapPoint(x2, y2, _spatialRef);
            IMapPoint p3 = Runtime.geometryEngine.newMapPoint(x3, y3, _spatialRef);
            IMapPoint p4 = Runtime.geometryEngine.newMapPoint(x4, y4, _spatialRef);

            g = ShapeMappingUtility.NewLine(p1, p2);
            g.Symbol = _lineSymbol;
            resultGraphic.Add(g);

            ISimpleLineSymbol outline = Runtime.graphicEngine.newSimpleLineSymbol(
                                Color.FromArgb(255, 255, 255, 255), Core.Graphics.SimpleLineStyle.Solid, 1.0);
            ISimpleFillSymbol fillSymbol = Runtime.graphicEngine.newSimpleFillSymbol(
                                GradeColor.GetFEMColor(max, min, value), SimpleFillStyle.Solid, outline);
            g = ShapeMappingUtility.NewQuadrilateral(p1, p2, p3, p4);
            g.Symbol = fillSymbol;
            resultGraphic.Add(g);
        }
        private void DrawValueTable(double x, double z, double r, double max, double min, IGraphicCollection resultGraphic)
        {
            double n = (max - min) / 9.0;
            double dis = 3 * r / 9.0;
            double x_start = x - 1.5 * r;
            double y_start = z - 1.3 * r;

            IGraphic c = Runtime.graphicEngine.newGraphic();
            c = ShapeMappingUtility.NewCircle(x, z, r, _spatialRef);
            c.Symbol = _whitefillSymbol;
            resultGraphic.Add(c);

            for (int i = 1; i < 10; i++)
            {
                double value = min + n * i;

                double left = x_start + dis * (i - 1);
                double bottom = y_start;
                double right = x_start + dis * i;
                double top = y_start + 0.07 * r;
                IGraphic g;
                ISimpleLineSymbol outline = Runtime.graphicEngine.newSimpleLineSymbol(
                                Colors.White, Core.Graphics.SimpleLineStyle.Solid, 1.0);
                ISimpleFillSymbol fillSymbol = Runtime.graphicEngine.newSimpleFillSymbol(
                                    GradeColor.GetFEMColor(max, min, value), SimpleFillStyle.Solid, outline);
                g = ShapeMappingUtility.NewRectangle(left, top, right, bottom, _spatialRef);
                g.Symbol = fillSymbol;
                resultGraphic.Add(g);
            }

            double middle = (max + min) / 2.0;
            IGraphic text;
            text = Runtime.graphicEngine.newText(string.Format("{0:0.00}", min),
                Runtime.geometryEngine.newMapPoint(x - 1.5 * r, z - 1.24 * r, _spatialRef), Colors.White, "Arial", 12);
            resultGraphic.Add(text);
            text = Runtime.graphicEngine.newText(string.Format("{0:0.00}", middle),
                Runtime.geometryEngine.newMapPoint(x - 0.1 * r, z - 1.24 * r, _spatialRef), Colors.White, "Arial", 12);
            resultGraphic.Add(text);
            text = Runtime.graphicEngine.newText(string.Format("{0:0.00}", max),
                Runtime.geometryEngine.newMapPoint(x + 1.2 * r, z - 1.24 * r, _spatialRef), Colors.White, "Arial", 12);
            resultGraphic.Add(text);
        }
        public int syncObjects(IEnumerable <DGObject> objs)
        {
            if (objs == null)
            {
                return(0);
            }

            // Build (graphic name)-(graphics) index.
            // Graphics may share a same name if they belong to a object.
            //
            Dictionary <string, IGraphicCollection> graphicIndex =
                new Dictionary <string, IGraphicCollection>();

            foreach (IGraphic g in graphics)
            {
                if (g.Attributes.ContainsKey("Name"))
                {
                    string name = g.Attributes["Name"] as string;
                    if (name == null)
                    {
                        continue;
                    }
                    IGraphicCollection gc = null;
                    if (graphicIndex.ContainsKey(name))
                    {
                        gc = graphicIndex[name];
                    }
                    else
                    {
                        gc = new IS3GraphicCollection();
                        graphicIndex[name] = gc;
                    }
                    gc.Add(g);
                }
            }

            // Sync objects with graphics
            //
            _obj2Graphics     = new Dictionary <DGObject, IGraphicCollection>();
            _graphicName2Objs = new Dictionary <string, DGObject>();
            int count = 0;

            foreach (DGObject obj in objs)
            {
                string name = obj.Name;
                if (graphicIndex.ContainsKey(name))
                {
                    IGraphicCollection gc = graphicIndex[name];
                    _obj2Graphics[obj]      = gc;
                    _graphicName2Objs[name] = obj;
                    count++;
                }
            }
            _graphic2Objs = new Dictionary <IGraphic, DGObject>();
            foreach (IGraphic g in graphics)
            {
                if (g.Attributes.ContainsKey("Name"))
                {
                    string name = g.Attributes["Name"] as string;
                    if (name == null)
                    {
                        continue;
                    }
                    if (_graphicName2Objs.ContainsKey(name))
                    {
                        _graphic2Objs[g] = _graphicName2Objs[name];
                    }
                }
            }

            return(count);
        }
Example #22
0
        // Get the extent of a bunch of graphics
        public static IEnvelope GetGraphicsEnvelope(IGraphicCollection gc)
        {
            if (gc == null || gc.Count == 0)
                return null;

            IEnvelope env = gc[0].Geometry.Extent;
            for (int i = 1; i < gc.Count; ++i)
            {
                env = env.Union(gc[i].Geometry.Extent);
            }
            return env;
        }
Example #23
0
 public void addGraphics(IGraphicCollection gc)
 {
     foreach (IGraphic g in gc)
         addGraphic(g);
 }
Example #24
0
        public static double? StratumTop(double tunnelX, IGraphicCollection sGraphics, ISpatialReference sp)
        {
            List<IMapPoint> intersectPnts = new List<IMapPoint>();
            foreach (var obj in sGraphics)
            {
                IGraphic sGraph = obj as IGraphic;
                if (sGraph == null)
                    continue;
                IPolygon sPoly = sGraph.Geometry as IPolygon;
                if (sPoly == null)
                    continue;
                IPointCollection sPts = sPoly.GetPoints();

                // compute the stratum's maximum coordinates
                double xmin, xmax, ymin, ymax;
                xmin = sPts[0].X;
                xmax = sPts[0].X;
                ymin = sPts[0].Y;
                ymax = sPts[0].Y;
                foreach (IMapPoint p in sPts)
                {
                    if (p.X < xmin) xmin = p.X;
                    if (p.X > xmax) xmax = p.X;
                    if (p.Y < ymin) ymin = p.Y;
                    if (p.Y > ymax) ymax = p.Y;
                }

                if (tunnelX < xmin || tunnelX > xmax)
                    continue;

                for (int i = 0; i < sPts.Count - 1; ++i)
                {
                    IMapPoint p0 = sPts[i];
                    IMapPoint p1 = sPts[i + 1];
                    double x = 0, y = 0;
                    bool intersect = GeometryAlgorithms.LineIntersectWithLine(p0.X, p0.Y, p1.X, p1.Y,
                        tunnelX, ymin, tunnelX, ymax, ref x, ref y, ExtendOption.Other);
                    if (intersect)
                    {
                        IMapPoint p = Runtime.geometryEngine.newMapPoint(x, y,sp);
                        intersectPnts.Add(p);
                    }
                }
            }

            if (intersectPnts.Count > 0)
            {
                List<double> y = new List<double>();
                for (int i = 0; i < intersectPnts.Count; ++i)
                {
                    y.Add(intersectPnts[i].Y);
                }
                y.Sort();

                return y[y.Count - 1];
            }

            return null;
        }
Example #25
0
        public int syncObjects(IEnumerable <DGObject> objs)
        {
            if (objs == null)
            {
                return(0);
            }

            // Build (graphic name)-(graphics) index.
            // Graphics may share a same name if they belong to a object.
            //
            Dictionary <int, IGraphicCollection> graphicIndex =
                new Dictionary <int, IGraphicCollection>();

            foreach (IGraphic g in graphics)
            {
                if (g.Attributes.ContainsKey("ID"))
                {
                    int id = int.Parse(g.Attributes["ID"].ToString());
                    if (id == null)
                    {
                        continue;
                    }
                    IGraphicCollection gc = null;
                    if (graphicIndex.ContainsKey(id))
                    {
                        gc = graphicIndex[id];
                    }
                    else
                    {
                        gc = new IS3GraphicCollection();
                        graphicIndex[id] = gc;
                    }
                    gc.Add(g);
                }
            }

            // Sync objects with graphics
            //
            _obj2Graphics   = new Dictionary <DGObject, IGraphicCollection>();
            _graphicID2Objs = new Dictionary <int, DGObject>();
            int count = 0;

            foreach (DGObject obj in objs)
            {
                int id = obj.ID;
                if (graphicIndex.ContainsKey(id))
                {
                    IGraphicCollection gc = graphicIndex[id];
                    _obj2Graphics[obj]  = gc;
                    _graphicID2Objs[id] = obj;
                    count++;
                }
            }
            _graphic2Objs = new Dictionary <IGraphic, DGObject>();
            foreach (IGraphic g in graphics)
            {
                if (g.Attributes.ContainsKey("ID"))
                {
                    int id = int.Parse(g.Attributes["ID"].ToString());
                    if (_graphicID2Objs.ContainsKey(id))
                    {
                        _graphic2Objs[g] = _graphicID2Objs[id];
                    }
                }
            }

            return(count);
        }
Example #26
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; //保存结果
                }
            }
        }
        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);
                }
            }
        }
Example #28
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; //保存结果
                }
            }
        }
Example #29
0
        public static Result StratumOnTunnel(double tunnelX, double tunnelZ, double h,
            IGraphicCollection sGraphics, ISpatialReference sp)
        {
            List<IMapPoint> intersectPnts = new List<IMapPoint>();
            foreach (object obj in sGraphics)
            {
                IGraphic sGraph = obj as IGraphic;
                if (sGraph == null)
                    continue;
                IPolygon sPoly = sGraph.Geometry as IPolygon;
                if (sPoly == null)
                    continue;
                IPointCollection sPts = sPoly.GetPoints();

                // compute the stratum's maximum coordinates
                double xmin, xmax, ymin, ymax;
                xmin = sPts[0].X;
                xmax = sPts[0].X;
                ymin = sPts[0].Y;
                ymax = sPts[0].Y;
                foreach (IMapPoint p in sPts)
                {
                    if (p.X < xmin) xmin = p.X;
                    if (p.X > xmax) xmax = p.X;
                    if (p.Y < ymin) ymin = p.Y;
                    if (p.Y > ymax) ymax = p.Y;
                }

                if (tunnelX < xmin || tunnelX > xmax)
                    continue;

                for (int i = 0; i < sPts.Count - 1; ++i)
                {
                    IMapPoint p0 = sPts[i];
                    IMapPoint p1 = sPts[i + 1];
                    double x = 0, y = 0;
                    bool intersect = GeometryAlgorithms.LineIntersectWithLine(p0.X, p0.Y, p1.X, p1.Y,
                        tunnelX, ymin, tunnelX, ymax, ref x, ref y, ExtendOption.None);
                    if (intersect)
                    {
                        IMapPoint p = Runtime.geometryEngine.newMapPoint(x, y,sp);
                        intersectPnts.Add(p);
                    }
                }
            }

            if (intersectPnts.Count > 0)
            {
                List<double> y = new List<double>();
                for (int i = 0; i < intersectPnts.Count; ++i)
                {
                    y.Add(intersectPnts[i].Y);
                }
                y.Sort();

                for (int i = 0; i < y.Count / 2; ++i)
                {
                    if (tunnelZ > y[2 * i] && tunnelZ < y[2 * i + 1])
                    {
                        y.Insert(2 * i + 1, tunnelZ);
                        y.Insert(2 * i + 1, tunnelZ);
                        break;
                    }
                }
                double bottom = tunnelZ - h;
                for (int i = 0; i < y.Count / 2; ++i)
                {
                    if (bottom > y[2 * i] && bottom < y[2 * i + 1])
                    {
                        y.Insert(2 * i + 1, bottom);
                        y.Insert(2 * i + 1, bottom);
                        break;
                    }
                }

                intersectPnts.Clear();
                for (int i = 0; i < y.Count; ++i)
                {
                    IMapPoint p = Runtime.geometryEngine.newMapPoint(tunnelX, y[i], sp);
                    intersectPnts.Add(p);
                }

                Result res = new Result();
                res.Depth = y[y.Count - 1] - tunnelZ;
                res.Top = y[y.Count - 1];
                res.Thickness = 0;
                res.ThicknessInside = 0;
                res.ThicknessBelow = 0;
                res.intersectPnts = intersectPnts;

                double y1, y2, t;
                for (int i = 0; i < y.Count / 2; ++i)
                {
                    y1 = y[i * 2];
                    y2 = y[i * 2 + 1];
                    t = y2 - y1;
                    if (y1 >= tunnelZ)
                        res.Thickness += t;
                    else if (y1 >= bottom)
                        res.ThicknessInside += t;
                    else
                        res.ThicknessBelow += t;
                }

                res.IsOverlap = false;
                res.MinDistToTop = 0;
                res.MinDistToBottom = 0;
                if (y[0] > tunnelZ)
                    res.MinDistToTop = y[0] - tunnelZ;
                else if (y[y.Count - 1] < bottom)
                    res.MinDistToBottom = bottom - y[y.Count - 1];
                else
                    res.IsOverlap = true;

                return res;
            }
            return null;
        }
        void DrawAxisMileage(TunnelAxis axis, IGraphicCollection gc, int interval)
        {
            int count = axis.AxisPoints.Count;
            double start = axis.AxisPoints[0].Mileage;
            double end = axis.AxisPoints[count - 1].Mileage;
            double len = end - start;
            int num = (int)len / interval;
            num += 3;       // add begin, end points, and a truncated interval

            for (int i = 0; i < num; ++i)
            {
                double m = start + i * interval;
                m = ((int)m / interval) * interval;
                if (m < start) m = start;
                if (m > end) m = end;

                int m1 = (int)m / 1000;
                int m2 = (int)m % 1000;
                string strK = "K" + m1.ToString() + "+" + m2.ToString();

                TunnelAxisPoint axisPt = TunnelMappingUtility.MileageToAxisPoint(m, axis);
                IMapPoint p = Runtime.geometryEngine.newMapPoint(axisPt.X + 3, axisPt.Y + 3, _spatialRef);
                IGraphic g = Runtime.graphicEngine.newText(strK, p, Colors.Red, "Arial", 10.0);
                gc.Add(g);

                IPointCollection pc = TunnelMappingUtility.ComputeTunnelCrossLine(m, _settings.tickLen, _settings.tickLen, axis, _spatialRef);
                g = Runtime.graphicEngine.newPolyline(pc);
                g.Symbol = _symbol;
                gc.Add(g);
            }
        }