Пример #1
0
        /// <summary>
        /// Creates a new simple line segment.
        /// </summary>
        /// <param name="start">The point at the start of the new line.</param>
        /// <param name="end">The point at the end of the new line.</param>
        /// <remarks>When you add a new line segment, the two end points will be referenced both to the
        /// new line, and to the editing operation that defined the line. While this is a bit verbose,
        /// it's consistent.</remarks>
        internal void Execute(PointFeature start, PointFeature end)
        {
            // Disallow an attempt to add a null line.
            if (start.Geometry.IsCoincident(end.Geometry))
            {
                throw new Exception("NewLineOperation.Execute - Attempt to add null line.");
            }

            // Add the new line with default entity type.
            CadastralMapModel mapModel = this.MapModel;
            LineFeature       newLine  = mapModel.AddLine(start, end, mapModel.DefaultLineType, this);

            base.SetNewLine(newLine);

            // Peform standard completion steps
            Complete();
        }
Пример #2
0
        /// <summary>
        /// Executes this operation.
        /// </summary>
        /// <param name="sub">The polygon subdivision information.</param>
        internal void Execute(PolygonSub sub)
        {
            int numLine = sub.NumLink;

            if (numLine == 0)
            {
                throw new Exception("PolygonSubdivisionOperation.Execute - Nothing to add");
            }

            // If the polygon contains just one label, de-activate it. This covers a "well-behaved" situation,
            // where the label inside the polygon is likely to be redundant after the subdivision (it also
            // conforms to logic used in the past). In a situation where the polygon contains multiple labels,
            // it's less clear whether the labels become redundant or not, so we keep them all.
            Polygon pol = sub.Polygon;

            if (pol.LabelCount == 1)
            {
                m_Label = pol.Label;
                if (m_Label != null)
                {
                    m_Label.IsInactive = true;
                }
            }

            // Mark the polygon for deletion
            pol.IsDeleted = true;

            // Get the default entity type for lines.
            CadastralMapModel map = MapModel;
            IEntity           ent = map.DefaultLineType;

            // Allocate array to point to the lines we will be creating.
            m_Lines = new LineFeature[numLine];

            // Add lines for each link
            PointFeature start, end;

            for (int i = 0; sub.GetLink(i, out start, out end); i++)
            {
                m_Lines[i] = map.AddLine(start, end, ent, this);
            }

            // Peform standard completion steps
            Complete();
        }