Class ShapeCollection
A collection of Shape objects, analogous to an OGC GeometryCollection. The implementation demands a List (with random access) so that the order can be retained if an application requires it, although logically it's treated as an unordered Set, mostly.
Ideally, Relate(IShape) should return the same result no matter what the shape order is, although the default implementation can be order dependent when the shapes overlap; see RelateContainsShortCircuits(). To improve performance slightly, the caller could order the shapes by largest first so that Relate() will have a greater chance of short-circuit'ing sooner. As the Shape contract states; it may return intersects when the best answer is actually contains or within.If any shape intersects the provided shape then that is the answer.
This implementation is not optimized for a large number of shapes; relate is O(N). A more sophisticated implementation might do an R-Tree based on bbox'es, for example.
Inheritance
Inherited Members
Assembly: Spatial4n.dll
Syntax
[Serializable]
public class ShapeCollection : ICollection<IShape>, IEnumerable<IShape>, IEnumerable, IShape
Constructors
Name | Description |
---|---|
ShapeCollection(IList<IShape>, SpatialContext) | WARNING: |
Fields
Name | Description |
---|---|
m_bbox | |
m_shapes |
Properties
Name | Description |
---|---|
BoundingBox | |
Center | |
Count | |
HasArea | |
IsEmpty | |
IsReadOnly | |
Item[Int32] | |
Shapes |
Methods
Name | Description |
---|---|
Add(IShape) | |
Clear() | |
ComputeBoundingBox(ICollection<IShape>, SpatialContext) | |
ComputeMutualDisjoint(IList<IShape>) | Computes whether the shapes are mutually disjoint. This is a utility method offered for use by a subclass implementing RelateContainsShortCircuits(). Beware: this is an O(N^2) algorithm.. Consequently, consider safely assuming non-disjoint if shapes.Count > 10 or something. And if all shapes are a IPoint then the result of this method doesn't ultimately matter. |
Contains(IShape) | |
CopyTo(IShape[], Int32) | |
Equals(Object) | |
GetArea(SpatialContext) | |
GetBuffered(Double, SpatialContext) | |
GetEnumerator() | |
GetHashCode() | |
Relate(IShape) | |
RelateContainsShortCircuits() | Called by Relate(IShape) to determine whether to return early if it finds CONTAINS, instead of checking the remaining shapes. It will do so without calling this method if the "other" shape is a Point. If a remaining shape finds INTERSECTS, then INTERSECTS will be returned. The only problem with this returning true is that if some of the shapes overlap, it's possible that the result of Relate(IShape) could be dependent on the order of the shapes, which could be unexpected / wrong depending on the application. The default implementation returns true because it probably doesn't matter. If it does, a subclass could add a boolean flag that this method could return. That flag could be initialized to true only if the shapes are mutually disjoint. |
Remove(IShape) | |
ToString() |
Explicit Interface Implementations
Name | Description |
---|---|
IEnumerable.GetEnumerator() |