/// <summary>
        /// Executes this operation.
        /// </summary>
        /// <param name="pointId">The ID (and entity type) for the extension point.</param>
        /// <param name="lineEnt">The entity type for the extension line (null for no line).</param>
        internal void Execute(IdHandle pointId, IEntity lineEnt)
        {
            FeatureFactory ff = new FeatureFactory(this);

            FeatureId fid = pointId.CreateId();
            IFeature xp = new FeatureStub(this, pointId.Entity, fid);
            ff.AddFeatureDescription(DataField.NewPoint, xp);

            if (lineEnt != null)
            {
                IFeature f = new FeatureStub(this, lineEnt, null);
                ff.AddFeatureDescription(DataField.NewLine, f);
            }

            base.Execute(ff);

            /*
            IPosition start;    // Start of the extension
            IPosition end;      // End of the extension

            // See if the extension is a straight line.
            bool isStraight = LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end);

            // If it's not straight, it should be a circular arc.
            bool isCurve = false;
            IPosition center;   // The centre of the circle
            bool iscw = true;   // Is the curve clockwise?

            if (!isStraight)
                isCurve = LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end, out center, out iscw);

            // Return if it's neither straight or a circular arc.
            if ( !(isStraight || isCurve) )
                throw new Exception("Cannot calculate line extension point.");

            // Add the extension point to the map.
            CadastralMapModel map = MapModel;
            m_NewPoint = map.AddPoint(end, pointId.Entity, this);

            // Associate the new point with the specified ID (if any).
            pointId.CreateId(m_NewPoint);

            // If a line entity has been supplied, add a line too.
            if (lineEnt==null)
                m_NewLine = null;
            else
            {
                // Get the point at the end of the extension line
                PointFeature s = (m_IsExtendFromEnd ? m_ExtendLine.EndPoint : m_ExtendLine.StartPoint);

                if (isStraight)
                    m_NewLine = map.AddLine(s, m_NewPoint, lineEnt, this);
                else
                {
                    // We need the circle that the arc lies on.
                    Circle circle = m_ExtendLine.Circle;
                    Debug.Assert(circle!=null);

                    // Add the arc to the map.
                    m_NewLine = map.AddCircularArc(circle, s, m_NewPoint, iscw, lineEnt, this);
                }
            }

            // Peform standard completion steps
            Complete();
             */
        }
 /// <summary>
 /// Reads data that was previously written using <see cref="WriteData"/>
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <param name="center">Point at the center of the circle.</param>
 /// <param name="radius">The radius of the circle.</param>
 /// <param name="arc">The arc running around the circumference of the circle</param>
 /// <param name="closingPoint">The closing point of the circle (if it was created by this edit). Null
 /// if the radius was specified using an offset point.</param>
 static void ReadData(EditDeserializer editDeserializer, out PointFeature center, out Observation radius,
     out FeatureStub closingPoint, out FeatureStub arc)
 {
     center = editDeserializer.ReadFeatureRef<PointFeature>(DataField.Center);
     radius = editDeserializer.ReadPersistent<Observation>(DataField.Radius);
     closingPoint = editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.ClosingPoint);
     arc = editDeserializer.ReadPersistent<FeatureStub>(DataField.Arc);
 }
        /// <summary>
        /// Executes this operation. 
        /// </summary>
        /// <param name="pointId">The ID and entity type for the intersect point
        /// If null, the default entity type for point features will be used.</param>
        /// <param name="lineEnt1">The entity type for a line connecting the 1st direction to the
        /// intersection (null for no line)</param>
        /// <param name="lineEnt2">The entity type for a line connecting the 2nd direction to the
        /// intersection (null for no line)</param>
        internal void Execute(IdHandle pointId, IEntity lineEnt1, IEntity lineEnt2)
        {
            FeatureFactory ff = new FeatureFactory(this);

            FeatureId fid = pointId.CreateId();
            IFeature x = new FeatureStub(this, pointId.Entity, fid);
            ff.AddFeatureDescription(DataField.To, x);

            if (lineEnt1 != null)
            {
                // Lines are not allowed if the direction line is associated with an offset
                // distance (since we would then need to add a point at the start of the
                // direction line). This should have been trapped by the UI. Note that an
                // offset specified using an OffsetPoint is valid.

                if (m_Direction1.Offset is OffsetDistance)
                    throw new ApplicationException("Cannot add direction line because a distance offset is involved");

                IFeature f = new FeatureStub(this, lineEnt1, null);
                ff.AddFeatureDescription(DataField.Line1, f);
            }

            if (lineEnt2 != null)
            {
                if (m_Direction2.Offset is OffsetDistance)
                    throw new ApplicationException("Cannot add direction line because a distance offset is involved");

                IFeature f = new FeatureStub(this, lineEnt2, null);
                ff.AddFeatureDescription(DataField.Line2, f);
            }

            base.Execute(ff);

            /*
            // Calculate the position of the point of intersection.
            IPosition xsect = m_Direction1.Intersect(m_Direction2);
            if (xsect==null)
                throw new Exception("Cannot calculate intersection point");

            // Add the intersection point
            m_To = AddIntersection(xsect, pointId);

            // If we have a defined entity types for lines, add them too.
            CadastralMapModel map = MapModel;

            if (lineEnt1!=null)
            {
                IPosition start = m_Direction1.StartPosition;
                PointFeature ps = map.EnsurePointExists(start, this);
                m_Line1 = map.AddLine(ps, m_To, lineEnt1, this);
            }

            if (lineEnt2!=null)
            {
                IPosition start = m_Direction2.StartPosition;
                PointFeature ps = map.EnsurePointExists(start, this);
                m_Line2 = map.AddLine(ps, m_To, lineEnt2, this);
            }

            // Peform standard completion steps
            Complete();
             */
        }
 /// <summary>
 /// Reads data that was previously written using <see cref="WriteData"/>
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <param name="dir1">The first observed direction.</param>
 /// <param name="dir2">The second observed direction</param>
 /// <param name="to">The created intersection point.</param>
 /// <param name="line1">The first line created (if any).</param>
 /// <param name="line1">The second line created (if any).</param>
 static void ReadData(EditDeserializer editDeserializer, out Direction dir1, out Direction dir2,
     out FeatureStub to, out FeatureStub line1, out FeatureStub line2)
 {
     dir1 = editDeserializer.ReadPersistent<Direction>(DataField.Direction1);
     dir2 = editDeserializer.ReadPersistent<Direction>(DataField.Direction2);
     to = editDeserializer.ReadPersistent<FeatureStub>(DataField.To);
     line1 = editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.Line1);
     line2 = editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.Line2);
 }
Esempio n. 5
0
        /// <summary>
        /// Executes this operation.
        /// </summary>
        /// <param name="pointId"></param>
        /// <param name="lineType"></param>
        internal void Execute(IdHandle pointId, IEntity lineType)
        {
            // Calculate the position of the sideshot point.
            IPosition to = Calculate(m_Direction, m_Length);
            if (to==null)
                throw new Exception("Cannot calculate position of sideshot point.");

            FeatureFactory ff = new FeatureFactory(this);

            FeatureId fid = pointId.CreateId();
            IFeature x = new FeatureStub(this, pointId.Entity, fid);
            ff.AddFeatureDescription(DataField.To, x);

            if (lineType != null)
            {
                IFeature f = new FeatureStub(this, lineType, null);
                ff.AddFeatureDescription(DataField.Line, f);
            }

            base.Execute(ff);
        }
        /// <summary>
        /// Executes this operation. 
        /// </summary>
        /// <param name="pointId">The ID and entity type for the intersect point</param>
        /// <param name="ent1">The entity type for 1st line (null for no line)</param>
        /// <param name="ent2">The entity type for 2nd line (null for no line)</param>
        internal void Execute(IdHandle pointId, IEntity ent1, IEntity ent2)
        {
            FeatureFactory ff = new FeatureFactory(this);

            FeatureId fid = pointId.CreateId();
            IFeature x = new FeatureStub(this, pointId.Entity, fid);
            ff.AddFeatureDescription(DataField.To, x);

            if (ent1 != null)
            {
                IFeature f = new FeatureStub(this, ent1, null);
                ff.AddFeatureDescription(DataField.Line1, f);
            }

            if (ent2 != null)
            {
                IFeature f = new FeatureStub(this, ent2, null);
                ff.AddFeatureDescription(DataField.Line2, f);
            }

            base.Execute(ff);

            /*
            // Calculate the position of the point of intersection.
            IPosition xsect = Calculate(m_Distance1, m_From1, m_Distance2, m_From2, m_Default);
            if (xsect==null)
                throw new Exception("Cannot calculate intersection point");

            // Add the intersection point
            m_To = AddIntersection(xsect, pointId);

            // If we have a defined entity types for lines, add them too.
            CadastralMapModel map = MapModel;

            if (ent1!=null)
                m_Line1 = map.AddLine(m_From1, m_To, ent1, this);

            if (ent2!=null)
                m_Line2 = map.AddLine(m_From2, m_To, ent2, this);

            // Peform standard completion steps
            Complete();
             */
        }
 /// <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>
        /// Executes this operation.
        /// </summary>
        /// <param name="pointId">The key and entity type to assign to the intersection point.</param>
        internal void Execute(IdHandle pointId)
        {
            FeatureFactory ff = new FeatureFactory(this);

            FeatureId fid = pointId.CreateId();
            IFeature x = new FeatureStub(this, pointId.Entity, fid);
            ff.AddFeatureDescription(DataField.To, x);

            if (m_IsSplit1)
            {
                // See FeatureFactory.MakeSection - the only thing that really matters is the
                // session sequence number that will get picked up by the FeatureStub constructor.
                ff.AddFeatureDescription(DataField.SplitBefore1, new FeatureStub(this, m_Line1.EntityType, null));
                ff.AddFeatureDescription(DataField.SplitAfter1, new FeatureStub(this, m_Line1.EntityType, null));
            }

            if (m_IsSplit2)
            {
                ff.AddFeatureDescription(DataField.SplitBefore2, new FeatureStub(this, m_Line2.EntityType, null));
                ff.AddFeatureDescription(DataField.SplitAfter2, new FeatureStub(this, m_Line2.EntityType, null));
            }

            base.Execute(ff);

            //////////
            /*
            // Calculate the position of the point of intersection.
            IPosition xsect;
            PointFeature closest;
            if (!m_Line1.Intersect(m_Line2, m_CloseTo, out xsect, out closest))
                throw new Exception("Cannot calculate intersection point");

            // Add the intersection point
            m_Intersection = AddIntersection(xsect, pointId);

            // Are we splitting the input lines? If so, do it.
            m_IsSplit1 = wantsplit1;
            if (m_IsSplit1)
                SplitLine(m_Intersection, m_Line1, out m_Line1a, out m_Line1b);

            m_IsSplit2 = wantsplit2;
            if (m_IsSplit2)
                SplitLine(m_Intersection, m_Line2, out m_Line2a, out m_Line2b);

            // Peform standard completion steps
            Complete();
             */
        }
        /// <summary>
        /// Executes this operation.
        /// </summary>
        /// <param name="pointId">The key and entity type to assign to the intersection point.</param>
        /// <param name="dirEnt">The entity type for any line that should be added along the direction
        /// line. Specify null if you don't want a line.</param>
        internal void Execute(IdHandle pointId, IEntity dirEnt)
        {
            FeatureFactory ff = new FeatureFactory(this);

            FeatureId fid = pointId.CreateId();
            IFeature x = new FeatureStub(this, pointId.Entity, fid);
            ff.AddFeatureDescription(DataField.To, x);

            if (m_IsSplit)
            {
                // See FeatureFactory.MakeSection - the only thing that really matters is the
                // session sequence number that will get picked up by the FeatureStub constructor.
                ff.AddFeatureDescription(DataField.SplitBefore, new FeatureStub(this, m_Line.EntityType, null));
                ff.AddFeatureDescription(DataField.SplitAfter, new FeatureStub(this, m_Line.EntityType, null));
            }

            if (dirEnt != null)
            {
                // Lines are not allowed if the direction line is associated with an offset
                // distance (since we would then need to add a point at the start of the
                // direction line). This should have been trapped by the UI. Note that an
                // offset specified using an OffsetPoint is valid.

                if (m_Direction.Offset is OffsetDistance)
                    throw new ApplicationException("Cannot add direction line because a distance offset is involved");

                IFeature f = new FeatureStub(this, dirEnt, null);
                ff.AddFeatureDescription(DataField.DirLine, f);
            }

            base.Execute(ff);

            //////////
            /*
            // Calculate the position of the point of intersection.
            IPosition xsect;
            PointFeature closest;
            if (!m_Direction.Intersect(m_Line, m_CloseTo, out xsect, out closest))
                throw new Exception("Cannot calculate intersection point");

            // Add the intersection point
            m_Intersection = AddIntersection(xsect, pointId);

            // Are we splitting the input line? If so, do it.
            m_IsSplit = wantsplit;
            if (m_IsSplit)
                SplitLine(m_Intersection, m_Line, out m_LineA, out m_LineB);

            // If we have a defined entity type for the direction line, add a line too.
            CadastralMapModel map = MapModel;
            if (dirEnt!=null)
                m_DirLine = map.AddLine(m_Direction.From, m_Intersection, dirEnt, this);

            // Peform standard completion steps
            Complete();
             */
        }