/// <summary>
 /// Initializes a new instance of the <see cref="NewProjectEvent"/> class.
 /// </summary>
 /// <param name="ed">The mechanism for reading back content.</param>
 internal NewProjectEvent(EditDeserializer ed)
     : base(ed)
 {
     this.ProjectId = new Guid(ed.ReadString(DataField.ProjectId));
     this.ProjectName = ed.ReadString(DataField.ProjectName);
     this.LayerId = ed.ReadInt32(DataField.LayerId);
     this.DefaultSystem = ed.ReadString(DataField.CoordinateSystem);
     this.UserName = ed.ReadString(DataField.UserName);
     this.MachineName = ed.ReadString(DataField.MachineName);
 }
示例#2
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);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleLineSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal SimpleLineSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Line      = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Line);
            m_Distance  = editDeserializer.ReadPersistent <Distance>(DataField.Distance);
            m_IsFromEnd = editDeserializer.ReadBool(DataField.EntryFromEnd);
            FeatureStub newPoint = editDeserializer.ReadPersistent <FeatureStub>(DataField.NewPoint);
            string      dataId1  = editDeserializer.ReadString(DataField.NewLine1);
            string      dataId2  = editDeserializer.ReadString(DataField.NewLine2);

            DeserializationFactory dff = new DeserializationFactory(this);

            dff.AddFeatureStub(DataField.NewPoint, newPoint);
            dff.AddLineSplit(m_Line, DataField.NewLine1, dataId1);
            dff.AddLineSplit(m_Line, DataField.NewLine2, dataId2);
            ProcessFeatures(dff);
        }
        /// <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);
        }
示例#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;
            //}
        }
示例#6
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);
        }
示例#7
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] };
            }
        }
示例#8
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="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);
        }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewSessionEvent"/> class.
 /// </summary>
 /// <param name="ed">The mechanism for reading back content.</param>
 internal NewSessionEvent(EditDeserializer ed)
     : base(ed)
 {
     this.UserName = ed.ReadString(DataField.UserName);
     this.MachineName = ed.ReadString(DataField.MachineName);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleLineSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal SimpleLineSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Line = editDeserializer.ReadFeatureRef<LineFeature>(DataField.Line);
            m_Distance = editDeserializer.ReadPersistent<Distance>(DataField.Distance);
            m_IsFromEnd = editDeserializer.ReadBool(DataField.EntryFromEnd);
            FeatureStub newPoint = editDeserializer.ReadPersistent<FeatureStub>(DataField.NewPoint);
            string dataId1 = editDeserializer.ReadString(DataField.NewLine1);
            string dataId2 = editDeserializer.ReadString(DataField.NewLine2);

            DeserializationFactory dff = new DeserializationFactory(this);
            dff.AddFeatureStub(DataField.NewPoint, newPoint);
            dff.AddLineSplit(m_Line, DataField.NewLine1, dataId1);
            dff.AddLineSplit(m_Line, DataField.NewLine2, dataId2);
            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);
 }
        /// <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>
        /// Initializes a new instance of the <see cref="MultiSegmentGeometry"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal MultiSegmentGeometry(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            // LineString assumes 2D, with X preceding Y. Each coordinate pair is separated
            // with a comma, with a space between each X and Y (e.g. "123 345,124 349,129 341")

            string s = editDeserializer.ReadString(DataField.LineString);
            string[] xys = s.Split(',');
            m_Data = new IPointGeometry[xys.Length];

            for (int i = 0; i < xys.Length; i++)
            {
                string xy = xys[i].Trim();

                int blankPos = xy.IndexOf(' ');
                if (blankPos <= 0)
                    throw new FormatException();

                double x = Double.Parse(xy.Substring(0, blankPos));
                double y = Double.Parse(xy.Substring(blankPos+1));
                m_Data[i] = new PointGeometry(x, y);
            }

            m_Extent = LineStringGeometry.GetExtent(this);
        }