Ejemplo n.º 1
0
        public void RoundTripLeg()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            Leg               leg1, leg2, leg3, leg4, leg5, leg6;
            ControlPoint      ctl1, ctl2;
            Id <ControlPoint> ctlId1, ctlId2;

            undomgr.BeginCommand(81, "Command1");

            ctl1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(10, 10));
            ctl1.symbolIds[0] = "0.3";
            ctl1.symbolIds[1] = "2.4";
            ctl1.columnFText  = "2m";
            ctlId1            = eventDB.AddControlPoint(ctl1);

            ctl2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(20, -10.5F));
            ctl2.symbolIds[1] = "3.7";
            ctl2.symbolIds[5] = "12.1";
            ctl2.gaps         = new Dictionary <int, CircleGap[]>();
            ctl2.gaps.Add(15000, CircleGap.ComputeCircleGaps(0xFFFFFFDF));
            ctl2.gaps.Add(10000, CircleGap.ComputeCircleGaps(0xFF00FFFF));
            ctl2.descriptionText = "very marshy spot";
            ctlId2 = eventDB.AddControlPoint(ctl2);

            leg1 = new Leg(ctlId1, ctlId2);
            eventDB.AddLeg(leg1);

            leg2          = new Leg(ctlId1, ctlId2);
            leg2.flagging = FlaggingKind.All;
            eventDB.AddLeg(leg2);

            leg3               = new Leg(ctlId1, ctlId2);
            leg3.flagging      = FlaggingKind.Begin;
            leg3.flagStartStop = new PointF(5, -7.5F);
            leg3.bends         = new PointF[2] {
                leg3.flagStartStop, new PointF(17, 6)
            };
            eventDB.AddLeg(leg3);

            leg4               = new Leg(ctlId1, ctlId2);
            leg4.flagging      = FlaggingKind.End;
            leg4.flagStartStop = new PointF(5, -7.5F);
            leg4.bends         = new PointF[1] {
                leg4.flagStartStop
            };
            leg4.gaps = new LegGap[2] {
                new LegGap(2, 0.3F), new LegGap(3.4F, 0.4F)
            };
            eventDB.AddLeg(leg4);

            leg5      = new Leg(ctlId1, ctlId2);
            leg5.gaps = new LegGap[3] {
                new LegGap(0.9F, 0.3F), new LegGap(3.4F, 0.4F), new LegGap(4.5F, 1.1F)
            };
            eventDB.AddLeg(leg5);

            leg6               = new Leg(ctlId1, ctlId2);
            leg6.flagging      = FlaggingKind.IssuePointMiddle;
            leg6.flagStartStop = new PointF(5, -7.5F);
            leg6.bends         = new PointF[1] {
                leg6.flagStartStop
            };
            eventDB.AddLeg(leg6);


            undomgr.EndCommand(81);

            eventDB.Validate();

            eventDB.Save(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml"));

            undomgr.Clear();
            eventDB = new EventDB(undomgr);

            eventDB.Load(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml"));
            eventDB.Validate();

            TestUtil.TestEnumerableAnyOrder(eventDB.AllLegPairs,
                                            new KeyValuePair <Id <Leg>, Leg>[] {
                new KeyValuePair <Id <Leg>, Leg>(LegId(1), leg1),
                new KeyValuePair <Id <Leg>, Leg>(LegId(2), leg2),
                new KeyValuePair <Id <Leg>, Leg>(LegId(3), leg3),
                new KeyValuePair <Id <Leg>, Leg>(LegId(4), leg4),
                new KeyValuePair <Id <Leg>, Leg>(LegId(5), leg5),
                new KeyValuePair <Id <Leg>, Leg>(LegId(6), leg6)
            }
                                            );
        }
Ejemplo n.º 2
0
        public void ComputeStraightLineControlDistance()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            ControlPoint control1, control2, control3;
            Leg leg1;
            Event ev = new Event();

            control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4.5F, -10.1F));
            control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-6.8F, 14.1F));
            control3 = new ControlPoint(ControlPointKind.Normal, "33", new PointF(-12.8F, 32.9F));
            undomgr.BeginCommand(123, "Add controls");
            Id<ControlPoint> id1 = eventDB.AddControlPoint(control1);
            Id<ControlPoint> id2 = eventDB.AddControlPoint(control2);
            Id<ControlPoint> id3 = eventDB.AddControlPoint(control3);

            leg1 = new Leg(id1, id2);
            leg1.bends = new PointF[] { new PointF(7, 8), new PointF(10, 14) };
            Id<Leg> legId = eventDB.AddLeg(leg1);

            ev.mapScale = 15000;
            eventDB.ChangeEvent(ev);
            undomgr.EndCommand(123);

            float length = QueryEvent.ComputeStraightLineControlDistance(eventDB, id1, id2);
            Assert.AreEqual(400.62F, length, 0.01F);  // Doesn't take bend in leg into account!

            length = QueryEvent.ComputeStraightLineControlDistance(eventDB, id3, id2);
            Assert.AreEqual(296.01F, length, 0.01F);
        }
Ejemplo n.º 3
0
        public void ComputeLegLengthBends()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            ControlPoint control1, control2;
            Leg leg1;
            Event ev = new Event();

            control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4.5F, -10.1F));
            control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-6.8F, 14.1F));
            undomgr.BeginCommand(123, "Add controls");
            Id<ControlPoint> id1 = eventDB.AddControlPoint(control1);
            Id<ControlPoint> id2 = eventDB.AddControlPoint(control2);

            leg1 = new Leg(id1, id2);
            leg1.bends = new PointF[] { new PointF(7, 8), new PointF(10, 14) };
            Id<Leg> legId = eventDB.AddLeg(leg1);

            ev.mapScale = 15000;
            eventDB.ChangeEvent(ev);
            undomgr.EndCommand(123);

            float length = QueryEvent.ComputeLegLength(eventDB, id1, id2, legId);

            Assert.AreEqual(626.7, length, 0.01);

            SymPath path = QueryEvent.GetLegPath(eventDB, id1, id2);
            Assert.AreEqual(new SymPath(new PointF[] { new PointF(4.5F, -10.1F), new PointF(7, 8), new PointF(10, 14), new PointF(-6.8F, 14.1F) }), path);
        }
Ejemplo n.º 4
0
        public void ComputeFlaggedLegLength()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            ControlPoint control1, control2;
            Leg leg1;
            Event ev = new Event();

            control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4F, -10F));
            control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-3F, 14F));
            undomgr.BeginCommand(123, "Add controls");
            Id<ControlPoint> id1 = eventDB.AddControlPoint(control1);
            Id<ControlPoint> id2 = eventDB.AddControlPoint(control2);

            leg1 = new Leg(id1, id2);
            leg1.bends = new PointF[] { new PointF(6, 3), new PointF(7, 8), new PointF(10, 14) };
            Id<Leg> legId = eventDB.AddLeg(leg1);

            // distances. 13.153, 5.099, 6.708, 13.00   * 15000

            ev.mapScale = 15000;
            eventDB.ChangeEvent(ev);
            undomgr.EndCommand(123);

            float length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId);
            Assert.AreEqual(569.4, length, 0.01);

            undomgr.BeginCommand(123, "Change leg");
            leg1.flagging = FlaggingKind.All;
            eventDB.ReplaceLeg(legId, leg1);
            undomgr.EndCommand(123);
            length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId);
            Assert.AreEqual(569.4, length, 0.01);

            undomgr.BeginCommand(123, "Change leg");
            leg1.flagging = FlaggingKind.Begin;
            leg1.flagStartStop = new PointF(7, 8);
            eventDB.ReplaceLeg(legId, leg1);
            undomgr.EndCommand(123);
            length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId);
            Assert.AreEqual(273.78, length, 0.01);

            undomgr.BeginCommand(123, "Change leg");
            leg1.flagging = FlaggingKind.End;
            eventDB.ReplaceLeg(legId, leg1);
            undomgr.EndCommand(123);
            length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId);
            Assert.AreEqual(295.62, length, 0.01);
        }
Ejemplo n.º 5
0
        public void FindLeg()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            ControlPoint control1, control2, control3, control4;
            Leg leg1, leg2;
            Id<Leg> legId1, legId2;
            Event ev = new Event();

            control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4.5F, -10.1F));
            control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-6.8F, 14.1F));
            control3 = new ControlPoint(ControlPointKind.Normal, "33", new PointF(5F, 19F));
            control4 = new ControlPoint(ControlPointKind.Normal, "34", new PointF(18F, 1F));
            undomgr.BeginCommand(124, "Add controls");
            Id<ControlPoint> id1 = eventDB.AddControlPoint(control1);
            Id<ControlPoint> id2 = eventDB.AddControlPoint(control2);
            Id<ControlPoint> id3 = eventDB.AddControlPoint(control3);
            Id<ControlPoint> id4 = eventDB.AddControlPoint(control4);

            leg1 = new Leg(id1, id2);
            legId1 = eventDB.AddLeg(leg1);
            leg2 = new Leg(id4, id2);
            legId2 = eventDB.AddLeg(leg2);

            undomgr.EndCommand(124);

            Id<Leg> result = QueryEvent.FindLeg(eventDB, id1, id3);
            Assert.IsTrue(result.IsNone);
            result = QueryEvent.FindLeg(eventDB, id2, id1);
            Assert.IsTrue(result.IsNone);
            result = QueryEvent.FindLeg(eventDB, id3, id2);
            Assert.IsTrue(result.IsNone);
            result = QueryEvent.FindLeg(eventDB, id1, id2);
            Assert.IsTrue(result == legId1);
            result = QueryEvent.FindLeg(eventDB, id4, id2);
            Assert.IsTrue(result == legId2);
        }
Ejemplo n.º 6
0
        public void RoundTripLeg()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            Leg leg1, leg2, leg3, leg4, leg5;
            ControlPoint ctl1, ctl2;
            Id<ControlPoint> ctlId1, ctlId2;

            undomgr.BeginCommand(81, "Command1");

            ctl1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(10, 10));
            ctl1.symbolIds[0] = "0.3";
            ctl1.symbolIds[1] = "2.4";
            ctl1.columnFText = "2m";
            ctlId1 = eventDB.AddControlPoint(ctl1);

            ctl2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(20, -10.5F));
            ctl2.symbolIds[1] = "3.7";
            ctl2.symbolIds[5] = "12.1";
            ctl2.gaps = new Dictionary<int, CircleGap[]>();
            ctl2.gaps.Add(15000, CircleGap.ComputeCircleGaps(0xFFFFFFDF));
            ctl2.gaps.Add(10000, CircleGap.ComputeCircleGaps(0xFF00FFFF));
            ctl2.descriptionText = "very marshy spot";
            ctlId2 = eventDB.AddControlPoint(ctl2);

            leg1 = new Leg(ctlId1, ctlId2);
            eventDB.AddLeg(leg1);

            leg2 = new Leg(ctlId1, ctlId2);
            leg2.flagging = FlaggingKind.All;
            eventDB.AddLeg(leg2);

            leg3 = new Leg(ctlId1, ctlId2);
            leg3.flagging = FlaggingKind.Begin;
            leg3.flagStartStop = new PointF(5, -7.5F);
            leg3.bends = new PointF[2] { leg3.flagStartStop, new PointF(17, 6) };
            eventDB.AddLeg(leg3);

            leg4 = new Leg(ctlId1, ctlId2);
            leg4.flagging = FlaggingKind.End;
            leg4.flagStartStop = new PointF(5, -7.5F);
            leg4.bends = new PointF[1] { leg4.flagStartStop };
            leg4.gaps = new LegGap[2] { new LegGap(2, 0.3F), new LegGap(3.4F, 0.4F)};
            eventDB.AddLeg(leg4);

            leg5 = new Leg(ctlId1, ctlId2);
            leg5.gaps = new LegGap[3] { new LegGap(0.9F, 0.3F), new LegGap(3.4F, 0.4F), new LegGap(4.5F, 1.1F) };
            eventDB.AddLeg(leg5);

            undomgr.EndCommand(81);

            eventDB.Validate();

            eventDB.Save(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml"));

            undomgr.Clear();
            eventDB = new EventDB(undomgr);

            eventDB.Load(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml"));
            eventDB.Validate();

            TestUtil.TestEnumerableAnyOrder(eventDB.AllLegPairs,
                new KeyValuePair<Id<Leg>, Leg>[] {
                    new KeyValuePair<Id<Leg>,Leg>(LegId(1), leg1),
                    new KeyValuePair<Id<Leg>,Leg>(LegId(2), leg2),
                    new KeyValuePair<Id<Leg>,Leg>(LegId(3), leg3),
                    new KeyValuePair<Id<Leg>,Leg>(LegId(4), leg4),
                    new KeyValuePair<Id<Leg>,Leg>(LegId(5), leg5)
                }
            );
        }