Пример #1
0
        /// <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);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Loads a miscellaneous value back from a storage medium (so long as it comes next in the supplied
        /// deserialization stream).
        /// </summary>
        /// <typeparam name="T">The type of value expected by the caller.</typeparam>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="field">The tag that identifies the value.</param>
        /// <returns>True if an item was loaded, false if the next item in the deserialization
        /// stream does not have the specified name.</returns>
        internal bool ReadItem <T>(EditDeserializer editDeserializer, DataField field) where T : IConvertible
        {
            if (editDeserializer.IsNextField(field))
            {
                T result = editDeserializer.ReadValue <T>(field);
                Add(new UpdateItem(field, result));
                return(true);
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Loads an observation back from a storage medium (so long as it comes next in the supplied
        /// deserialization stream).
        /// </summary>
        /// <typeparam name="T">The type of object expected by the caller.</typeparam>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="field">The tag that identifies the item.</param>
        /// <returns>True if an observation was loaded, false if the next item in the deserialization
        /// stream does not have the specified name.</returns>
        internal bool ReadObservation <T>(EditDeserializer editDeserializer, DataField field) where T : Observation
        {
            if (editDeserializer.IsNextField(field))
            {
                T result = editDeserializer.ReadPersistent <T>(field);
                Add(new UpdateItem(field, result));
                return(true);
            }

            return(false);
        }
Пример #4
0
        /// <summary>
        /// Loads a feature reference back from a storage medium (so long as it comes next in the supplied
        /// deserialization stream).
        /// </summary>
        /// <typeparam name="T">The type of feature expected by the caller.</typeparam>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="field">The tag that identifies the item.</param>
        /// <returns>True if a feature reference was loaded, false if the next item in the deserialization
        /// stream does not have the specified name.</returns>
        internal bool ReadFeature <T>(EditDeserializer editDeserializer, DataField field) where T : Feature
        {
            if (editDeserializer.IsNextField(field))
            {
                T result = editDeserializer.ReadFeatureRef <T>(field);
                Add(new UpdateItem(field, result));
                return(true);
            }

            return(false);
        }
Пример #5
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]
                };
            }
        }
Пример #6
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="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);
        }
Пример #7
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="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);
        }