/// <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); }
/// <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); } }
/// <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); }
/// <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); }