public virtual void Quadrants() { //random line BufferedLine line = NewRandomLine(); // if (line.getA().equals(line.getB())) // return;//this test doesn't work IRectangle rect = NewRandomLine().BoundingBox; //logShapes(line, rect); //compute closest corner brute force List <IPoint> corners = QuadrantCorners(rect); // a collection instead of 1 value due to ties List <int?> farthestDistanceQuads = new List <int?>(); double farthestDistance = -1; int quad = 1; foreach (IPoint corner in corners) { double d = line.LinePrimary.DistanceUnbuffered(corner); if (Math.Abs(d - farthestDistance) < 0.000001) {//about equal farthestDistanceQuads.Add(quad); } else if (d > farthestDistance) { farthestDistanceQuads.Clear(); farthestDistanceQuads.Add(quad); farthestDistance = d; } quad++; } //compare results int calcClosestQuad = line.LinePrimary.Quadrant(rect.Center); Assert.True(farthestDistanceQuads.Contains(calcClosestQuad)); }
public virtual void Misc() { //pa == pb IPoint pt = ctx.MakePoint(10, 1); BufferedLine line = new BufferedLine(pt, pt, 3, ctx); Assert.True(line.Contains(ctx.MakePoint(10, 1 + 3 - 0.1))); Assert.False(line.Contains(ctx.MakePoint(10, 1 + 3 + 0.1))); }
// @Rule //public TestLog testLog = TestLog.instance; //SpatialContext.GEO ;// public static void LogShapes(BufferedLine line, IRectangle rect) { string lineWKT = "LINESTRING(" + line.A.X + " " + line.A.Y + "," + line.B.X + " " + line.B.Y + ")"; Console.WriteLine( "GEOMETRYCOLLECTION(" + lineWKT + "," + RectToWkt(line.BoundingBox ) + ")"); string rectWKT = RectToWkt(rect); Console.WriteLine(rectWKT); }