public override void Initialize() { Texture2D polygonTexture = GameInstance.Content.Load <Texture2D>("Texture"); uint[] data = new uint[polygonTexture.Width * polygonTexture.Height]; polygonTexture.GetData(data); Vertices verts = PolygonUtils.CreatePolygon(data, polygonTexture.Width); Vector2 scale = new Vector2(0.07f, -0.07f); verts.Scale(ref scale); Vector2 centroid = -verts.GetCentroid(); verts.Translate(ref centroid); Body compund = BodyFactory.CreateCompoundPolygon(World, Triangulate.ConvexPartition(verts, TriangulationAlgorithm.Bayazit), 1); compund.Position = new Vector2(-25, 30); //Body b = compund.DeepClone(); //b.Position = new Vector2(20, 30); //b.BodyType = BodyType.Dynamic; base.Initialize(); }
public bool ContainsLatLon(Vector2d coord) { ////first check tile var coordinateTileId = Conversions.LatitudeLongitudeToTileId( coord.x, coord.y, Tile.CurrentZoom); if (Points.Count > 0) { var from = Conversions.LatLonToMeters(coord.x, coord.y); var to = new Vector2d((Points[0][0].x / Tile.TileScale) + Tile.Rect.Center.x, (Points[0][0].z / Tile.TileScale) + Tile.Rect.Center.y); var dist = Vector2d.Distance(from, to); if (Mathd.Abs(dist) < 50) { return(true); } } //Debug.Log("Distance -> " + dist); { if ((!coordinateTileId.Canonical.Equals(Tile.CanonicalTileId))) { return(false); } //then check polygon var point = Conversions.LatitudeLongitudeToVectorTilePosition(coord, Tile.CurrentZoom); var output = PolygonUtils.PointInPolygon(new Point2d <float>(point.x, point.y), _geom); return(output); } }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, Lines, Framework.GraphicsDevice); Vertices rectangle1 = PolygonUtils.CreateRectangle(2f, 2f); Vertices rectangle2 = PolygonUtils.CreateRectangle(2f, 2f); Vector2 translation = new Vector2(-2f, 0f); rectangle1.Translate(ref translation); translation = new Vector2(2f, 0f); rectangle2.Translate(ref translation); List <Vertices> vertices = new List <Vertices>(2); vertices.Add(rectangle1); vertices.Add(rectangle2); _rectangles = BodyFactory.CreateCompoundPolygon(World, vertices, 1f); _rectangles.BodyType = BodyType.Dynamic; SetUserAgent(_rectangles, 200f, 200f); // create sprite based on rectangle fixture _rectangleSprite = new Sprite(ContentWrapper.PolygonTexture(rectangle1, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f)); _offset = new Vector2(ConvertUnits.ToDisplayUnits(2f), 0f); }
public override Vertices Process(Texture2DContent input, ContentProcessorContext context) { if (ScaleFactor < 1) { throw new Exception("Pixel to meter ratio must be greater than zero."); } PixelBitmapContent <Color> bitmapContent = (PixelBitmapContent <Color>)input.Faces[0][0]; uint[] colorData = new uint[bitmapContent.Width * bitmapContent.Height]; for (int i = 0; i < bitmapContent.Height; i++) { for (int j = 0; j < bitmapContent.Width; j++) { Color c = bitmapContent.GetPixel(j, i); c.R *= c.A; c.G *= c.A; c.B *= c.A; colorData[i * bitmapContent.Width + j] = c.PackedValue; } } Vertices outline = PolygonUtils.CreatePolygon(colorData, bitmapContent.Width, HoleDetection); Vector2 centroid = -outline.GetCentroid(); outline.Translate(ref centroid); Vector2 scale = new Vector2(_scaleFactor); outline.Scale(ref scale); return(outline); }
private PulleysTest() { //Ground Body ground = BodyFactory.CreateBody(World); FixtureFactory.AttachCircle(2, 0, ground, new Vector2(-10.0f, Y + B + L)); FixtureFactory.AttachCircle(2, 0, ground, new Vector2(10.0f, Y + B + L)); { PolygonShape shape = new PolygonShape(5); shape.Vertices = PolygonUtils.CreateRectangle(A, B); Body body1 = BodyFactory.CreateBody(World); body1.BodyType = BodyType.Dynamic; body1.Position = new Vector2(-10.0f, Y); body1.CreateFixture(shape); Body body2 = BodyFactory.CreateBody(World); body2.BodyType = BodyType.Dynamic; body2.Position = new Vector2(10.0f, Y); body2.CreateFixture(shape); Vector2 anchor1 = new Vector2(-10.0f, Y + B); Vector2 anchor2 = new Vector2(10.0f, Y + B); Vector2 groundAnchor1 = new Vector2(-10.0f, Y + B + L); Vector2 groundAnchor2 = new Vector2(10.0f, Y + B + L); _joint1 = new PulleyJoint(body1, body2, anchor1, anchor2, groundAnchor1, groundAnchor2, 1.5f, true); World.AddJoint(_joint1); } }
private PrismaticTest() { Body ground = BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f)); PolygonShape shape = new PolygonShape(5); shape.Vertices = PolygonUtils.CreateRectangle(2.0f, 0.5f); Body body = BodyFactory.CreateBody(World); body.BodyType = BodyType.Dynamic; body.Position = new Vector2(-10.0f, 10.0f); body.Rotation = 0.5f * Settings.Pi; body.CreateFixture(shape); // Bouncy limit Vector2 axis = new Vector2(2.0f, 1.0f); axis.Normalize(); _joint = new PrismaticJoint(ground, body, Vector2.Zero, Vector2.Zero, axis, true); // Non-bouncy limit //_joint = new PrismaticJoint(ground, body2, body2.Position, new Vector2(-10.0f, 10.0f), new Vector2(1.0f, 0.0f)); _joint.MotorSpeed = 5.0f; _joint.MaxMotorForce = 1000.0f; _joint.MotorEnabled = true; _joint.LowerLimit = -10.0f; _joint.UpperLimit = 20.0f; _joint.LimitEnabled = true; World.AddJoint(_joint); }
private CuttingTest() { //Ground BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f)); Vertices box = PolygonUtils.CreateRectangle(0.5f, 0.5f); PolygonShape shape = new PolygonShape(box, 5); Vector2 x = new Vector2(-7.0f, 0.75f); Vector2 deltaX = new Vector2(0.5625f, 1.25f); Vector2 deltaY = new Vector2(1.125f, 0.0f); for (int i = 0; i < Count; ++i) { Vector2 y = x; for (int j = i; j < Count; ++j) { Body body = BodyFactory.CreateBody(World); body.BodyType = BodyType.Dynamic; body.Position = y; body.CreateFixture(shape); y += deltaY; } x += deltaX; } }
public Pyramid(World world, Vector2 position, int count, float density) { Vertices rect = PolygonUtils.CreateRectangle(0.5f, 0.5f); PolygonShape shape = new PolygonShape(rect, density); Vector2 rowStart = position; rowStart.Y -= 0.5f + count * 1.1f; Vector2 deltaRow = new Vector2(-0.625f, 1.1f); const float spacing = 1.25f; // Physics _boxes = new List <Body>(); for (int i = 0; i < count; i++) { Vector2 pos = rowStart; for (int j = 0; j < i + 1; j++) { Body body = BodyFactory.CreateBody(world); body.BodyType = BodyType.Dynamic; body.Position = pos; body.CreateFixture(shape); _boxes.Add(body); pos.X += spacing; } rowStart += deltaRow; } //GFX _box = new Sprite(ContentWrapper.PolygonTexture(rect, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f)); }
/// <summary> /// Does validation on the project boundary points. /// </summary> private object ValidateProjectBoundary(string projectBoundary) { var result = GeofenceValidation.ValidateWKT(projectBoundary); if (string.CompareOrdinal(result, GeofenceValidation.ValidationOk) != 0) { if (string.CompareOrdinal(result, GeofenceValidation.ValidationNoBoundary) == 0) { return(new { code = 23, message = "Missing project boundary." }); } if (string.CompareOrdinal(result, GeofenceValidation.ValidationLessThan3Points) == 0) { return(new { code = 24, message = "Invalid project boundary as it should contain at least 3 points." }); } if (string.CompareOrdinal(result, GeofenceValidation.ValidationInvalidFormat) == 0) { return(new { code = 25, message = "Invalid project boundary." }); } if (string.CompareOrdinal(result, GeofenceValidation.ValidationInvalidPointValue) == 0) { return(new { code = 111, message = "Invalid project boundary points. Latitudes should be -90 through 90 and Longitude -180 through 180. Points around 0,0 are invalid." }); } } if (PolygonUtils.SelfIntersectingPolygon(projectBoundary)) { return(new { code = 129, message = "Self-intersecting project boundary." }); } return(new { code = ContractExecutionStatesEnum.ExecutedSuccessfully, message = ContractExecutionResult.DefaultMessage }); }
/// <summary> /// Get the voronoi cell for the given point using the clip polygon. /// </summary> /// <param name="point"></param> /// <param name="clipPolygon"></param> /// <returns></returns> public Cell GetVoronoiCell(Point point, Vector[] clipPolygon) { List <Vector> currentPolygon = GetCircumCenterVectors(point); if (currentPolygon.Count == 0) { return(null); } Cell cell; if (clipPolygon == null) { Vector centroid = PolygonUtils.GetMeanVector(currentPolygon.ToArray()); cell = new Cell(currentPolygon.ToArray(), centroid, ToVector(point)); } else { Vector[] clippedPoints = SutherlandHodgman.GetIntersectedPolygon(currentPolygon.ToArray(), clipPolygon); Vector centroid = PolygonUtils.GetMeanVector(clippedPoints); // create the cell including polygons and center point cell = new Cell(clippedPoints, centroid, ToVector(point)); } return(cell); }
public static Fixture AttachLineArc(float radians, int sides, float radius, bool closed, Body body) { Vertices arc = PolygonUtils.CreateArc(radians, sides, radius); arc.Rotate((MathHelper.Pi - radians) / 2); return(closed ? AttachLoopShape(arc, body) : AttachChainShape(arc, body)); }
private void GetLongestSegment(List <Vector2d> footprint, out float maxLength, out Vector2d start, out Vector2d end) { var result = ObjectPool.NewList <Vector2d>(); PolygonUtils.Simplify(footprint, result, 1, ObjectPool); maxLength = 0; start = default(Vector2d); end = default(Vector2d); for (int i = 0; i < result.Count; i++) { var s = result[i]; var e = result[i == result.Count - 1 ? 0 : i + 1]; var distance = s.DistanceTo(e); if (distance > maxLength) { start = s; end = e; maxLength = (float)distance; } } ObjectPool.StoreList(result); }
/// <summary> /// Get the voronoi cell for the given point using the clip polygon. /// </summary> /// <param name="point"></param> /// <param name="clipPolygon"></param> /// <returns></returns> public Cell GetVoronoiCell(Point point, Vector2[] clipPolygon) { List <Vector2> currentPolygon = GetCircumCenterVectors(point); if (currentPolygon.Count == 0) { return(null); } Cell cell; if (clipPolygon == null) { Vector2 centroid = PolygonUtils.GetMeanVector(currentPolygon.ToArray()); cell = new Cell(currentPolygon.ToArray(), centroid, ToVector(point)); } else { Vector2[] clippedPoints = SutherlandHodgman.GetIntersectedPolygon(currentPolygon.ToArray(), clipPolygon); if (clippedPoints.Length == 0) { UnityEngine.Debug.Log("Clipping algorithm returned non-intersecting polygon. Skipping it."); return(null); } Vector2 centroid = PolygonUtils.GetMeanVector(clippedPoints); // create the cell including polygons and center point cell = new Cell(clippedPoints, centroid, ToVector(point)); } return(cell); }
private BreakableTest() { // Ground body BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f)); // Breakable dynamic body _body1 = BodyFactory.CreateBody(World); _body1.BodyType = BodyType.Dynamic; _body1.Position = new Vector2(0.0f, 40.0f); _body1.Rotation = 0.25f * Settings.Pi; Vertices box = PolygonUtils.CreateRectangle(0.5f, 0.5f, new Vector2(-0.5f, 0.0f), 0.0f); PolygonShape shape1 = new PolygonShape(box, 1); _piece1 = _body1.CreateFixture(shape1); box = PolygonUtils.CreateRectangle(0.5f, 0.5f, new Vector2(0.5f, 0.0f), 0.0f); _shape2 = new PolygonShape(box, 1); _piece2 = _body1.CreateFixture(_shape2); _break = false; _broke = false; }
/// <summary> /// Creates the capsule using the specified world /// </summary> /// <param name="world">The world</param> /// <param name="height">The height</param> /// <param name="endRadius">The end radius</param> /// <param name="density">The density</param> /// <param name="position">The position</param> /// <param name="rotation">The rotation</param> /// <param name="bodyType">The body type</param> /// <param name="userData">The user data</param> /// <returns>The body</returns> public static Body CreateCapsule(World world, float height, float endRadius, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null !) { //Create the middle rectangle Vertices rectangle = PolygonUtils.CreateRectangle(endRadius, height / 2); List <Vertices> list = new List <Vertices> { rectangle }; Body body = CreateCompoundPolygon(world, list, density, position, rotation, bodyType, userData); FixtureFactory.AttachCircle(endRadius, density, body, new Vector2(0, height / 2)); FixtureFactory.AttachCircle(endRadius, density, body, new Vector2(0, -(height / 2))); //Create the two circles //CircleShape topCircle = new CircleShape(endRadius, density); //topCircle.Position = new Vector2(0, height / 2); //body.CreateFixture(topCircle); //CircleShape bottomCircle = new CircleShape(endRadius, density); //bottomCircle.Position = new Vector2(0, -(height / 2)); //body.CreateFixture(bottomCircle); return(body); }
private ContinuousTest() { List <Vertices> list = new List <Vertices>(); list.Add(PolygonUtils.CreateLine(new Vector2(-10.0f, 0.0f), new Vector2(10.0f, 0.0f))); list.Add(PolygonUtils.CreateRectangle(0.2f, 1.0f, new Vector2(0.5f, 1.0f), 0)); _ground = BodyFactory.CreateCompoundPolygon(World, list, 0); _box = BodyFactory.CreateRectangle(World, 4, 0.2f, 1); _box.Position = new Vector2(0, 20); _box.BodyType = BodyType.Dynamic; //_box.Body.Rotation = 0.1f; //_angularVelocity = 46.661274f; _angularVelocity = Rand.RandomFloat(-50.0f, 50.0f); _box.LinearVelocity = new Vector2(0.0f, -100.0f); _box.AngularVelocity = _angularVelocity; Distance.GJKCalls = 0; Distance.GJKIters = 0; Distance.GJKMaxIters = 0; TimeOfImpact.TOICalls = 0; TimeOfImpact.TOIIters = 0; TimeOfImpact.TOIRootIters = 0; TimeOfImpact.TOIMaxRootIters = 0; }
public Agent(World world, Vector2 position) { _collidesWith = Category.All; _collisionCategories = Category.All; Body = BodyFactory.CreateBody(world, position); Body.BodyType = BodyType.Dynamic; //Center FixtureFactory.AttachCircle(0.5f, 0.5f, Body); //Left arm FixtureFactory.AttachRectangle(1.5f, 0.4f, 1f, new Vector2(-1f, 0f), Body); FixtureFactory.AttachCircle(0.5f, 0.5f, Body, new Vector2(-2f, 0f)); //Right arm FixtureFactory.AttachRectangle(1.5f, 0.4f, 1f, new Vector2(1f, 0f), Body); FixtureFactory.AttachCircle(0.5f, 0.5f, Body, new Vector2(2f, 0f)); //Top arm FixtureFactory.AttachRectangle(0.4f, 1.5f, 1f, new Vector2(0f, 1f), Body); FixtureFactory.AttachCircle(0.5f, 0.5f, Body, new Vector2(0f, 2f)); //Bottom arm FixtureFactory.AttachRectangle(0.4f, 1.5f, 1f, new Vector2(0f, -1f), Body); FixtureFactory.AttachCircle(0.5f, 0.5f, Body, new Vector2(0f, -2f)); //GFX _box = new Sprite(ContentWrapper.PolygonTexture(PolygonUtils.CreateRectangle(1.75f, 0.2f), Color.White, ContentWrapper.Black)); _knob = new Sprite(ContentWrapper.CircleTexture(0.5f, "Square", ContentWrapper.Black, ContentWrapper.Gold, ContentWrapper.Black, 1f)); _offset = ConvertUnits.ToDisplayUnits(2f); }
/// <summary> /// Used by Create/Update project to check if any new boundary overlaps any OTHER project /// </summary> public static async Task <bool> DoesProjectOverlap(Guid customerUid, Guid?projectUid, Guid userUid, string projectBoundary, ILogger log, IServiceExceptionHandler serviceExceptionHandler, ICwsProjectClient cwsProjectClient, IHeaderDictionary customHeaders) { // get all active projects for customer, excluding this projectUid (i.e. update) // todo what are the rules e.g. active, for manual import? var projectDatabaseModelList = (await GetProjectListForCustomer(customerUid, userUid, log, serviceExceptionHandler, cwsProjectClient, CwsProjectType.AcceptsTagFiles, ProjectStatus.Active, false, true, customHeaders)) .Where(p => !p.IsArchived && p.ProjectType.HasFlag(CwsProjectType.AcceptsTagFiles) && (projectUid == null || string.Compare(p.ProjectUID.ToString(), projectUid.ToString(), StringComparison.OrdinalIgnoreCase) != 0)); // return once we find any overlapping projects foreach (var project in projectDatabaseModelList) { if (string.IsNullOrEmpty(project.Boundary)) { continue; } if (PolygonUtils.OverlappingPolygons(projectBoundary, project.Boundary)) { return(true); } } log.LogDebug($"{nameof(DoesProjectOverlap)}: No overlapping projects."); return(false); }
public void SelfIntersectingPolygon_HappyPath() { // Not self intersecting var result = PolygonUtils.SelfIntersectingPolygon("POLYGON((10 20,10 60,70 50, 50 20))"); Assert.False(result); }
private OneSidedPlatformTest() { //Ground BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f)); // Platform { Body body = BodyFactory.CreateBody(World); body.Position = new Vector2(0.0f, 10.0f); PolygonShape shape = new PolygonShape(1); shape.Vertices = PolygonUtils.CreateRectangle(3.0f, 0.5f); _platform = body.CreateFixture(shape); _top = 10.0f + 0.5f; } // Actor { Body body = BodyFactory.CreateBody(World); body.BodyType = BodyType.Dynamic; body.Position = new Vector2(0.0f, 12.0f); _radius = 0.5f; CircleShape shape = new CircleShape(_radius, 20); _character = body.CreateFixture(shape); body.LinearVelocity = new Vector2(0.0f, -50.0f); } }
public void PointInPolygon_Inside() { var projectBoundary = "POLYGON((170 10, 190 10, 190 40, 170 40, 170 10))"; var result = PolygonUtils.PointInPolygon(projectBoundary, 15, 180); Assert.True(result); }
public void OverlappingPolygons_InvalidPolygon() { var projectBoundary = "POLYGON((170 10, 190 10, 190 40, 170 40, 170 10))"; var testBoundary = "POLYGON((1 3,3 2,1 1,3 0,1 0,1 3))"; var result = PolygonUtils.OverlappingPolygons(projectBoundary, testBoundary); Assert.False(result); }
private TilesTest() { Stopwatch timer = new Stopwatch(); timer.Start(); { const float a = 0.5f; Body ground = BodyFactory.CreateBody(World, new Vector2(0, -a)); const int N = 200; const int M = 10; Vector2 position = Vector2.Zero; position.Y = 0.0f; for (int j = 0; j < M; ++j) { position.X = -N * a; for (int i = 0; i < N; ++i) { PolygonShape shape = new PolygonShape(0); shape.Vertices = PolygonUtils.CreateRectangle(a, a, position, 0.0f); ground.CreateFixture(shape); ++_fixtureCount; position.X += 2.0f * a; } position.Y -= 2.0f * a; } } { const float a = 0.5f; Vertices box = PolygonUtils.CreateRectangle(a, a); PolygonShape shape = new PolygonShape(box, 5); Vector2 x = new Vector2(-7.0f, 0.75f); Vector2 deltaX = new Vector2(0.5625f, 1.25f); Vector2 deltaY = new Vector2(1.125f, 0.0f); for (int i = 0; i < Count; ++i) { Vector2 y = x; for (int j = i; j < Count; ++j) { Body body = BodyFactory.CreateBody(World); body.BodyType = BodyType.Dynamic; body.Position = y; body.CreateFixture(shape); ++_fixtureCount; y += deltaY; } x += deltaX; } } timer.Stop(); _createTime = timer.ElapsedMilliseconds; }
public Objects(World world, Vector2 startPosition, Vector2 endPosition, int count, float radius, ObjectType type) { _bodies = new List <Body>(count); CollidesWith = Category.All; CollisionCategories = Category.All; // Physics for (int i = 0; i < count; i++) { switch (type) { case ObjectType.Circle: _bodies.Add(BodyFactory.CreateCircle(world, radius, 1f)); break; case ObjectType.Rectangle: _bodies.Add(BodyFactory.CreateRectangle(world, radius, radius, 1f)); break; case ObjectType.Star: _bodies.Add(BodyFactory.CreateGear(world, radius, 10, 0f, 1f, 1f)); break; case ObjectType.Gear: _bodies.Add(BodyFactory.CreateGear(world, radius, 10, 100f, 1f, 1f)); break; } } for (int i = 0; i < _bodies.Count; i++) { Body body = _bodies[i]; body.BodyType = BodyType.Dynamic; body.Position = Vector2.Lerp(startPosition, endPosition, i / (float)(count - 1)); body.Restitution = 0.7f; body.Friction = 0.2f; } //GFX switch (type) { case ObjectType.Circle: _object = new Sprite(ContentWrapper.CircleTexture(radius, ContentWrapper.Gold, ContentWrapper.Grey)); break; case ObjectType.Rectangle: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonUtils.CreateRectangle(radius / 2f, radius / 2f), ContentWrapper.Red, ContentWrapper.Grey)); break; case ObjectType.Star: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonUtils.CreateGear(radius, 10, 0f, 1f), ContentWrapper.Brown, ContentWrapper.Black)); break; case ObjectType.Gear: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonUtils.CreateGear(radius, 10, 100f, 1f), ContentWrapper.Orange, ContentWrapper.Grey)); break; } }
public void OverlappingPolygons_NotPolygon() { var projectBoundary = "POLYGON((170 10, 190 10, 190 40, 170 40, 170 10))"; var testBoundary = "LINESTRING(30 10, 10 30, 40 40)"; var result = PolygonUtils.OverlappingPolygons(projectBoundary, testBoundary); Assert.False(result); }
public void PolygonOrientationOK() { var projectBoundaryCounterClockwise = "POLYGON((170 10,190 10,190 40,170 40,170 10))"; var projectBoundary = projectBoundaryCounterClockwise; var resultPolygonWkt = PolygonUtils.MakeCounterClockwise(projectBoundary, out var hasBeenReversed); Assert.False(hasBeenReversed); Assert.Equal(projectBoundaryCounterClockwise, resultPolygonWkt); }
public void OverlappingPolygons_Intersecting() { // test polygon is intersecting project polygon var projectBoundary = "POLYGON((170 10, 190 10, 190 40, 170 40, 170 10))"; var testBoundary = "POLYGON((180 20, 210 20, 210 50, 180 50, 180 20))"; var result = PolygonUtils.OverlappingPolygons(projectBoundary, testBoundary); Assert.True(result); }
public void OverlappingPolygons_Overlapping() { // test polygon is completely overlapping project polygon var projectBoundary = "POLYGON((170 10, 190 10, 190 40, 170 40, 170 10))"; var testBoundary = "POLYGON((170 10, 190 10, 190 40, 170 40, 170 10))"; var result = PolygonUtils.OverlappingPolygons(projectBoundary, testBoundary); Assert.True(result); }
public void OverlappingPolygons_Edge() { // test polygon touches project polygon along an edge var projectBoundary = "POLYGON((170 10, 190 10, 190 40, 170 40, 170 10))"; var testBoundary = "POLYGON((190 10, 202 10, 202 20, 190 20, 190 10))"; var result = PolygonUtils.OverlappingPolygons(projectBoundary, testBoundary); Assert.True(result); }
public void OverlappingPolygons_Outside() { // test polygon is completely outside project polygon var projectBoundary = "POLYGON((170 10, 190 10, 190 40, 170 40, 170 10))"; var testBoundary = "POLYGON((200 10, 202 10, 202 20, 200 20, 200 10))"; var result = PolygonUtils.OverlappingPolygons(projectBoundary, testBoundary); Assert.False(result); }