/// <summary> /// Creates a new <c>GeometryWrapper</c> that wraps the supplied geometry. /// </summary> /// <param name="g">The geometry to wrap</param> /// <exception cref="ArgumentException">If the geometry can't be mapped to one of the /// types defined by the <c>SpatialType</c> enum.</exception> internal GeometryWrapper(NTS.Geometry g) { m_Geometry = g; // Throw exception on unexpected type SpatialType type = this.SpatialType; }
public void GetNearestFeatureReturnsNullWhenNoNearestFeaturesCanBeFound() { var features = new[] { new Feature {Geometry = new Point(0, 0)}, new Feature {Geometry = new Point(2, 0)}, new Feature {Geometry = new Point(2, 2)} }; var feature2 = GeometryHelper.GetNearestFeature(new Coordinate(1, 1), features, 0.5); feature2 .Should("tolerance is too small") .Be.Null(); }
public void GetNearestFeatureReturnsLastNearestFeature() { var features = new[] { new Feature {Geometry = new Point(0, 0)}, new Feature {Geometry = new Point(2, 0)}, new Feature {Geometry = new Point(2, 2)} }; var feature1 = GeometryHelper.GetNearestFeature(new Coordinate(1, 1), features, 3); feature1 .Should("the last feature is chosen if more than 1 featres with the same distance are found") .Be.EqualTo(features[2]); }
/// <summary> /// Creates a new <c>PointWrapper</c> that wraps the supplied geometry. /// </summary> /// <param name="g">The geometry to wrap</param> internal PointWrapper(NTS.Point p) : base(p) { }
/// <summary> /// Converts an array of NTS coordinates into Backsight positions /// </summary> /// <param name="cos">The coordinates to convert</param> /// <returns>The corresponding positions</returns> IPosition[] GetPositionArray(NTS.Coordinate[] cos) { IPosition[] pts = new Position[cos.Length]; for (int i=0; i<cos.Length; i++) { NTS.Coordinate c = cos[i]; pts[i] = new Position(c.X, c.Y); } return pts; }
private List<NTS.Geometry> GetBasicGeometries(NTS.Geometry geom) { List<NTS.Geometry> result = new List<NTS.Geometry>(); AppendBasicGeometries(result, geom); return result; }
private void AppendBasicGeometries(List<NTS.Geometry> result, NTS.Geometry geom) { if (geom is GeometryCollection) { // Note that I initially had 'foreach (NTS.Geometry g in gc)', which compiled, // but which led to an infinite loop when dealing with multi-polygons. GeometryCollection gc = (GeometryCollection)geom; NTS.Geometry[] ga = gc.Geometries; foreach (NTS.Geometry g in ga) AppendBasicGeometries(result, g); // recurse } else result.Add(geom); }