/// <summary>
        /// Creates a new <c>FindPointContainerQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="point">The position you want the container for</param>
        internal FindPointContainerQuery(ISpatialIndex index, IPointGeometry p)
        {
            m_Point = p;
            m_Result = null;
            IWindow w = new Window(p, p);
            index.QueryWindow(w, SpatialType.Polygon, OnQueryHit);

            // If we didn't get a result, but we skipped some candidates, check them now.
            if (m_Result==null && m_Candidates!=null)
            {
                // If NONE of the polygon's islands enclose the search position, that's
                // the result we want.

                foreach (Polygon cand in m_Candidates)
                {
                    Debug.Assert(cand.HasAnyIslands);

                    if (!cand.HasIslandEnclosing(m_Point))
                    {
                        m_Result = cand;
                        return;
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Default constructor
 /// </summary>
 internal PolygonFace()
 {
     m_Polygon = null;
     m_Divider = null;
     m_Begin = null;
     m_End = null;
     m_ExtraPoints = null;
 }
        /// <summary>
        /// Creates a new <c>FindPolygonLabelQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="polygon">The polygon that needs to be associated with a label</param>
        internal FindPolygonLabelQuery(ISpatialIndex index, Polygon polygon)
        {
            m_Polygon = polygon;
            m_Result = null;

            if (!polygon.HasAnyIslands)
                index.QueryWindow(m_Polygon.Extent, SpatialType.Text, OnTextFound);
        }
Example #4
0
        /// <summary>
        /// One-time definition of the topological divider that this face corresponds to.
        /// </summary>
        /// <param name="pol">The polygon this face is part of</param>
        /// <param name="line">The topological line that acts as the primary face for
        /// some portion of the polygon boundary</param>
        /// <returns>The number of points for this face (one for the start of the face,
        /// plus any intermediate points along the face).</returns>
        internal uint SetDivider(Polygon pol, IDivider line)
        {
            // Expect that this method should only ever get called once in the
            // lifetime of an instance
            Debug.Assert(m_ExtraPoints==null);

            // Define any extra points
            m_Polygon = pol;
            m_Divider = line;
            int nExtra = SetExtraPoints();
            return (uint)(1+nExtra);
        }
Example #5
0
        void ExportPolygon(Polygon pol)
        {
            // Get the exterior ring
            ILinearRing xr = GetLinearRing(pol);

            // Pick up any islands
            LinearRingCollection irs = null;
            if (pol.HasAnyIslands)
            {
                irs = new LinearRingCollection();

                foreach (Island i in pol.Islands)
                {
                    ILinearRing ir = GetLinearRing(i);
                    irs.Add(ir);
                }
            }

            IGeometry g = m_Factory.CreatePolygon(xr, irs);
            ExportGeometry(g);
        }
Example #6
0
        void ExportCurvePolygon(Polygon pol)
        {
            // Get the exterior ring
            IRing xr = GetRing(pol);

            // Pick up any islands
            RingCollection irs = new RingCollection();
            if (pol.HasAnyIslands)
            {
                foreach (Island i in pol.Islands)
                {
                    IRing ir = GetRing(i);
                    irs.Add(ir);
                }
            }

            IGeometry g = m_Factory.CreateCurvePolygon(xr, irs);
            ExportGeometry(g);
        }
        /// <summary>
        /// Delegate that's called whenever the index finds an object with an extent that
        /// overlaps the query window.
        /// </summary>
        /// <param name="item">The item to process (expected to be some sort of <c>Ring</c>)</param>
        /// <returns>True if the query should continue. False if the enclosing polygon has been found.</returns>
        private bool OnQueryHit(ISpatialObject item)
        {
            // We're only interested in real polygons (not islands)
            if (!(item is Polygon))
                return true;

            // The window of the polygon has to overlap.
            Polygon p = (Polygon)item;
            if (!p.Extent.IsOverlap(m_Point))
                return true;

            // Skip if it doesn't enclose the search position
            if (!p.IsRingEnclosing(m_Point))
                return true;

            // If the polygon contains any islands, remember the polygon
            // for a further look. Things like an unclosed street network
            // can have MANY islands, so checking whether the position falls
            // inside any of them is a bit laborious. We'll comes back to
            // this polygon if we can't find an easy match.

            if (p.HasAnyIslands)
            {
                if (m_Candidates==null)
                    m_Candidates = new List<Polygon>(1);

                m_Candidates.Add(p);
                return true;
            }

            m_Result = p;
            return false;
        }
Example #8
0
 /// <summary>
 /// Creates a new text feature
 /// </summary>
 /// <param name="creator">The operation creating the text</param>
 /// <param name="id">The internal ID of this feature within the
 /// project that created it.</param>
 /// <param name="ent">The entity type for the string.</param>
 /// <param name="text">The text geometry (including the text string itself)</param>
 /// </param>
 internal TextFeature(Operation creator, InternalIdValue id, IEntity ent, TextGeometry text)
     : base(creator, id, ent, null)
 {
     m_Geom = text;
     m_Container = null;
 }
Example #9
0
 /// <summary>
 /// Releases the association of this label with a polygon that is being removed.
 /// </summary>
 internal void OnPolygonDelete()
 {
     m_Container = null;
     SetBuilt(false);
 }
Example #10
0
 /// <summary>
 /// Creates a new <c>Island</c> polygon.
 /// </summary>
 /// <param name="rm">The metrics for this island</param>
 /// <param name="edge">The boundaries that define the exterior edge of the island,
 /// arranged in a (counter?)-clockwise cycle.</param>
 internal Island(RingMetrics rm, List<Face> edge)
     : base(rm, edge)
 {
     Debug.Assert(rm.SignedArea <= 0.0);
     m_Container = null;
 }