Exemplo n.º 1
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)
            {
                // 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, ent1, null);
                ff.AddFeatureDescription(DataField.DirLine, f);
            }

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

            base.Execute(ff);

            /*
             * // Calculate the position of the point of intersection.
             * IPosition xsect = Calculate(m_Direction, m_Distance, m_From, 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)
             * {
             *  IPosition start = m_Direction.StartPosition;
             *  PointFeature ps = map.EnsurePointExists(start, this);
             *  m_DirLine = map.AddLine(ps, m_To, ent1, this);
             * }
             *
             * if (ent2!=null)
             *  m_DistLine = map.AddLine(m_From, m_To, ent2, this);
             *
             * // Peform standard completion steps
             * Complete();
             */
        }
Exemplo n.º 3
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="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);
 }
Exemplo n.º 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="line">The line the point should appear on </param>
        /// <param name="positionRatio">The position ratio of the attached point.</param>
        /// <param name="point">The point that was created.</param>
        static void ReadData(EditDeserializer editDeserializer, out LineFeature line, out uint positionRatio, out PointFeature point)
        {
            line          = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Line);
            positionRatio = editDeserializer.ReadUInt32(DataField.PositionRatio);
            FeatureStub stub = editDeserializer.ReadPersistent <FeatureStub>(DataField.Point);

            point = new PointFeature(stub, null);
        }
Exemplo n.º 5
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="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);
 }
Exemplo n.º 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="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);
 }
Exemplo n.º 7
0
        /// <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();
             */
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LineExtensionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal LineExtensionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_ExtendLine      = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Line);
            m_IsExtendFromEnd = editDeserializer.ReadBool(DataField.ExtendFromEnd);
            m_Length          = editDeserializer.ReadPersistent <Distance>(DataField.Distance);
            FeatureStub newPoint = editDeserializer.ReadPersistent <FeatureStub>(DataField.NewPoint);
            FeatureStub newLine  = editDeserializer.ReadPersistentOrNull <FeatureStub>(DataField.NewLine);

            DeserializationFactory dff = new DeserializationFactory(this);

            dff.AddFeatureStub(DataField.NewPoint, newPoint);
            dff.AddFeatureStub(DataField.NewLine, newLine);
            ProcessFeatures(dff);
        }
        /// <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);
        }
Exemplo n.º 10
0
        /// <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>
        /// Initializes a new instance of the <see cref="IntersectDirectionAndDistanceOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal IntersectDirectionAndDistanceOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Direction = editDeserializer.ReadPersistent <Direction>(DataField.Direction);
            m_Distance  = editDeserializer.ReadPersistent <Observation>(DataField.Distance);
            m_From      = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.From);
            m_Default   = editDeserializer.ReadBool(DataField.Default);
            FeatureStub to       = editDeserializer.ReadPersistent <FeatureStub>(DataField.To);
            FeatureStub dirLine  = editDeserializer.ReadPersistentOrNull <FeatureStub>(DataField.DirLine);
            FeatureStub distLine = editDeserializer.ReadPersistentOrNull <FeatureStub>(DataField.DistLine);

            DeserializationFactory dff = new DeserializationFactory(this);

            dff.AddFeatureStub(DataField.To, to);
            dff.AddFeatureStub(DataField.DirLine, dirLine);
            dff.AddFeatureStub(DataField.DistLine, distLine);
            ProcessFeatures(dff);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IntersectTwoDistancesOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal IntersectTwoDistancesOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Distance1 = editDeserializer.ReadPersistent <Observation>(DataField.Distance1);
            m_From1     = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.From1);
            m_Distance2 = editDeserializer.ReadPersistent <Observation>(DataField.Distance2);
            m_From2     = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.From2);
            m_Default   = editDeserializer.ReadBool(DataField.Default);
            FeatureStub to    = editDeserializer.ReadPersistent <FeatureStub>(DataField.To);
            FeatureStub line1 = editDeserializer.ReadPersistentOrNull <FeatureStub>(DataField.Line1);
            FeatureStub line2 = editDeserializer.ReadPersistentOrNull <FeatureStub>(DataField.Line2);

            DeserializationFactory dff = new DeserializationFactory(this);

            dff.AddFeatureStub(DataField.To, to);
            dff.AddFeatureStub(DataField.Line1, line1);
            dff.AddFeatureStub(DataField.Line2, line2);
            ProcessFeatures(dff);
        }
        /// <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);
        }
Exemplo n.º 14
0
        /// <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>
        /// 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();
             */
        }
        /// <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();
             */
        }
        /// <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 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="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);
 }
 /// <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);
 }
Exemplo n.º 21
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();
             */
        }
Exemplo n.º 23
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="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();
             */
        }