public void FullEarthRectContainsSegmentCrossingPrimeMeridian() { Rect fullEarth = GetFullEarthRect(); GeoCoordinates segA = new GeoCoordinates(-10, 170); GeoCoordinates segB = new GeoCoordinates(10, 190); GeoSegment seg = new GeoSegment(segA, segB); Assert.True(GeoRectUtils.RectNearSegment(seg, fullEarth, 0)); }
public void FullEarthRectContainsAverageSegment() { Rect fullEarth = GetFullEarthRect(); GeoCoordinates segA = new GeoCoordinates(0, -10); GeoCoordinates segB = new GeoCoordinates(10, 10); GeoSegment seg = new GeoSegment(segA, segB); Assert.True(GeoRectUtils.RectNearSegment(seg, fullEarth, 0)); }
public void RectWrappingAroundGlobeIsValid() { Rect rect = new Rect { xMin = -200, xMax = 200, yMin = -10, yMax = 10 }; Assert.True(GeoRectUtils.IsValidGeoRect(rect)); }
public void GeoRectIsWithinDistanceOfSegment() { Rect rect = new Rect { xMin = -10, xMax = 10, yMin = -10, yMax = 10 }; GeoCoordinates segA = new GeoCoordinates(11, -20); GeoCoordinates segB = new GeoCoordinates(11, 20); GeoSegment seg = new GeoSegment(segA, segB); Assert.True(GeoRectUtils.RectNearSegment(seg, rect, 1 + 1e-10)); }
public void GeoRectIsNearSegmentThatIntersectsItsEdge() { Rect rect = new Rect { xMin = -10, xMax = 10, yMin = -10, yMax = 10 }; GeoCoordinates segA = new GeoCoordinates(0, -20); GeoCoordinates segB = new GeoCoordinates(0, 20); GeoSegment seg = new GeoSegment(segA, segB); Assert.True(GeoRectUtils.RectNearSegment(seg, rect, 0)); }
public void GeoRectIsNearSegmentItContains() { Rect rect = new Rect { xMin = -10, xMax = 10, yMin = -10, yMax = 10 }; GeoCoordinates segA = new GeoCoordinates(-1, 0); GeoCoordinates segB = new GeoCoordinates(1, 0); GeoSegment seg = new GeoSegment(segA, segB); Assert.True(GeoRectUtils.RectNearSegment(seg, rect, 0)); }
public void RectNearSegmentWorksWithRectCrossingPrimeMeridian2() { Rect rect = new Rect { xMin = -185, xMax = -175, yMin = -10, yMax = 10 }; GeoCoordinates segA = new GeoCoordinates(-30, -177); GeoCoordinates segB = new GeoCoordinates(30, -177); GeoSegment seg = new GeoSegment(segA, segB); Assert.True(GeoRectUtils.RectNearSegment(seg, rect, 0)); }
public void SmallRectContainsSegmentCrossingPrimeMeridianOnOppositeSide() { Rect rect = new Rect { xMin = -181, xMax = -179, yMin = 10, yMax = 13 }; GeoCoordinates segA = new GeoCoordinates(11, 170); GeoCoordinates segB = new GeoCoordinates(11, 190); GeoSegment seg = new GeoSegment(segA, segB); Assert.True(GeoRectUtils.RectNearSegment(seg, rect, 0)); }
public void RectIsntNearSegment() { Rect rect = new Rect { xMin = -10, xMax = 10, yMin = -10, yMax = 10 }; GeoCoordinates segA = new GeoCoordinates(11, -20); GeoCoordinates segB = new GeoCoordinates(11, 20); GeoSegment seg = new GeoSegment(segA, segB); Assert.False(GeoRectUtils.RectNearSegment(seg, rect, 0.5)); }
public ActionResult <IEnumerable <GeoCoordinates> > GetUsersIn(double minLongitude, double maxLongitude, double minLatitude, double maxLatitude) { Rect rect = new Rect { xMin = minLongitude, xMax = maxLongitude, yMin = minLatitude, yMax = maxLatitude }; if (!GeoRectUtils.IsValidGeoRect(rect)) { return(BadRequest()); } return(Ok(Users.GetActiveUsersIn(rect.Intersects).Select((user) => user.LastKnownLocation))); }
public void RectCrossingPolesNotValid() { Rect rectCrossingNorth = new Rect { xMin = -10, xMax = 10, yMin = 50, yMax = 100 }; Rect rectCrossingSouth = new Rect { xMin = -10, xMax = 10, yMin = 50, yMax = 100 }; Assert.False(GeoRectUtils.IsValidGeoRect(rectCrossingNorth)); Assert.False(GeoRectUtils.IsValidGeoRect(rectCrossingSouth)); }
public void GeoRectsIntersectTheory(Rect rect1, Rect rect2, string message) { Assert.True(GeoRectUtils.Intersect(rect1, rect2), message); }
public void RectIsValidTheory(Rect rect, string message) { Assert.True(GeoRectUtils.IsValidGeoRect(rect), message); }