/// <summary> /// Delegate that's called whenever the index finds text with a window that overlaps the query window /// </summary> /// <param name="item">The item to process (expected to be some sort of <c>TextFeature</c>)</param> /// <returns>True (always), indicating that the query should continue.</returns> private bool OnTextFound(ISpatialObject item) { // Ignore test that's already been built TextFeature text = (TextFeature)item; if (text.IsBuilt) { return(true); } if (text.IsTopological) { // Get the label's reference position. IPointGeometry posn = text.GetPolPosition(); // Try to find enclosing polygon if (m_Polygon.IsEnclosing(posn)) { m_Result = text; return(false); } } return(true); }
/// <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); } }