public MgCurveRing CreateCurveRing(double offset) { // Ring is a closed entity. // Create and return a ring consisting of // one circulararc segment and one linearstring segment // arcseg = (0,0), (0,1), (1,2) // lineseg = (1,2), (0,0) // ArcSegment MgCoordinate startPos = factory.CreateCoordinateXY(offset + 0.0, offset + 0.0); MgCoordinate midPos = factory.CreateCoordinateXY(offset + 0.0, offset + 1.0); MgCoordinate endPos = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0); MgArcSegment arcSeg = factory.CreateArcSegment(startPos, endPos, midPos); // Linear Segment MgCoordinateCollection points = new MgCoordinateCollection(); MgCoordinate fromPt = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0); MgCoordinate toPt = factory.CreateCoordinateXY(offset + 0.0, offset + 0.0); points.Add(fromPt); points.Add(toPt); MgLinearSegment lineSeg = factory.CreateLinearSegment(points); // Curve Segment MgCurveSegmentCollection curveSegs = new MgCurveSegmentCollection(); curveSegs.Add(arcSeg); curveSegs.Add(lineSeg); return(factory.CreateCurveRing(curveSegs)); }
public void Execute(IPlatformFactory factory, ITestLogger logger) { var build = new GeomBuild(); MgArcSegment geom1 = build.CreateArcSegment(2.0); MgArcSegment geom2 = build.CreateArcSegment(12.0); MgArcSegment geom3 = build.CreateArcSegment(2.0); MgCurveSegmentCollection coll = new MgCurveSegmentCollection(); coll.Add(geom1); coll.Add(geom2); coll.Add(geom3); Assert.AreEqual(3, coll.Count); Assert.IsTrue(geom1.Envelope().Contains(coll[0].Envelope())); Assert.IsTrue(coll[0].Envelope().Contains(coll[2].Envelope())); Assert.IsFalse(coll[0].Envelope().Contains(coll[1].Envelope())); coll[0] = coll[1]; Assert.IsTrue(coll[0].Envelope().Contains(coll[1].Envelope())); double width = 0.0; foreach (MgCurveSegment geom in coll) { width += geom.Envelope().GetWidth(); } Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width); }
public MgCurveString CreateCurveString(double offset) { // Create and return a curvestring consisting of // one circulararc segment and one linearstring segment // arcseg = (0,0), (0,1), (1,2) // lineseg = (1,2), (3,0), (3,2) // ArcSegment MgCoordinate startPos = factory.CreateCoordinateXY(offset + 0.0, offset + 0.0); MgCoordinate midPos = factory.CreateCoordinateXY(offset + 0.0, offset + 1.0); MgCoordinate endPos = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0); MgArcSegment arcSeg = factory.CreateArcSegment(startPos, endPos, midPos); // Linear Segment MgCoordinateCollection points = new MgCoordinateCollection(); MgCoordinate pt1 = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0); MgCoordinate pt2 = factory.CreateCoordinateXY(offset + 3.0, offset + 0.0); MgCoordinate pt3 = factory.CreateCoordinateXY(offset + 3.0, offset + 2.0); points.Add(pt1); points.Add(pt2); points.Add(pt3); MgLinearSegment lineSeg = factory.CreateLinearSegment(points); // CurveSegment MgCurveSegmentCollection curveSegs = new MgCurveSegmentCollection(); curveSegs.Add(arcSeg); curveSegs.Add(lineSeg); return(factory.CreateCurveString(curveSegs)); }
public void Execute(IPlatformFactory factory, ITestLogger logger) { MgGeometryFactory gf = new MgGeometryFactory(); MgCoordinateXY start = gf.CreateCoordinateXY(0, 0) as MgCoordinateXY; MgCoordinateXY end = gf.CreateCoordinateXY(10, 10) as MgCoordinateXY; MgCoordinateXY control = gf.CreateCoordinateXY(5, 5) as MgCoordinateXY; MgArcSegment arcSegment = gf.CreateArcSegment(start, end, control); Assert.AreEqual(MgGeometryComponentType.ArcSegment, arcSegment.ComponentType); Assert.AreEqual(control.ToString(), arcSegment.ControlCoordinate.ToString()); Assert.AreEqual(start.ToString(), arcSegment.StartCoordinate.ToString()); Assert.AreEqual(end.ToString(), arcSegment.EndCoordinate.ToString()); }