Beispiel #1
0
        public void ShipSetup()
        {
            shotShipPoint = new Mock <IMapPoint>();
            shotShipPoint.Setup(_ => _.IsShip).Returns(true);
            shotShipPoint.Setup(_ => _.WasHit).Returns(true);
            shotShipPoint.Setup(_ => _.IsBlocked).Returns(true);
            shotShipPoint.Setup(_ => _.IsHidden).Returns(false);
            shotShipPoint.Setup(_ => _.X).Returns(0);
            shotShipPoint.Setup(_ => _.Y).Returns(0);

            okShipPointA = new Mock <IMapPoint>();
            okShipPointA.SetupGet(_ => _.IsShip).Returns(true);
            okShipPointA.SetupGet(_ => _.IsBlocked).Returns(true);
            okShipPointA.SetupGet(_ => _.IsHidden).Returns(true);
            okShipPointA.SetupGet(_ => _.X).Returns(0);
            okShipPointA.SetupGet(_ => _.Y).Returns(1);
            okShipPointA.SetupProperty(_ => _.WasHit, false);

            okShipPointB = new Mock <IMapPoint>();
            okShipPointB.SetupGet(_ => _.IsShip).Returns(true);
            okShipPointB.SetupGet(_ => _.IsBlocked).Returns(true);
            okShipPointB.SetupGet(_ => _.IsHidden).Returns(true);
            okShipPointB.SetupGet(_ => _.X).Returns(0);
            okShipPointB.SetupGet(_ => _.Y).Returns(2);
            okShipPointB.SetupProperty(_ => _.WasHit, false);

            var mp = new IMapPoint[3] {
                shotShipPoint.Object, okShipPointA.Object, okShipPointB.Object
            };

            _ship = new Ship(mp);
        }
        public static IPointCollection VectorArrowPoints(double beginPntX, double beginPntY, IMapPoint endPnt)
        {
            double x     = beginPntX - endPnt.X;
            double y     = beginPntY - endPnt.Y;
            double angle = Math.Atan2(y, x);

            double alpha  = Math.PI / 6;                        // arrow is 30 degree by each side of original line
            double length = Math.Sqrt(x * x + y * y) * 0.25;    // arrow is a quarter of original length

            double x1 = endPnt.X + length * Math.Cos(angle + alpha);
            double y1 = endPnt.Y + length * Math.Sin(angle + alpha);
            double x2 = endPnt.X + length * Math.Cos(angle - alpha);
            double y2 = endPnt.Y + length * Math.Sin(angle - alpha);

            IMapPoint p1 = Runtime.geometryEngine.newMapPoint(x1, y1);
            IMapPoint p2 = Runtime.geometryEngine.newMapPoint(x2, y2);

            IPointCollection pc = Runtime.geometryEngine.newPointCollection();

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

            return(pc);
        }
Beispiel #3
0
 public IGraphic newLine(IMapPoint p1, IMapPoint p2)
 {
     IS3PointCollection pts = new IS3PointCollection();
     pts.Add(p1 as IS3MapPoint);
     pts.Add(p2 as IS3MapPoint);
     return newPolyline(pts);
 }
        public void ShowHitResult(IMapPoint target, bool wasHit, bool wasSank)
        {
            var strBuilder = new StringBuilder();

            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;

            strBuilder.Append($"Your shot at {Convert.ToChar(START_CHAR + target.X)}{target.Y+1} ");
            if (!wasHit)
            {
                strBuilder.Append("missed");
            }
            else
            {
                if (wasSank)
                {
                    strBuilder.Append("hit and sank a ship!");
                }
                else
                {
                    strBuilder.Append("hit but did not sink a ship!");
                }
            }

            Console.WriteLine(strBuilder.ToString());
        }
Beispiel #5
0
 public static IGraphic NewLine(IMapPoint p1, IMapPoint p2)
 {
     IPointCollection pc = Runtime.geometryEngine.newPointCollection();
     pc.Add(p1);
     pc.Add(p2);
     return NewPolyline(pc);
 }
        public static IMapPoint MidPoint(IMapPoint p1, IMapPoint p2)
        {
            double    x = (p1.X + p2.X) / 2.0;
            double    y = (p1.Y + p2.Y) / 2.0;
            IMapPoint p = Runtime.geometryEngine.newMapPoint(x, y);

            return(p);
        }
        public IGraphic newLine(IMapPoint p1, IMapPoint p2)
        {
            IS3PointCollection pts = new IS3PointCollection();

            pts.Add(p1 as IS3MapPoint);
            pts.Add(p2 as IS3MapPoint);
            return(newPolyline(pts));
        }
Beispiel #8
0
        public bool Equals(IMapPoint other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            return(Location == other.Location && Map == other.Map);
        }
        public static IMapPoint InterpolatePointOnLine(IMapPoint p1, IMapPoint p2, double scale)
        {
            double x = 0.0, y = 0.0;

            GeometryAlgorithms.InterpolatePointOnLine(p1.X, p1.Y, p2.X, p2.Y, scale, ref x, ref y);
            IMapPoint p = Runtime.geometryEngine.newMapPoint(x, y);

            return(p);
        }
        public IGraphic newTriangle(IMapPoint p1, IMapPoint p2, IMapPoint p3)
        {
            IS3PointCollection pts = new IS3PointCollection();

            pts.Add(p1 as IS3MapPoint);
            pts.Add(p2 as IS3MapPoint);
            pts.Add(p3 as IS3MapPoint);
            pts.Add(p1 as IS3MapPoint);
            return(newPolygon(pts));
        }
Beispiel #11
0
 public static IGraphic NewQuadrilateral(IMapPoint p1, IMapPoint p2, IMapPoint p3, IMapPoint p4)
 {
     IPointCollection pc = Runtime.geometryEngine.newPointCollection();
     pc.Add(p1);
     pc.Add(p2);
     pc.Add(p3);
     pc.Add(p4);
     //pc.Add(p1);
     return NewPolygon(pc);
 }
        public IGraphic newQuadrilateral(IMapPoint p1, IMapPoint p2,
                                         IMapPoint p3, IMapPoint p4)
        {
            IS3PointCollection pts = new IS3PointCollection();

            pts.Add(p1 as IS3MapPoint);
            pts.Add(p2 as IS3MapPoint);
            pts.Add(p3 as IS3MapPoint);
            pts.Add(p4 as IS3MapPoint);
            return(newPolygon(pts));
        }
Beispiel #13
0
        public void ShipCorrectlyReportedAsSank()
        {
            var mp = new IMapPoint[2] {
                shotShipPoint.Object, shotShipPoint.Object
            };

            _ship = new Ship(mp);

            Assert.IsTrue(_ship.WasHit);
            Assert.IsTrue(_ship.WasSank);
        }
        public IGraphic newPentagon(IMapPoint p1, IMapPoint p2,
                                    IMapPoint p3, IMapPoint p4, IMapPoint p5)
        {
            IS3PointCollection pts = new IS3PointCollection();

            pts.Add(p1 as IS3MapPoint);
            pts.Add(p2 as IS3MapPoint);
            pts.Add(p3 as IS3MapPoint);
            pts.Add(p4 as IS3MapPoint);
            pts.Add(p5 as IS3MapPoint);
            return(newPolygon(pts));
        }
        private static void Postfix(MobileParty mobileParty, PartyThinkParams p)
        {
            Hero owner = mobileParty.Party.Owner;

            if (mobileParty?.LeaderHero == null)
            {
                return;
            }
            Equipment owner_equipment   = owner.BattleEquipment;
            float     total_owner_armor = owner_equipment.GetHeadArmorSum() + owner_equipment.GetHumanBodyArmorSum() +
                                          owner_equipment.GetLegArmorSum() + owner_equipment.GetArmArmorSum();
            Equipment leader_equipment   = owner.BattleEquipment;
            float     total_leader_armor = leader_equipment.GetHeadArmorSum() + leader_equipment.GetHumanBodyArmorSum() +
                                           leader_equipment.GetLegArmorSum() + leader_equipment.GetArmArmorSum();

            if (total_owner_armor < 9000)
            {
                return;
            }
            foreach (KeyValuePair <AIBehaviorTuple, float> keyValuePair in p.AIBehaviorScores.ToList())
            {
                float     value  = keyValuePair.Value;
                IMapPoint target = keyValuePair.Key.Party;
                if (keyValuePair.Key.AiBehavior == AiBehavior.GoToSettlement)
                {
                    p.AIBehaviorScores[keyValuePair.Key] = value * 1.7f;
                }
                else if (keyValuePair.Key.AiBehavior == AiBehavior.DefendSettlement || keyValuePair.Key.AiBehavior == AiBehavior.PatrolAroundPoint)
                {
                    if (((Settlement)keyValuePair.Key.Party).OwnerClan == mobileParty.LeaderHero.Clan)
                    {
                        p.AIBehaviorScores[keyValuePair.Key] = value * 1.4f;
                    }
                    else
                    {
                        p.AIBehaviorScores[keyValuePair.Key] = value * 1.4f;
                    }
                }
                else if (keyValuePair.Key.AiBehavior == AiBehavior.BesiegeSettlement || keyValuePair.Key.AiBehavior == AiBehavior.AssaultSettlement)
                {
                    p.AIBehaviorScores[keyValuePair.Key] = value * 2.0f;
                }
                else if (keyValuePair.Key.AiBehavior == AiBehavior.RaidSettlement)
                {
                    p.AIBehaviorScores[keyValuePair.Key] = 0f;
                }
                else if (keyValuePair.Key.AiBehavior == AiBehavior.EngageParty)
                {
                    InformationManager.DisplayMessage(new InformationMessage("EngageParty: " + keyValuePair.Key.Party.Name?.ToString() + " " + keyValuePair.Value));
                }
            }
        }
Beispiel #16
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);
        }
        // Project a point to polyline.
        // point: (p), polyline: (pts)
        // output distance relative to the start point of the polyline: (distance)
        // output projection point: (outPnt)
        // return value:
        //      true: the point is projected on the polyline without extending the polyline
        //      false: the point is projected on the polyline through extending the polyline
        //
        public static bool ProjectPointToPolyline(IMapPoint p,
                                                  IPointCollection pts, ref double distance, ref IMapPoint outPnt)
        {
            distance = 0.0;

            double    outx = 0.0, outy = 0.0;
            IMapPoint p0, p1;

            for (int i = 0; i < pts.Count - 1; ++i)
            {
                p0 = pts[i];
                p1 = pts[i + 1];

                bool canProject = GeometryAlgorithms.ProjectPointToLine(p.X, p.Y,
                                                                        p0.X, p0.Y, p1.X, p1.Y, ref outx, ref outy);

                if (canProject == true)
                {
                    distance += GeometryAlgorithms.PointDistanceToPoint(outx, outy, p0.X, p0.Y);
                    outPnt    = Runtime.geometryEngine.newMapPoint(outx, outy);
                    return(true);
                }
                distance += GeometryAlgorithms.PointDistanceToPoint(p0.X, p0.Y, p1.X, p1.Y);
            }

            // Project the point by extending the polyline
            p0 = pts[0];
            p1 = pts[pts.Count - 1];
            double d0p = GeometryAlgorithms.PointDistanceToPoint(p.X, p.Y, p0.X, p0.Y);
            double d1p = GeometryAlgorithms.PointDistanceToPoint(p.X, p.Y, p1.X, p1.Y);

            if (d0p < d1p)
            {
                // the map point is closer to the beginning of the polyline,
                // then extend the beginning segment.
                p1 = pts[1];
                GeometryAlgorithms.ProjectPointToLine(p.X, p.Y,
                                                      p0.X, p0.Y, p1.X, p1.Y, ref outx, ref outy);
                distance  = GeometryAlgorithms.PointDistanceToPoint(outx, outy, p0.X, p0.Y);
                distance *= -1.0;
                outPnt    = Runtime.geometryEngine.newMapPoint(outx, outy);
            }
            else
            {
                // the map point is closer to the endding of the polyline,
                // since the loop is ended on the last segment, just use the result is OK.
                distance += GeometryAlgorithms.PointDistanceToPoint(outx, outy, p1.X, p1.Y);
                outPnt    = Runtime.geometryEngine.newMapPoint(outx, outy);
            }
            return(false);
        }
Beispiel #18
0
        // Project a point to polyline.
        // point: (p), polyline: (pts)
        // output distance relative to the start point of the polyline: (distance)
        // output projection point: (outPnt)
        // return value:
        //      true: the point is projected on the polyline without extending the polyline
        //      false: the point is projected on the polyline through extending the polyline
        //
        public static bool ProjectPointToPolyline(IMapPoint p,
            IPointCollection pts,ref double distance, ref IMapPoint outPnt)
        {
            distance = 0.0;

            double outx = 0.0, outy = 0.0;
            IMapPoint p0, p1;
            for (int i = 0; i < pts.Count - 1; ++i)
            {
                p0 = pts[i];
                p1 = pts[i + 1];

                bool canProject = GeometryAlgorithms.ProjectPointToLine(p.X, p.Y,
                    p0.X, p0.Y, p1.X, p1.Y, ref outx, ref outy);

                if (canProject == true)
                {
                    distance += GeometryAlgorithms.PointDistanceToPoint(outx, outy, p0.X, p0.Y);
                    outPnt = Runtime.geometryEngine.newMapPoint(outx, outy);
                    return true;
                }
                distance += GeometryAlgorithms.PointDistanceToPoint(p0.X, p0.Y, p1.X, p1.Y);
            }

            // Project the point by extending the polyline
            p0 = pts[0];
            p1 = pts[pts.Count - 1];
            double d0p = GeometryAlgorithms.PointDistanceToPoint(p.X, p.Y, p0.X, p0.Y);
            double d1p = GeometryAlgorithms.PointDistanceToPoint(p.X, p.Y, p1.X, p1.Y);
            if (d0p < d1p)
            {
                // the map point is closer to the beginning of the polyline,
                // then extend the beginning segment.
                p1 = pts[1];
                GeometryAlgorithms.ProjectPointToLine(p.X, p.Y,
                    p0.X, p0.Y, p1.X, p1.Y, ref outx, ref outy);
                distance = GeometryAlgorithms.PointDistanceToPoint(outx, outy, p0.X, p0.Y);
                distance *= -1.0;
                outPnt = Runtime.geometryEngine.newMapPoint(outx, outy);
            }
            else
            {
                // the map point is closer to the endding of the polyline,
                // since the loop is ended on the last segment, just use the result is OK.
                distance += GeometryAlgorithms.PointDistanceToPoint(outx, outy, p1.X, p1.Y);
                outPnt = Runtime.geometryEngine.newMapPoint(outx, outy);
            }
            return false;
        }
        public static IMapPoint Center(IPolygon polygon)
        {
            IEnumerable <IMapPoint> pc = polygon.GetPoints();
            double x = 0;
            double y = 0;

            foreach (IMapPoint p in pc)
            {
                x += p.X;
                y += p.Y;
            }
            x /= pc.Count();
            y /= pc.Count();
            IMapPoint center = Runtime.geometryEngine.newMapPoint(x, y);

            return(center);
        }
        // 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 IGraphic newText(string text, IMapPoint p, Color color,
                                string fontName, double fontSize)
        {
            IS3TextSymbol textSymbol = new IS3TextSymbol();

            textSymbol.Text  = text;
            textSymbol.Color = color;

            IS3SymbolFont font = new IS3SymbolFont(fontName, fontSize);

            textSymbol.Font = font;

            IS3Graphic g = new IS3Graphic();

            g.Symbol   = textSymbol;
            g.Geometry = p;

            return(g);
        }
Beispiel #22
0
        private async static Task <bool> SearchDirectionsAsyncInternal(IMapPoint startPoint, IMapPoint endPoint, MapOptions options)
        {
            var startPointStr = startPoint == null ? String.Empty : startPoint.ToString();
            var endPointStr   = endPoint == null ? String.Empty : endPoint.ToString();

            var sb = new StringBuilder();

            if (options != null)
            {
                sb.Append(OptionsToString(options));
            }

            if (!String.IsNullOrWhiteSpace(startPointStr) || !String.IsNullOrWhiteSpace(endPointStr))
            {
                sb.AppendFormat("&rtp={0}~{1}", startPointStr, endPointStr);
            }

            return(await LaunchMapApp(sb.ToString()));
        }
        private async static Task<bool> SearchDirectionsAsyncInternal(IMapPoint startPoint, IMapPoint endPoint, MapOptions options)
        {
            var startPointStr = startPoint == null ? String.Empty : startPoint.ToString();
            var endPointStr = endPoint == null ? String.Empty : endPoint.ToString();

            var sb = new StringBuilder();

            if (options != null)
            {
                sb.Append(OptionsToString(options));
            }

            if (!String.IsNullOrWhiteSpace(startPointStr) || !String.IsNullOrWhiteSpace(endPointStr))
            {
                sb.AppendFormat("&rtp={0}~{1}", startPointStr, endPointStr);
            }

            return await LaunchMapApp(sb.ToString());
        }
Beispiel #24
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);
        }
        private static void UpdateMessengerPosition(Messenger messenger)
        {
            IMapPoint targetHeroLocationPoint = messenger.TargetHero.GetMapPoint();

            if (messenger.CurrentPosition.Equals(default(Vec2)) || targetHeroLocationPoint == null)
            {
                return;
            }

            Vec2 targetHeroLocation = targetHeroLocationPoint.Position2D;
            Vec2 distanceToGo       = targetHeroLocation - messenger.CurrentPosition;

            if (distanceToGo.Length <= MessengerHourlySpeed)
            {
                messenger.Arrived = true;
            }
            else
            {
                messenger.CurrentPosition += distanceToGo.Normalized() * MessengerHourlySpeed;
            }
        }
Beispiel #26
0
        private void Spawn(IMapPoint mobileParty, TroopRoster party, TroopRoster prisoners)
        {
            MobileParty = MBObjectManager.Instance.CreateObject <MobileParty>("Bandit_Militia");
            MobileParty.InitializeMobileParty(
                party,
                prisoners,
                mobileParty.Position2D,
                0);
            var mostPrevalent = (Clan)MostPrevalentFaction(MobileParty) ?? Clan.BanditFactions.First();

            MobileParty.ActualClan = mostPrevalent;
            Hero = HeroCreatorCopy.CreateBanditHero(mostPrevalent, MobileParty);
            var faction = Clan.BanditFactions.FirstOrDefault(x => Hero.MapFaction.Name == x.Name);

            Hero.Culture = faction == null?Clan.All.FirstOrDefault(x => x.Name.ToString() == "Looters")?.Culture : faction.Culture;

            Name = (string)Traverse.Create(typeof(MBTextManager))
                   .Method("GetLocalizedText", $"{Possess(Hero.FirstName.ToString())} Bandit Militia").GetValue();
            MobileParty.SetCustomName(new TextObject(Name));
            MobileParty.Party.Owner             = Hero;
            MobileParty.Leader.StringId        += "_Bandit_Militia";
            MobileParty.ShouldJoinPlayerBattles = true;
        }
Beispiel #27
0
 public IGraphic newPentagon(IMapPoint p1, IMapPoint p2,
     IMapPoint p3, IMapPoint p4, IMapPoint p5)
 {
     IS3PointCollection pts = new IS3PointCollection();
     pts.Add(p1 as IS3MapPoint);
     pts.Add(p2 as IS3MapPoint);
     pts.Add(p3 as IS3MapPoint);
     pts.Add(p4 as IS3MapPoint);
     pts.Add(p5 as IS3MapPoint);
     return newPolygon(pts);
 }
Beispiel #28
0
 public Point locationToScreen(IMapPoint mapPoint)
 {
     return(_mapView.LocationToScreen(mapPoint as MapPoint));
 }
Beispiel #29
0
        public IGraphic newText(string text, IMapPoint p, Color color,
            string fontName, double fontSize)
        {
            IS3TextSymbol textSymbol = new IS3TextSymbol();
            textSymbol.Text = text;
            textSymbol.Color = color;

            IS3SymbolFont font = new IS3SymbolFont(fontName, fontSize);
            textSymbol.Font = font;

            IS3Graphic g = new IS3Graphic();
            
            g.Symbol = textSymbol;
            g.Geometry = p;

            return g;
        }
 static IGraphic NewQuadrilateral(IMapPoint p1, IMapPoint p2, IMapPoint p3, IMapPoint p4)
 {
     return Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4);
 }
Beispiel #31
0
 public Point locationToScreen(IMapPoint mapPoint)
 {
     return _mapView.LocationToScreen(mapPoint as MapPoint);
 }
Beispiel #32
0
 System.Windows.Point IView2D.locationToScreen(IMapPoint mapPoint)
 {
     throw new NotImplementedException();
 }
Beispiel #33
0
 public static IMapPoint MidPoint(IMapPoint p1, IMapPoint p2)
 {
     double x = (p1.X + p2.X) / 2.0;
     double y = (p1.Y + p2.Y) / 2.0;
     IMapPoint p = Runtime.geometryEngine.newMapPoint(x, y);
     return p;
 }
Beispiel #34
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; //保存结果
                }
            }
        }
Beispiel #35
0
 public System.Windows.Point locationToScreen(IMapPoint mapPoint)
 {
     return(new System.Windows.Point());
 }
        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);
                }
            }
        }
Beispiel #37
0
        public static IPointCollection VectorArrowPoints(double beginPntX, double beginPntY, IMapPoint endPnt)
        {
            double x = beginPntX - endPnt.X;
            double y = beginPntY - endPnt.Y;
            double angle = Math.Atan2(y, x);

            double alpha = Math.PI / 6;                         // arrow is 30 degree by each side of original line
            double length = Math.Sqrt(x * x + y * y) * 0.25;      // arrow is a quarter of original length 

            double x1 = endPnt.X + length * Math.Cos(angle + alpha);
            double y1 = endPnt.Y + length * Math.Sin(angle + alpha);
            double x2 = endPnt.X + length * Math.Cos(angle - alpha);
            double y2 = endPnt.Y + length * Math.Sin(angle - alpha);

            IMapPoint p1 = Runtime.geometryEngine.newMapPoint(x1, y1);
            IMapPoint p2 = Runtime.geometryEngine.newMapPoint(x2, y2);

            IPointCollection pc = Runtime.geometryEngine.newPointCollection();
            pc.Add(p1);
            pc.Add(endPnt);
            pc.Add(p2);

            return pc;
        }
Beispiel #38
0
 public static IMapPoint InterpolatePointOnLine(IMapPoint p1, IMapPoint p2, double scale)
 {
     double x = 0.0, y = 0.0;
     GeometryAlgorithms.InterpolatePointOnLine(p1.X, p1.Y, p2.X, p2.Y, scale, ref x, ref y);
     IMapPoint p = Runtime.geometryEngine.newMapPoint(x, y);
     return p;
 }
Beispiel #39
0
 public IGraphic newQuadrilateral(IMapPoint p1, IMapPoint p2,
     IMapPoint p3, IMapPoint p4)
 {
     IS3PointCollection pts = new IS3PointCollection();
     pts.Add(p1 as IS3MapPoint);
     pts.Add(p2 as IS3MapPoint);
     pts.Add(p3 as IS3MapPoint);
     pts.Add(p4 as IS3MapPoint);
     return newPolygon(pts);
 }
 public static double Distance(IMapPoint p1, IMapPoint p2)
 {
     return(GeometryAlgorithms.PointDistanceToPoint(p1.X, p1.Y, p2.X, p2.Y));
 }
Beispiel #41
0
 public IGraphic newTriangle(IMapPoint p1, IMapPoint p2, IMapPoint p3)
 {
     IS3PointCollection pts = new IS3PointCollection();
     pts.Add(p1 as IS3MapPoint);
     pts.Add(p2 as IS3MapPoint);
     pts.Add(p3 as IS3MapPoint);
     pts.Add(p1 as IS3MapPoint);
     return newPolygon(pts);
 }
Beispiel #42
0
 public System.Windows.Point locationToScreen(IMapPoint mapPoint)
 { return new System.Windows.Point(); }
Beispiel #43
0
 public System.Windows.Point locationToScreen(IMapPoint mapPoint)
 {
     return(_mapView.LocationToScreen(mapPoint as MapPoint));
 }
 public void Add(IMapPoint item)
 {
     base.Add(item as IS3MapPoint);
 }
 static IGraphic NewTriangle(IMapPoint p1, IMapPoint p2, IMapPoint p3)
 {
     return Runtime.graphicEngine.newTriangle(p1, p2, p3);
 }
Beispiel #46
0
 /// <summary> Write the geometry to stream
 /// </summary>
 /// <param name="geometry">Geometry</param>
 /// <param name="writer">BinaryWriter</param>
 /// <param name="byteOrder">Byte order</param>
 private static void WriteMapPoint(IMapPoint geometry, BinaryWriter writer, WkbByteOrder byteOrder)
 {
     WriteDouble(geometry.X, writer, byteOrder);
     WriteDouble(geometry.Y, writer, byteOrder);
 }
 static IGraphic NewPentagon(IMapPoint p1, IMapPoint p2, IMapPoint p3, IMapPoint p4, IMapPoint p5)
 {
     return Runtime.graphicEngine.newPentagon(p1, p2, p3, p4, p5);
 }
Beispiel #48
0
 public bool Equals(IMapPoint other)
 {
     return(!ReferenceEquals(other, null) && Map == other.Map && Location == other.Location);
 }
Beispiel #49
0
 public static double Distance(IMapPoint p1, IMapPoint p2)
 {
     return GeometryAlgorithms.PointDistanceToPoint(p1.X, p1.Y, p2.X, p2.Y);
 }
 /// <summary>
 /// Searches driving directions for provided points
 /// </summary>
 public static IAsyncOperation<bool> SearchDirectionsAsync(IMapPoint startPoint, IMapPoint endPoint, MapOptions options)
 {
     return AsyncInfo.Run(token => SearchDirectionsAsyncInternal(startPoint, endPoint, options));
 }