Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Distance"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal Distance(EditDeserializer editDeserializer)
        {
            double           distance = editDeserializer.ReadDouble(DataField.Value);
            DistanceUnitType unitType = (DistanceUnitType)editDeserializer.ReadByte(DataField.Unit);

            m_EnteredUnit    = EditingController.GetUnits(unitType);
            m_ObservedMetric = m_EnteredUnit.ToMetric(distance);

            if (editDeserializer.IsNextField(DataField.Fixed))
            {
                m_IsFixed = editDeserializer.ReadBool(DataField.Fixed);
            }
            else
            {
                m_IsFixed = false;
            }

            if (editDeserializer.IsNextField(DataField.Flipped))
            {
                IsAnnotationFlipped = editDeserializer.ReadBool(DataField.Flipped);
            }
            else
            {
                IsAnnotationFlipped = false;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ParallelLineOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal ParallelLineOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_RefLine = editDeserializer.ReadFeatureRef <LineFeature>(this, DataField.RefLine);

            if (editDeserializer.IsNextField(DataField.Term1))
            {
                m_Term1 = editDeserializer.ReadFeatureRef <LineFeature>(this, DataField.Term1);
            }

            if (editDeserializer.IsNextField(DataField.Term2))
            {
                m_Term2 = editDeserializer.ReadFeatureRef <LineFeature>(this, DataField.Term2);
            }

            if (editDeserializer.IsNextField(DataField.ReverseArc) && editDeserializer.ReadBool(DataField.ReverseArc) == true)
            {
                m_Flags = 1;
            }

            m_Offset = editDeserializer.ReadPersistent <Observation>(DataField.Offset);

            DeserializationFactory dff = new DeserializationFactory(this);

            dff.AddFeatureStub(DataField.From, editDeserializer.ReadPersistentOrNull <FeatureStub>(DataField.From));
            dff.AddFeatureStub(DataField.To, editDeserializer.ReadPersistentOrNull <FeatureStub>(DataField.To));
            dff.AddFeatureStub(DataField.NewLine, editDeserializer.ReadPersistent <FeatureStub>(DataField.NewLine));
            ProcessFeatures(dff);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LineSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal LineSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Line = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Line);
            m_Face = editDeserializer.ReadPersistent <LineSubdivisionFace>(DataField.Face);
            //FeatureStub[] sections = editDeserializer.ReadFeatureStubArray(DataField.Result);

            if (editDeserializer.IsNextField(DataField.OtherSide))
            {
                InternalIdValue id = editDeserializer.ReadInternalId(DataField.OtherSide);
                OtherSide = (LineSubdivisionOperation)editDeserializer.MapModel.FindOperation(id);
                Debug.Assert(OtherSide != null);
                OtherSide.OtherSide = this;
            }

            Project p         = editDeserializer.Project;
            IEntity pointType = editDeserializer.ReadEntity(DataField.PointType);

            FeatureStub[] sections = CreateStubs(p, pointType, m_Line.EntityType);

            DeserializationFactory result = new DeserializationFactory(this, sections);

            ProcessFeatures(result);

            // Apply any IDs
            if (editDeserializer.IsNextField(DataField.Ids))
            {
                editDeserializer.ReadIdMappings(DataField.Ids);
            }
        }
Exemple #4
0
 /// <summary>
 /// Reads data that was previously written using <see cref="WriteData"/>
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <param name="line1">The 1st line to intersect.</param>
 /// <param name="line2">The 2nd line to intersect.</param>
 /// <param name="closeTo">The point closest to the intersection.</param>
 /// <param name="to">The created intersection point (if any). May have existed previously.</param>
 /// <param name="idLine1a">The ID of the portion of the first line prior to the intersection (null if no split).</param>
 /// <param name="idLine1b">The ID of the portion of the first line after the intersection (null if no split).</param>
 /// <param name="idLine2a">The ID of the portion of the second line prior to the intersection (null if no split).</param>
 /// <param name="idLine2b">The ID of the portion of the second line after the intersection (null if no split).</param>
 static void ReadData(EditDeserializer editDeserializer, out LineFeature line1, out LineFeature line2, out PointFeature closeTo,
                      out FeatureStub to, out string idLine1a, out string idLine1b, out string idLine2a, out string idLine2b)
 {
     line1    = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Line1);
     line2    = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Line2);
     closeTo  = editDeserializer.ReadFeatureRef <PointFeature>(DataField.CloseTo);
     to       = editDeserializer.ReadPersistent <FeatureStub>(DataField.To);
     idLine1a = (editDeserializer.IsNextField(DataField.SplitBefore1) ? editDeserializer.ReadString(DataField.SplitBefore1) : null);
     idLine1b = (editDeserializer.IsNextField(DataField.SplitAfter1) ? editDeserializer.ReadString(DataField.SplitAfter1) : null);
     idLine2a = (editDeserializer.IsNextField(DataField.SplitBefore2) ? editDeserializer.ReadString(DataField.SplitBefore2) : null);
     idLine2b = (editDeserializer.IsNextField(DataField.SplitAfter2) ? editDeserializer.ReadString(DataField.SplitAfter2) : null);
 }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PathOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal PathOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            //try
            //{
            m_From             = editDeserializer.ReadFeatureRef <PointFeature>(DataField.From);
            m_To               = editDeserializer.ReadFeatureRef <PointFeature>(DataField.To);
            m_EntryString      = editDeserializer.ReadString(DataField.EntryString);
            m_DefaultEntryUnit = editDeserializer.ReadDistanceUnit(DataField.DefaultEntryUnit);

            Leg[] legs = PathParser.CreateLegs(m_EntryString, m_DefaultEntryUnit);
            PrepareLegs(this.EditSequence, legs);
            m_Legs = new List <Leg>(legs);

            Project p         = editDeserializer.Project;
            IEntity pointType = editDeserializer.ReadEntity(DataField.PointType);
            IEntity lineType  = editDeserializer.ReadEntity(DataField.LineType);

            // Pick up any alternate faces (these may be defined ONLY when dealing with
            // data files that were derived from old CEdit files). The deserializaing
            // constructor will connect the alternate faces to the legs we've just
            // created.
            if (editDeserializer.IsNextField(DataField.AlternateFaces))
            {
                editDeserializer.ReadPersistentArray <LegFace>(DataField.AlternateFaces);
            }

            // Create stubs for everything that we could conceivably create (including
            // any alternate faces).
            FeatureStub[] stubs = CreateStubs(p, pointType, lineType);

            var result = new DeserializationFactory(this, stubs);

            result.PointType = pointType;
            result.LineType  = lineType;

            // Create feature objects
            ProcessFeatures(result);

            // Apply any IDs
            if (editDeserializer.IsNextField(DataField.Ids))
            {
                editDeserializer.ReadIdMappings(DataField.Ids);
            }
            //}

            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="IntersectOperation"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 protected IntersectOperation(EditDeserializer editDeserializer)
     : base(editDeserializer)
 {
     // If the data was produced via export from an old CEdit file, we'll have the absolute position
     if (editDeserializer.IsNextField(DataField.X))
         CheckPosition = editDeserializer.ReadPointGeometry(DataField.X, DataField.Y);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="LineSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal LineSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Line = editDeserializer.ReadFeatureRef<LineFeature>(DataField.Line);
            m_Face = editDeserializer.ReadPersistent<LineSubdivisionFace>(DataField.Face);
            //FeatureStub[] sections = editDeserializer.ReadFeatureStubArray(DataField.Result);

            if (editDeserializer.IsNextField(DataField.OtherSide))
            {
                InternalIdValue id = editDeserializer.ReadInternalId(DataField.OtherSide);
                OtherSide = (LineSubdivisionOperation)editDeserializer.MapModel.FindOperation(id);
                Debug.Assert(OtherSide != null);
                OtherSide.OtherSide = this;
            }

            Project p = editDeserializer.Project;
            IEntity pointType = editDeserializer.ReadEntity(DataField.PointType);
            FeatureStub[] sections = CreateStubs(p, pointType, m_Line.EntityType);

            DeserializationFactory result = new DeserializationFactory(this, sections);
            ProcessFeatures(result);

            // Apply any IDs
            if (editDeserializer.IsNextField(DataField.Ids))
                editDeserializer.ReadIdMappings(DataField.Ids);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ArcGeometry"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal ArcGeometry(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_IsClockwise = editDeserializer.ReadBool(DataField.Clockwise);

            if (editDeserializer.IsNextField(DataField.Center))
            {
                PointFeature center = editDeserializer.ReadFeatureRef<PointFeature>(this, DataField.Center);

                // The arc is the first arc attached to the circle. However, we cannot
                // calculate the radius just yet because the bc/ec points are not persisted
                // as part of the ArcGeometry definition (they are defined as part of the
                // LineFeature object that utilizes the ArcGeometry).

                // Even if we did have the bc/ec points at this stage, their positions will
                // only be available if the data came from an import (they will still be
                // undefined if the geometry is calculated, since calculation only occurs
                // after deserialization has been completed).

                if (center != null)
                    ApplyFeatureRef(DataField.Center, center);
            }
            else
            {
                ArcFeature firstArc = editDeserializer.ReadFeatureRef<ArcFeature>(this, DataField.FirstArc);
                if (firstArc != null)
                    ApplyFeatureRef(DataField.FirstArc, firstArc);
            }
        }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IntersectOperation"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 protected IntersectOperation(EditDeserializer editDeserializer)
     : base(editDeserializer)
 {
     // If the data was produced via export from an old CEdit file, we'll have the absolute position
     if (editDeserializer.IsNextField(DataField.X))
     {
         CheckPosition = editDeserializer.ReadPointGeometry(DataField.X, DataField.Y);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ImportOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal ImportOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            if (editDeserializer.IsNextField(DataField.Source))
                m_Source = editDeserializer.ReadString(DataField.Source);
            else
                m_Source = String.Empty;

            m_Data = editDeserializer.ReadPersistentArray<Feature>(DataField.Features);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PolygonSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal PolygonSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            if (editDeserializer.IsNextField(DataField.DeactivatedLabel))
            {
                m_Label = editDeserializer.ReadFeatureRef<TextFeature>(DataField.DeactivatedLabel);
                m_Label.IsInactive = true; // later ?
            }

            m_Lines = editDeserializer.ReadPersistentArray<LineFeature>(DataField.Lines);
        }
Exemple #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PolygonSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal PolygonSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            if (editDeserializer.IsNextField(DataField.DeactivatedLabel))
            {
                m_Label            = editDeserializer.ReadFeatureRef <TextFeature>(DataField.DeactivatedLabel);
                m_Label.IsInactive = true; // later ?
            }

            m_Lines = editDeserializer.ReadPersistentArray <LineFeature>(DataField.Lines);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MoveTextOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal MoveTextOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Text = editDeserializer.ReadFeatureRef<TextFeature>(DataField.Text);
            m_OldPosition = editDeserializer.ReadPointGeometry(DataField.OldX, DataField.OldY);
            m_NewPosition = editDeserializer.ReadPointGeometry(DataField.NewX, DataField.NewY);

            if (editDeserializer.IsNextField(DataField.OldPolygonX))
                m_OldPolPosition = editDeserializer.ReadPointGeometry(DataField.OldPolygonX, DataField.OldPolygonY);
            else
                m_OldPolPosition = null;
        }
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            if (editDeserializer.IsNextField(DataField.Face))
            {
                Distance[] face = editDeserializer.ReadPersistentArray <Distance>(DataField.Face);
                result.Add(new UpdateItem(DataField.Face, face));
            }

            return(result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IntersectDirectionAndLineOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal IntersectDirectionAndLineOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Direction = editDeserializer.ReadPersistent <Direction>(DataField.Direction);
            ForwardFeatureRef fwRef;

            m_Line    = editDeserializer.ReadFeatureRef <LineFeature>(this, DataField.Line, out fwRef);
            m_CloseTo = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.CloseTo);
            FeatureStub to      = editDeserializer.ReadPersistent <FeatureStub>(DataField.To);
            FeatureStub dirLine = editDeserializer.ReadPersistentOrNull <FeatureStub>(DataField.DirLine);
            string      idLineA = (editDeserializer.IsNextField(DataField.SplitBefore) ? editDeserializer.ReadString(DataField.SplitBefore) : null);
            string      idLineB = (editDeserializer.IsNextField(DataField.SplitAfter) ? editDeserializer.ReadString(DataField.SplitAfter) : null);

            m_IsSplit = (idLineA != null && idLineB != null);

            // TODO (perhaps): If the line is a forward-reference (from CEdit export), we'd have to handle
            // AddLineSplit a bit differently, and do some more in ApplyFeatureRef.
            if (m_Line == null && m_IsSplit)
            {
                if (fwRef == null)
                {
                    int junk = 0;
                }
                Debug.Assert(fwRef != null);
                editDeserializer.AddForwardSplit(fwRef, idLineA, idLineB);
            }

            DeserializationFactory dff = new DeserializationFactory(this);

            dff.AddFeatureStub(DataField.To, to);
            dff.AddFeatureStub(DataField.DirLine, dirLine);

            if (m_Line != null)
            {
                dff.AddLineSplit(m_Line, DataField.SplitBefore, idLineA);
                dff.AddLineSplit(m_Line, DataField.SplitAfter, idLineB);
            }
            ProcessFeatures(dff);
        }
Exemple #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImportOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal ImportOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            if (editDeserializer.IsNextField(DataField.Source))
            {
                m_Source = editDeserializer.ReadString(DataField.Source);
            }
            else
            {
                m_Source = String.Empty;
            }

            m_Data = editDeserializer.ReadPersistentArray <Feature>(DataField.Features);
        }
Exemple #17
0
        /// <summary>
        /// Reads data that was previously written using <see cref="WriteData"/>
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="label">The polygon label that was modified</param>
        /// <param name="newPosition">The revised position of the reference point.</param>
        /// <param name="oldPosition">The original position of the reference point.</param>
        static void ReadData(EditDeserializer editDeserializer, out TextFeature label, out PointGeometry newPosition,
                             out PointGeometry oldPosition)
        {
            label       = editDeserializer.ReadFeatureRef <TextFeature>(DataField.Label);
            newPosition = editDeserializer.ReadPointGeometry(DataField.NewX, DataField.NewY);

            if (editDeserializer.IsNextField(DataField.OldX))
            {
                oldPosition = editDeserializer.ReadPointGeometry(DataField.OldX, DataField.OldY);
            }
            else
            {
                oldPosition = null;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal UpdateOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            if (editDeserializer.IsNextField(DataField.RevisedEdits))
            {
                m_Revisions = editDeserializer.ReadPersistentArray<RevisedEdit>(DataField.RevisedEdits);
            }
            else
            {
                RevisedEdit rev = new RevisedEdit(editDeserializer);
                m_Revisions = new RevisedEdit[] { rev };
            }

            m_IsApplied = false;
        }
Exemple #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal UpdateOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            if (editDeserializer.IsNextField(DataField.RevisedEdits))
            {
                m_Revisions = editDeserializer.ReadPersistentArray <RevisedEdit>(DataField.RevisedEdits);
            }
            else
            {
                RevisedEdit rev = new RevisedEdit(editDeserializer);
                m_Revisions = new RevisedEdit[] { rev };
            }

            m_IsApplied = false;
        }
Exemple #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MoveTextOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal MoveTextOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Text        = editDeserializer.ReadFeatureRef <TextFeature>(DataField.Text);
            m_OldPosition = editDeserializer.ReadPointGeometry(DataField.OldX, DataField.OldY);
            m_NewPosition = editDeserializer.ReadPointGeometry(DataField.NewX, DataField.NewY);

            if (editDeserializer.IsNextField(DataField.OldPolygonX))
            {
                m_OldPolPosition = editDeserializer.ReadPointGeometry(DataField.OldPolygonX, DataField.OldPolygonY);
            }
            else
            {
                m_OldPolPosition = null;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PathOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal PathOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            //try
            //{
                m_From = editDeserializer.ReadFeatureRef<PointFeature>(DataField.From);
                m_To = editDeserializer.ReadFeatureRef<PointFeature>(DataField.To);
                m_EntryString = editDeserializer.ReadString(DataField.EntryString);
                m_DefaultEntryUnit = editDeserializer.ReadDistanceUnit(DataField.DefaultEntryUnit);

                Leg[] legs = PathParser.CreateLegs(m_EntryString, m_DefaultEntryUnit);
                PrepareLegs(this.EditSequence, legs);
                m_Legs = new List<Leg>(legs);

                Project p = editDeserializer.Project;
                IEntity pointType = editDeserializer.ReadEntity(DataField.PointType);
                IEntity lineType = editDeserializer.ReadEntity(DataField.LineType);

                // Pick up any alternate faces (these may be defined ONLY when dealing with
                // data files that were derived from old CEdit files). The deserializaing
                // constructor will connect the alternate faces to the legs we've just
                // created.
                if (editDeserializer.IsNextField(DataField.AlternateFaces))
                    editDeserializer.ReadPersistentArray<LegFace>(DataField.AlternateFaces);

                // Create stubs for everything that we could conceivably create (including
                // any alternate faces).
                FeatureStub[] stubs = CreateStubs(p, pointType, lineType);

                var result = new DeserializationFactory(this, stubs);
                result.PointType = pointType;
                result.LineType = lineType;

                // Create feature objects
                ProcessFeatures(result);

                // Apply any IDs
                if (editDeserializer.IsNextField(DataField.Ids))
                    editDeserializer.ReadIdMappings(DataField.Ids);
            //}

            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
        /// <summary>
        /// Reads data that was previously written using <see cref="WriteData"/>
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="from">The point at the start of the line</param>
        /// <param name="to">The point at the end of the line</param>
        /// <param name="isTopological">Does the line act as a polygon boundary </param>
        /// <param name="geom">The geometry for the line.</param>
        static void ReadData(EditDeserializer editDeserializer, out PointFeature from, out PointFeature to, out bool isTopological,
            out LineGeometry geom)
        {
            from = editDeserializer.ReadFeatureRef<PointFeature>(DataField.From);
            to = editDeserializer.ReadFeatureRef<PointFeature>(DataField.To);
            isTopological = editDeserializer.ReadBool(DataField.Topological);

            if (editDeserializer.IsNextField(DataField.Type))
            {
                geom = editDeserializer.ReadPersistent<LineGeometry>(DataField.Type);

                // Ensure terminals have been defined (since there was no easy way to pass them
                // through to the LineGeometry constructor).
                geom.StartTerminal = from;
                geom.EndTerminal = to;

                // If we're dealing with a circular arc, and the bc/ec points have defined
                // positions (e.g. coming from an import), we can calculate the radius now.
                // Otherwise we'll need to wait until geometry has been calculated.

                // The radius is defined here only because it's consistent with older code.
                // It may well be better to leave the definition of circle radius till later
                // (i.e. do all circles after geometry has been calculated).

                ArcGeometry arc = (geom as ArcGeometry);
                if (arc != null)
                {
                    Circle c = (Circle)arc.Circle;
                    PointFeature center = c.CenterPoint;

                    if (center.PointGeometry != null && from.PointGeometry != null)
                        c.Radius = Geom.Distance(center.PointGeometry, from.PointGeometry);
                }

            }
            else
            {
                geom = new SegmentGeometry(from, to);
            }
        }
        /// <summary>
        /// Reads data that was previously written using <see cref="WriteData"/>
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="isTopological">Are we dealing with a polygon label</param>
        /// <param name="polPos">The label reference point (usually applies onlt to polygon labels). Null if it's
        /// identical to the position recorded via the geometry object.</param>
        /// <param name="geom">The geometry for the text.</param>
        static void ReadData(EditDeserializer editDeserializer, out bool isTopological, out PointGeometry polPos, out TextGeometry geom)
        {
            isTopological = editDeserializer.ReadBool(DataField.Topological);

            if (editDeserializer.IsNextField(DataField.PolygonX))
                polPos = editDeserializer.ReadPointGeometry(DataField.PolygonX, DataField.PolygonY);
            else
                polPos = null;

            geom = editDeserializer.ReadPersistent<TextGeometry>(DataField.Type);
        }
        /// <summary>
        /// Reads data that was previously written using <see cref="WriteData"/>
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="label">The polygon label that was modified</param>
        /// <param name="newPosition">The revised position of the reference point.</param>
        /// <param name="oldPosition">The original position of the reference point.</param>
        static void ReadData(EditDeserializer editDeserializer, out TextFeature label, out PointGeometry newPosition,
            out PointGeometry oldPosition)
        {
            label = editDeserializer.ReadFeatureRef<TextFeature>(DataField.Label);
            newPosition = editDeserializer.ReadPointGeometry(DataField.NewX, DataField.NewY);

            if (editDeserializer.IsNextField(DataField.OldX))
                oldPosition = editDeserializer.ReadPointGeometry(DataField.OldX, DataField.OldY);
            else
                oldPosition = null;
        }
        /// <summary>
        /// Reads data that was previously written using <see cref="WriteData"/>
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="font">The text style</param>
        /// <param name="position">Position of the text's reference point</param>
        /// <param name="height">The height of the text, in meters on the ground.</param>
        /// <param name="width">The total width of the text, in meters on the ground.</param>
        /// <param name="rotation">Clockwise rotation from horizontal</param>
        static void ReadData(EditDeserializer editDeserializer, out IFont font, out PointGeometry position,
            out float height, out float width, out IAngle rotation)
        {
            if (editDeserializer.IsNextField(DataField.Font))
            {
                int fontId = editDeserializer.ReadInt32(DataField.Font);
                font = EnvironmentContainer.FindFontById(fontId);
            }
            else
            {
                font = null;
            }

            position = editDeserializer.ReadPointGeometry(DataField.X, DataField.Y);
            width = (float)editDeserializer.ReadDouble(DataField.Width);
            height = (float)editDeserializer.ReadDouble(DataField.Height);
            rotation = editDeserializer.ReadRadians(DataField.Rotation);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IntersectDirectionAndLineOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal IntersectDirectionAndLineOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Direction = editDeserializer.ReadPersistent<Direction>(DataField.Direction);
            ForwardFeatureRef fwRef;
            m_Line = editDeserializer.ReadFeatureRef<LineFeature>(this, DataField.Line, out fwRef);
            m_CloseTo = editDeserializer.ReadFeatureRef<PointFeature>(this, DataField.CloseTo);
            FeatureStub to = editDeserializer.ReadPersistent<FeatureStub>(DataField.To);
            FeatureStub dirLine = editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.DirLine);
            string idLineA = (editDeserializer.IsNextField(DataField.SplitBefore) ? editDeserializer.ReadString(DataField.SplitBefore) : null);
            string idLineB = (editDeserializer.IsNextField(DataField.SplitAfter) ? editDeserializer.ReadString(DataField.SplitAfter) : null);

            m_IsSplit = (idLineA != null && idLineB != null);

            // TODO (perhaps): If the line is a forward-reference (from CEdit export), we'd have to handle
            // AddLineSplit a bit differently, and do some more in ApplyFeatureRef.
            if (m_Line == null && m_IsSplit)
            {
                if (fwRef == null)
                {
                    int junk = 0;
                }
                Debug.Assert(fwRef != null);
                editDeserializer.AddForwardSplit(fwRef, idLineA, idLineB);
            }

            DeserializationFactory dff = new DeserializationFactory(this);
            dff.AddFeatureStub(DataField.To, to);
            dff.AddFeatureStub(DataField.DirLine, dirLine);

            if (m_Line != null)
            {
                dff.AddLineSplit(m_Line, DataField.SplitBefore, idLineA);
                dff.AddLineSplit(m_Line, DataField.SplitAfter, idLineB);
            }
            ProcessFeatures(dff);
        }
 /// <summary>
 /// Reads data that was previously written using <see cref="WriteData"/>
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <param name="line1">The 1st line to intersect.</param>
 /// <param name="line2">The 2nd line to intersect.</param>
 /// <param name="closeTo">The point closest to the intersection.</param>
 /// <param name="to">The created intersection point (if any). May have existed previously.</param>
 /// <param name="idLine1a">The ID of the portion of the first line prior to the intersection (null if no split).</param>
 /// <param name="idLine1b">The ID of the portion of the first line after the intersection (null if no split).</param>
 /// <param name="idLine2a">The ID of the portion of the second line prior to the intersection (null if no split).</param>
 /// <param name="idLine2b">The ID of the portion of the second line after the intersection (null if no split).</param>
 static void ReadData(EditDeserializer editDeserializer, out LineFeature line1, out LineFeature line2, out PointFeature closeTo,
     out FeatureStub to, out string idLine1a, out string idLine1b, out string idLine2a, out string idLine2b)
 {
     line1 = editDeserializer.ReadFeatureRef<LineFeature>(DataField.Line1);
     line2 = editDeserializer.ReadFeatureRef<LineFeature>(DataField.Line2);
     closeTo = editDeserializer.ReadFeatureRef<PointFeature>(DataField.CloseTo);
     to = editDeserializer.ReadPersistent<FeatureStub>(DataField.To);
     idLine1a = (editDeserializer.IsNextField(DataField.SplitBefore1) ? editDeserializer.ReadString(DataField.SplitBefore1) : null);
     idLine1b = (editDeserializer.IsNextField(DataField.SplitAfter1) ? editDeserializer.ReadString(DataField.SplitAfter1) : null);
     idLine2a = (editDeserializer.IsNextField(DataField.SplitBefore2) ? editDeserializer.ReadString(DataField.SplitBefore2) : null);
     idLine2b = (editDeserializer.IsNextField(DataField.SplitAfter2) ? editDeserializer.ReadString(DataField.SplitAfter2) : null);
 }
Exemple #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LegFace"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal LegFace(EditDeserializer editDeserializer)
        {
            // Only connection paths should generate LegFace instances
            PathOperation op = (editDeserializer.CurrentEdit as PathOperation);
            if (op == null)
                throw new ApplicationException("Unexpected creating edit for a leg face");

            this.Sequence = editDeserializer.ReadInternalId(DataField.Id);

            if (editDeserializer.IsNextField(DataField.PrimaryFaceId))
            {
                InternalIdValue primaryFaceId = editDeserializer.ReadInternalId(DataField.PrimaryFaceId);
                LegFace face = op.FindFace(primaryFaceId);

                if (face == null)
                    throw new ApplicationException("Cannot locate primary face " + primaryFaceId);

                Leg = face.Leg;
                Leg.AlternateFace = this;
            }
            else
            {
                // This should never happen. Primary faces are not serialized using the LegFace
                // class (we only use LegFace as part of a PathOperation to simplify import of
                // extra legs from old CEdit files).

                throw new ApplicationException();
            }

            // Convert the data entry string into observed spans
            string entryString = editDeserializer.ReadString(DataField.EntryString);
            DistanceUnit defaultEntryUnit = EditingController.Current.EntryUnit;
            Distance[] dists = LineSubdivisionFace.GetDistances(entryString, defaultEntryUnit, false);
            m_Spans = new SpanInfo[dists.Length];

            for (int i=0; i<m_Spans.Length; i++)
            {
                m_Spans[i] = new SpanInfo() { ObservedDistance = dists[i] };
            }
        }
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            if (editDeserializer.IsNextField(DataField.Face))
            {
                Distance[] face = editDeserializer.ReadPersistentArray<Distance>(DataField.Face);
                result.Add(new UpdateItem(DataField.Face, face));
            }

            return result;
        }