Exemplo n.º 1
0
        internal void Resolve(CadastralMapModel model)
        {
            IFeatureRef fr = m_LineRef.ReferenceFrom;

            Debug.Assert(fr is Operation);

            Feature f = model.Find <Feature>(m_LineRef.InternalId);

            if (f == null)
            {
                throw new ApplicationException("Cannot locate forward reference " + m_LineRef.InternalId);
            }

            // Only IntersectDirectionAndLineOperation has forward splits, so follow that logic
            LineFeature line = (LineFeature)f;
            var         dff  = new DeserializationFactory(fr as Operation);

            dff.AddLineSplit(line, DataField.SplitBefore, m_SplitBeforeId);
            dff.AddLineSplit(line, DataField.SplitAfter, m_SplitAfterId);

            IntersectOperation xop = (IntersectOperation)fr;
            LineFeature        lineBefore, lineAfter;

            dff.MakeSections(line, DataField.SplitBefore, xop.IntersectionPoint, DataField.SplitAfter,
                             out lineBefore, out lineAfter);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ForwardFeatureRef"/> class.
        /// </summary>
        /// <param name="referenceFrom">The object that makes the forward-reference (not null).</param>
        /// <param name="field">The ID of the persistent field.</param>
        /// <param name="iid">The internal ID that has been persisted for the field (relating to a feature
        /// that has not been created yet).</param>
        /// <exception cref="ArgumentNullException">If <paramref name="referenceFrom"/> is not defined.</exception>
        internal ForwardFeatureRef(IFeatureRef referenceFrom, DataField field, InternalIdValue iid)
            : base(field)
        {
            if (referenceFrom == null)
                throw new ArgumentNullException();

            ReferenceFrom = referenceFrom;
            InternalId = iid;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ForwardFeatureRef"/> class.
        /// </summary>
        /// <param name="referenceFrom">The object that makes the forward-reference (not null).</param>
        /// <param name="field">The ID of the persistent field.</param>
        /// <param name="iid">The internal ID that has been persisted for the field (relating to a feature
        /// that has not been created yet).</param>
        /// <exception cref="ArgumentNullException">If <paramref name="referenceFrom"/> is not defined.</exception>
        internal ForwardFeatureRef(IFeatureRef referenceFrom, DataField field, InternalIdValue iid)
            : base(field)
        {
            if (referenceFrom == null)
            {
                throw new ArgumentNullException();
            }

            ReferenceFrom = referenceFrom;
            InternalId    = iid;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reads a reference to a spatial feature, using that reference to obtain the
        /// corresponding feature. If the feature cannot be found, the reference will be cached as
        /// a forward reference (on completion of deserialization, you then call <see cref="ApplyForwardRefs"/>
        /// to process the cache).
        /// </summary>
        /// <typeparam name="T">The type of spatial feature expected by the caller</typeparam>
        /// <param name="referenceFrom">The object that is making the reference</param>
        /// <param name="field">A tag associated with the value</param>
        /// <returns>
        /// The feature that was read (null if not found, or the reference was undefined). May
        /// actually have a type that is derived from the supplied type.
        /// </returns>
        /// <remarks>This does not create a brand new feature. Rather, it uses a reference
        /// to try to obtain a feature that should have already been created.
        /// </remarks>
        internal T ReadFeatureRef <T>(IFeatureRef referenceFrom, DataField field) where T : Feature
        {
            InternalIdValue id = m_Reader.ReadInternalId(field.ToString());

            if (id.IsEmpty)
            {
                return(default(T));
            }

            T result = MapModel.Find <T>(id);

            if (result == null)
            {
                var fwRef = new ForwardFeatureRef(referenceFrom, field, id);
                m_ForwardRefs.Add(fwRef);
            }

            return(result);
        }