Example #1
0
        /// <summary>
        /// Delegate called to process every polygon in the map.
        /// Called by <see cref="BuildLabels"/>.
        /// </summary>
        /// <param name="o">A polygon ring in the spatial index</param>
        /// <returns>True (always), to force examination of the entire spatial index</returns>
        bool FindLabelForPolygon(ISpatialObject o)
        {
            Debug.Assert(o is Ring);

            if (o is Polygon)
            {
                // Only process polygons that don't already have a label, and which
                // don't contain any islands (polygons with islands tend to cover
                // much larget areas, so trying to find the label this way will
                // probably not be very efficient).

                Polygon p = (Polygon)o;
                if (p.Label == null && !p.HasAnyIslands)
                {
                    TextFeature label = new FindPolygonLabelQuery(m_Model.Index, p).Result;
                    if (label != null)
                    {
                        p.ClaimLabel(label);
                        label.SetBuilt(true);
                    }
                }
            }

            return(true);
        }