示例#1
0
        /// <summary>
        /// Releases an island of this polygon. This gets done if the island has been
        /// marked for deletion.
        /// </summary>
        /// <param name="i">The island to release</param>
        internal void Release(Island i)
        {
            if (m_Islands == null)
            {
                throw new Exception("Attempt to release island, but polygon doesn't have any islands");
            }

            if (!m_Islands.Remove(i))
            {
                throw new Exception("Failed to remove island from enclosing polygon");
            }

            // Add the area of the island back to this polygon.
            SetArea(Area + i.Area);
        }
示例#2
0
        /// <summary>
        /// Creates a new <c>FindIslandContainerQuery</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="island">The island you want the container for</param>
        internal FindIslandContainerQuery(ISpatialIndex index, Island island)
        {
            m_Island = island;
            m_Result = null;

            // Get the most easterly point in the island.
            IPosition ep = m_Island.GetEastPoint();

            // Shift the east point ONE MICRON further to the east, to ensure
            // we don't pick up the interior of the island!
            PointGeometry eg = PointGeometry.Create(ep);

            m_EastPoint = new PointGeometry(eg.Easting.Microns + 1, eg.Northing.Microns);
            IWindow w = new Window(m_EastPoint, m_EastPoint);

            index.QueryWindow(w, SpatialType.Polygon, OnQueryHit);
        }
示例#3
0
        /// <summary>
        /// Relates this polygon to an island.
        /// </summary>
        /// <param name="island">The island to point to.</param>
        /// <return>True if association successfully made.</return>
        internal void ClaimIsland(Island island)
        {
            // Issue error if the inclusion of the island would reduce the
            // area of this polygon to less than zero.
            if (this.Area - island.Area < 0.0)
            {
                throw new Exception("AddIsland - wrong enclosing polygon");
            }

            // Adjust the area of this enclosing polygon
            SetArea(this.Area - island.Area);

            // Append the island to the list of islands known to this polygon
            if (m_Islands == null)
            {
                m_Islands = new List <Island>(1);
            }

            m_Islands.Add(island);

            // Define this polygon as the container for the island.
            island.Container = this;
        }
示例#4
0
        /// <summary>
        /// Releases an island of this polygon. This gets done if the island has been
        /// marked for deletion.
        /// </summary>
        /// <param name="i">The island to release</param>
        internal void Release(Island i)
        {
            if (m_Islands==null)
                throw new Exception("Attempt to release island, but polygon doesn't have any islands");

            if (!m_Islands.Remove(i))
                throw new Exception("Failed to remove island from enclosing polygon");

            // Add the area of the island back to this polygon.
            SetArea(Area + i.Area);
        }
示例#5
0
        /// <summary>
        /// Relates this polygon to an island.
        /// </summary>
        /// <param name="island">The island to point to.</param>
        /// <return>True if association successfully made.</return>
        internal void ClaimIsland(Island island)
        {
            // Issue error if the inclusion of the island would reduce the
            // area of this polygon to less than zero.
            if (this.Area - island.Area < 0.0)
                throw new Exception("AddIsland - wrong enclosing polygon");

            // Adjust the area of this enclosing polygon
            SetArea(this.Area - island.Area);

            // Append the island to the list of islands known to this polygon
            if (m_Islands==null)
                m_Islands = new List<Island>(1);

            m_Islands.Add(island);

            // Define this polygon as the container for the island.
            island.Container = this;
        }