Пример #1
0
        /// <summary>
        /// Ensure that this label knows it's enclosing polygon.
        /// </summary>
        /// <returns>True if label successfully associated with polygon.</returns>
        internal void SetPolygon()
        {
            // Return if this label is already associated with a polygon (or the
            // label was previously found to be inside nothing)
            if (IsBuilt)
            {
                return;
            }

            // If this is a non-topological label, mark is as "built"
            // and return (it should have been previously marked as built).
            if (IsTopological)
            {
                // Get the label's reference position.
                IPointGeometry posn = GetPolPosition();

                // Try to find enclosing polygon
                ISpatialIndex index = CadastralMapModel.Current.Index;
                Polygon       enc   = new FindPointContainerQuery(index, posn).Result;
                if (enc != null)
                {
                    enc.ClaimLabel(this);
                }
            }

            SetBuilt(true);
        }
Пример #2
0
        /// <summary>
        /// Re-calculates the polygon that encloses this label. This should be called whenever
        /// the polygon reference position gets changed (if a polygon reference position is
        /// not explicit, this will arise when the text itself is moved). Does nothing if the
        /// label is not currently marked as "built".
        /// </summary>
        internal void RecalculateEnclosingPolygon()
        {
            if (!IsBuilt)
            {
                return;
            }

            if (!IsTopological)
            {
                return;
            }

            // If a container was previously defined, first check whether it's still the
            // enclosing polygon (if so, we're done).
            IPointGeometry p = GetPolPosition();

            if (m_Container != null && m_Container.IsEnclosing(p))
            {
                return;
            }

            // If a container was previously defined, break the association with this label
            if (m_Container != null)
            {
                m_Container.ReleaseLabel(this);
                Debug.Assert(m_Container == null);
            }

            // Figure out which polygon now encloses this label (if any)
            ISpatialIndex index = CadastralMapModel.Current.Index;
            Polygon       enc   = new FindPointContainerQuery(index, p).Result;

            if (enc != null)
            {
                enc.ClaimLabel(this);
            }
        }
Пример #3
0
        private ISpatialObject SelectObject(ISpatialDisplay display, IPosition p, SpatialType spatialType)
        {
            ProjectSettings   ps         = m_Project.Settings;
            CadastralMapModel cmm        = this.CadastralMapModel;
            ISpatialSelection currentSel = this.SpatialSelection;
            ISpatialObject    oldItem    = currentSel.Item;
            ISpatialObject    newItem;

            // Try to find a point feature if points are drawn.
            if ((spatialType & SpatialType.Point) != 0 && display.MapScale <= ps.ShowPointScale)
            {
                ILength size = new Length(ps.PointHeight * 0.5);
                newItem = cmm.QueryClosest(p, size, SpatialType.Point);
                if (newItem != null)
                {
                    return(newItem);
                }
            }

            // If we are adding a line, don't bother trying to select
            // lines or polygons or text.

            /*
             * if (m_Op==ID_LINE_NEW || m_Op==ID_LINE_CURVE)
             *  return 0;
             */

            ILength tol = new Length(0.001 * display.MapScale);

            // Try to find a line, using a tolerance of 1mm at the draw scale.
            if ((spatialType & SpatialType.Line) != 0)
            {
                // If we previously selected something, see if the search point
                // lies within tolerance. If so, just return with what we've already got
                // ...just make the query (the issue here has to do with special highlighting
                // for topological sections -- if you point at another section of a line, the
                // highlighting doesn't move).

                // if (oldItem!=null && oldItem.SpatialType==SpatialType.Line)
                // {
                //     ILength dist = oldItem.Distance(p);
                //     if (dist.Meters < tol.Meters)
                //         return;
                // }

                newItem = cmm.QueryClosest(p, tol, SpatialType.Line);
                if (newItem != null)
                {
                    return(newItem);
                }
            }

            // Try for a text string if text is drawn.
            // The old software handles text by checking that the point is inside
            // the outline, not sure whether the new index provides acceptable alternative.
            if ((spatialType & SpatialType.Text) != 0 && display.MapScale <= ps.ShowLabelScale)
            {
                newItem = cmm.QueryClosest(p, tol, SpatialType.Text);
                if (newItem != null)
                {
                    return(newItem);
                }
            }

            // Just return if a command dialog is up,
            // since selecting a polygon is distracting at that stage
            // (really, this applies to things like intersect commands).
            // There MIGHT be cases at some later date where we really
            // do want to select pols...
            // For updates, allow polygon selection

            if (IsCommandRunning && !(m_Command is UpdateUI))
            {
                return(null);
            }

            if ((spatialType & SpatialType.Polygon) != 0)
            {
                // If we currently have a selected polygon, see if we're still inside it.

                /*
                 * if (oldItem is Polygon)
                 * {
                 *  Polygon oldPol = (oldItem is Polygon);
                 *  if (oldPol.IsEnclosing(p))
                 *
                 * }
                 */

                IPointGeometry pg    = PointGeometry.Create(p);
                ISpatialIndex  index = cmm.Index;
                Polygon        pol   = new FindPointContainerQuery(index, pg).Result;
                if (pol != null)
                {
                    return(pol);
                }
            }

            return(null);
        }
Пример #4
0
        private ISpatialObject SelectObject(ISpatialDisplay display, IPosition p, SpatialType spatialType)
        {
            ProjectSettings ps = m_Project.Settings;
            CadastralMapModel cmm = this.CadastralMapModel;
            ISpatialSelection currentSel = this.SpatialSelection;
            ISpatialObject oldItem = currentSel.Item;
            ISpatialObject newItem;

            // Try to find a point feature if points are drawn.
            if ((spatialType & SpatialType.Point) != 0 && display.MapScale <= ps.ShowPointScale)
            {
                ILength size = new Length(ps.PointHeight * 0.5);
                newItem = cmm.QueryClosest(p, size, SpatialType.Point);
                if (newItem!=null)
                    return newItem;
            }

            // If we are adding a line, don't bother trying to select
            // lines or polygons or text.
            /*
            if (m_Op==ID_LINE_NEW || m_Op==ID_LINE_CURVE)
                return 0;
             */

            ILength tol = new Length(0.001 * display.MapScale);

            // Try to find a line, using a tolerance of 1mm at the draw scale.
            if ((spatialType & SpatialType.Line)!=0)
            {
                // If we previously selected something, see if the search point
                // lies within tolerance. If so, just return with what we've already got
                // ...just make the query (the issue here has to do with special highlighting
                // for topological sections -- if you point at another section of a line, the
                // highlighting doesn't move).

                // if (oldItem!=null && oldItem.SpatialType==SpatialType.Line)
                // {
                //     ILength dist = oldItem.Distance(p);
                //     if (dist.Meters < tol.Meters)
                //         return;
                // }

                newItem = cmm.QueryClosest(p, tol, SpatialType.Line);
                if (newItem!=null)
                    return newItem;
            }

            // Try for a text string if text is drawn.
            // The old software handles text by checking that the point is inside
            // the outline, not sure whether the new index provides acceptable alternative.
            if ((spatialType & SpatialType.Text)!=0 && display.MapScale <= ps.ShowLabelScale)
            {
                newItem = cmm.QueryClosest(p, tol, SpatialType.Text);
                if (newItem!=null)
                    return newItem;
            }

            // Just return if a command dialog is up,
            // since selecting a polygon is distracting at that stage
            // (really, this applies to things like intersect commands).
            // There MIGHT be cases at some later date where we really
            // do want to select pols...
            // For updates, allow polygon selection

            if (IsCommandRunning && !(m_Command is UpdateUI))
                return null;

            if ((spatialType & SpatialType.Polygon)!=0)
            {
                // If we currently have a selected polygon, see if we're still inside it.
                /*
                if (oldItem is Polygon)
                {
                    Polygon oldPol = (oldItem is Polygon);
                    if (oldPol.IsEnclosing(p))

                }
                */

                IPointGeometry pg = PointGeometry.Create(p);
                ISpatialIndex index = cmm.Index;
                Polygon pol = new FindPointContainerQuery(index, pg).Result;
                if (pol!=null)
                    return pol;
            }

            return null;
        }
Пример #5
0
        /// <summary>
        /// Ensure that this label knows it's enclosing polygon.
        /// </summary>
        /// <returns>True if label successfully associated with polygon.</returns>
        internal void SetPolygon()
        {
            // Return if this label is already associated with a polygon (or the
            // label was previously found to be inside nothing)
            if (IsBuilt)
                return;

            // If this is a non-topological label, mark is as "built"
            // and return (it should have been previously marked as built).
            if (IsTopological)
            {
                // Get the label's reference position.
                IPointGeometry posn = GetPolPosition();

                // Try to find enclosing polygon
                ISpatialIndex index = CadastralMapModel.Current.Index;
                Polygon enc = new FindPointContainerQuery(index, posn).Result;
                if (enc!=null)
                    enc.ClaimLabel(this);
            }

            SetBuilt(true);
        }
Пример #6
0
        /// <summary>
        /// Re-calculates the polygon that encloses this label. This should be called whenever
        /// the polygon reference position gets changed (if a polygon reference position is
        /// not explicit, this will arise when the text itself is moved). Does nothing if the
        /// label is not currently marked as "built".
        /// </summary>
        internal void RecalculateEnclosingPolygon()
        {
            if (!IsBuilt)
                return;

            if (!IsTopological)
                return;

            // If a container was previously defined, first check whether it's still the
            // enclosing polygon (if so, we're done).
            IPointGeometry p = GetPolPosition();
            if (m_Container!=null && m_Container.IsEnclosing(p))
                return;

            // If a container was previously defined, break the association with this label
            if (m_Container!=null)
            {
                m_Container.ReleaseLabel(this);
                Debug.Assert(m_Container==null);
            }

            // Figure out which polygon now encloses this label (if any)
            ISpatialIndex index = CadastralMapModel.Current.Index;
            Polygon enc = new FindPointContainerQuery(index, p).Result;
            if (enc!=null)
                enc.ClaimLabel(this);
        }