public IDivider[] IncidentDividers() { List <IDivider> result = new List <IDivider>(4); // 4 is frequently the number in the result foreach (IFeatureDependent fd in Dependents) { if (fd is LineFeature) { LineFeature line = (fd as LineFeature); Topology t = line.Topology; if (t != null) { // Could have a situation where BOTH start and end of the line end // at the same point (e.g. a multisegment that loops back on itself). bool sMatch = line.StartPoint.IsCoincident(this); bool eMatch = line.EndPoint.IsCoincident(this); if (sMatch) { IDivider d = t.FirstDivider; if (!d.IsOverlap) { result.Add(d); } } if (eMatch) { // The result could conceivably contain the divider already (case where a multi-segment // closes on itself) IDivider d = t.LastDivider; if (!d.IsOverlap && !result.Contains(d)) { result.Add(d); } } if (!(sMatch || eMatch)) { // Cover a situation where this point is referenced to a line that // passes through (intersection). Debug.Assert(t is SectionTopologyList); SectionTopologyList sections = (t as SectionTopologyList); sections.AddIncidentDividers(result, this); } } } } return(result.ToArray()); }
/// <summary> /// Creates a new <c>Selection</c> that contains a single item (or nothing). /// </summary> /// <param name="so">The object to remember as part of this selection (if null, it /// will not be added to the selection)</param> /// <param name="searchPosition">A position associated with the selection (null /// if a specific position isn't relevant). This is used to determine whether a /// topological section is relevant when a line is selected.</param> public Selection(ISpatialObject so, IPosition searchPosition) { m_Items = new List<ISpatialObject>(1); if (so!=null) m_Items.Add(so); // If we're dealing with a single line that's been topologically sectioned, // determine which divider we're closest to. m_Section = null; if (searchPosition != null) { LineFeature line = (so as LineFeature); if (line != null && line.Topology is SectionTopologyList) { SectionTopologyList sections = (line.Topology as SectionTopologyList); IDivider d = sections.FindClosestSection(searchPosition); if (d != null) m_Section = new DividerObject(d); } } }