public virtual void TestPolyline() { com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline(); polyline.StartPath(-97.06138, 32.837); polyline.LineTo(-97.06133, 32.836); polyline.LineTo(-97.06124, 32.834); polyline.LineTo(-97.06127, 32.832); polyline.StartPath(-97.06326, 32.759); polyline.LineTo(-97.06298, 32.755); { com.fasterxml.jackson.core.JsonParser polylinePathsWgs84Parser = factory.CreateJsonParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, polyline)); com.epl.geometry.MapGeometry mPolylineWGS84MP = com.epl.geometry.GeometryEngine.JsonToGeometry(polylinePathsWgs84Parser); NUnit.Framework.Assert.IsTrue(polyline.GetPointCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPointCount()); NUnit.Framework.Assert.IsTrue(polyline.GetPoint(0).GetX() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(0).GetX()); NUnit.Framework.Assert.IsTrue(polyline.GetPoint(0).GetY() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(0).GetY()); NUnit.Framework.Assert.IsTrue(polyline.GetPathCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPathCount()); NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount()); NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount(0) == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount(0)); NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount(1) == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount(1)); int lastIndex = polyline.GetPointCount() - 1; NUnit.Framework.Assert.IsTrue(polyline.GetPoint(lastIndex).GetX() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(lastIndex).GetX()); NUnit.Framework.Assert.IsTrue(polyline.GetPoint(lastIndex).GetY() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(lastIndex).GetY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPolylineWGS84MP.GetSpatialReference().GetID()); com.epl.geometry.Polyline emptyPolyline = new com.epl.geometry.Polyline(); string emptyString = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, emptyPolyline); mPolylineWGS84MP = com.epl.geometry.GeometryEngine.JsonToGeometry(factory.CreateJsonParser(emptyString)); NUnit.Framework.Assert.IsTrue(mPolylineWGS84MP.GetGeometry().IsEmpty()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPolylineWGS84MP.GetSpatialReference().GetID()); } }
public virtual void TestEqualsOnPolylines() { com.epl.geometry.SpatialReference sr = com.epl.geometry.SpatialReference.Create(4326); com.epl.geometry.Polyline baseMp = new com.epl.geometry.Polyline(); com.epl.geometry.Polyline compMp = new com.epl.geometry.Polyline(); baseMp.StartPath(-116, 40); baseMp.LineTo(-120, 39); baseMp.LineTo(-121, 10); baseMp.LineTo(-130, 12); baseMp.LineTo(-108, 25); compMp.StartPath(-116, 40); compMp.LineTo(-120, 39); compMp.LineTo(-121, 10); compMp.LineTo(-130, 12); compMp.LineTo(-108, 25); bool isEqual; try { isEqual = com.epl.geometry.GeometryEngine.Equals(baseMp, compMp, sr); } catch (System.ArgumentException) { isEqual = false; } NUnit.Framework.Assert.IsTrue(isEqual); }
public virtual void TestPointAndPolyline1() { com.epl.geometry.Point basePl = new com.epl.geometry.Point(-116, 20); com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline(); compPl.StartPath(new com.epl.geometry.Point(-116, 20)); compPl.LineTo(new com.epl.geometry.Point(-131, 10)); compPl.LineTo(new com.epl.geometry.Point(-121, 50)); int noException = 1; // no exception com.epl.geometry.Geometry intersectGeom = null; try { intersectGeom = com.epl.geometry.GeometryEngine.Intersect(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326)); } catch (System.Exception) { noException = 0; } NUnit.Framework.Assert.AreEqual(noException, 1); NUnit.Framework.Assert.IsNotNull(intersectGeom); NUnit.Framework.Assert.IsTrue(intersectGeom.GetType() == com.epl.geometry.Geometry.Type.Point); com.epl.geometry.Point ip = (com.epl.geometry.Point)intersectGeom; NUnit.Framework.Assert.AreEqual(ip.GetX(), -116, 0.1E7); NUnit.Framework.Assert.AreEqual(ip.GetY(), 20, 0.1E7); }
public static void TestGetXCorrectCR185697() { com.epl.geometry.OperatorFactoryLocal engine = com.epl.geometry.OperatorFactoryLocal.GetInstance(); com.epl.geometry.OperatorClip clipOp = (com.epl.geometry.OperatorClip)engine.GetOperator(com.epl.geometry.Operator.Type.Clip); com.epl.geometry.Polyline polylineCR = MakePolylineCR(); com.epl.geometry.SimpleGeometryCursor polylineCursCR = new com.epl.geometry.SimpleGeometryCursor(polylineCR); com.epl.geometry.SpatialReference gcsWGS84 = com.epl.geometry.SpatialReference.Create(4326); com.epl.geometry.Envelope2D envelopeCR = new com.epl.geometry.Envelope2D(); envelopeCR.xmin = -180; envelopeCR.xmax = 180; envelopeCR.ymin = -90; envelopeCR.ymax = 90; // CR com.epl.geometry.Polyline clippedPolylineCR = (com.epl.geometry.Polyline)clipOp.Execute(polylineCR, envelopeCR, gcsWGS84, null); com.epl.geometry.Point pointResult = new com.epl.geometry.Point(); clippedPolylineCR.GetPointByVal(0, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.GetX() == -180); clippedPolylineCR.GetPointByVal(1, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.GetX() == -90); clippedPolylineCR.GetPointByVal(2, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.GetX() == 0); clippedPolylineCR.GetPointByVal(3, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.GetX() == 100); clippedPolylineCR.GetPointByVal(4, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.GetX() == 170); clippedPolylineCR.GetPointByVal(5, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.GetX() == 180); }
public static com.epl.geometry.Polyline MakePolylineCutter2() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(-1.5, 0); poly.LineTo(-.75, 0); poly.StartPath(-.5, 0); poly.LineTo(1, 0); poly.LineTo(1, 2); poly.LineTo(3, -2); poly.LineTo(4, 2); poly.LineTo(5, -2); poly.LineTo(5, 4); poly.LineTo(8, 2); poly.LineTo(6, 0); poly.LineTo(6, 3); poly.StartPath(9, 5); poly.LineTo(9, 2); poly.LineTo(10, 2); poly.LineTo(10, 5); poly.LineTo(10.5, 5); poly.LineTo(10.5, 3); poly.StartPath(11, 4); poly.LineTo(11, 5); poly.StartPath(12, 5); poly.LineTo(12, 4); return(poly); }
public static com.epl.geometry.Polyline MakePolylineCutter1() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(1, 0); poly.LineTo(4, 0); poly.StartPath(6, -1); poly.LineTo(6, 1); poly.StartPath(6, 0); poly.LineTo(8, 0); poly.StartPath(9, -1); poly.LineTo(9, 1); poly.StartPath(10, 0); poly.LineTo(12, 0); poly.StartPath(12, 1); poly.LineTo(12, -1); poly.StartPath(12, 0); poly.LineTo(15, 0); poly.StartPath(15, 1); poly.LineTo(15, -1); poly.StartPath(16, 0); poly.LineTo(16, -1); poly.LineTo(17, -1); poly.LineTo(17, 1); poly.LineTo(17, 0); poly.LineTo(18, 0); poly.StartPath(18, 0); poly.LineTo(18, -1); return(poly); }
public override com.epl.geometry.ogc.OGCGeometry Boundary() { com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline(); polyline.Add(polygon, true); // adds reversed path return((com.epl.geometry.ogc.OGCMultiCurve)com.epl.geometry.ogc.OGCGeometry.CreateFromEsriGeometry(polyline, esriSR, true)); }
public static com.epl.geometry.Polyline MakePolygonCutter9() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(5, -1); poly.LineTo(5, 51); return(poly); }
public virtual void TestTouchPointLineCR183227() { // Tests CR 183227 com.epl.geometry.Geometry baseGeom = new com.epl.geometry.Point(-130, 10); com.epl.geometry.Polyline pl = new com.epl.geometry.Polyline(); // pl.startPath(new Point(-130, 10)); pl.StartPath(-130, 10); pl.LineTo(-131, 15); pl.LineTo(-140, 20); com.epl.geometry.SpatialReference sr = com.epl.geometry.SpatialReference.Create(4326); bool isTouched; bool isTouched2; isTouched = com.epl.geometry.GeometryEngine.Touches(baseGeom, pl, sr); isTouched2 = com.epl.geometry.GeometryEngine.Touches(pl, baseGeom, sr); NUnit.Framework.Assert.IsTrue(isTouched && isTouched2); { com.epl.geometry.Geometry baseGeom2 = (com.epl.geometry.Geometry) new com.epl.geometry.Point(-131, 15); bool bIsTouched; bool bIsTouched2; bIsTouched = com.epl.geometry.GeometryEngine.Touches(baseGeom2, pl, sr); bIsTouched2 = com.epl.geometry.GeometryEngine.Touches(pl, baseGeom2, sr); NUnit.Framework.Assert.IsTrue(!bIsTouched && !bIsTouched2); } }
public static void Test2() { com.epl.geometry.OperatorFactoryLocal engine = com.epl.geometry.OperatorFactoryLocal.GetInstance(); com.epl.geometry.OperatorGeneralize op = (com.epl.geometry.OperatorGeneralize)engine.GetOperator(com.epl.geometry.Operator.Type.Generalize); com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline(); polyline.StartPath(0, 0); polyline.LineTo(1, 1); polyline.LineTo(2, 0); polyline.LineTo(3, 2); polyline.LineTo(4, 1); polyline.LineTo(5, 0); polyline.LineTo(5, 10); polyline.LineTo(0, 10); com.epl.geometry.Geometry geom = op.Execute(polyline, 2, true, null); com.epl.geometry.Polyline p = (com.epl.geometry.Polyline)geom; com.epl.geometry.Point2D[] points = p.GetCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 4); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 5 && points[1].y == 0); NUnit.Framework.Assert.IsTrue(points[2].x == 5 && points[2].y == 10); NUnit.Framework.Assert.IsTrue(points[3].x == 0 && points[3].y == 10); com.epl.geometry.Geometry geom1 = op.Execute(geom, 5, false, null); p = (com.epl.geometry.Polyline)geom1; points = p.GetCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 2); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 0 && points[1].y == 10); geom1 = op.Execute(geom, 5, true, null); p = (com.epl.geometry.Polyline)geom1; points = p.GetCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 2); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 0 && points[1].y == 10); }
public static com.epl.geometry.Polyline MakePolyline() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); // 0 poly.StartPath(0, 40); poly.LineTo(30, 0); // 1 poly.StartPath(20, 70); poly.LineTo(45, 100); // 2 poly.StartPath(50, 100); poly.LineTo(50, 60); // 3 poly.StartPath(35, 25); poly.LineTo(65, 45); // 4 poly.StartPath(60, 10); poly.LineTo(65, 35); // 5 poly.StartPath(60, 60); poly.LineTo(100, 60); // 6 poly.StartPath(80, 10); poly.LineTo(80, 99); // 7 poly.StartPath(60, 60); poly.LineTo(65, 35); return(poly); }
public virtual void TestTouchesOnPolylineAndPolygon() { com.epl.geometry.SpatialReference sr = com.epl.geometry.SpatialReference.Create(4326); com.epl.geometry.Polygon basePl = new com.epl.geometry.Polygon(); basePl.StartPath(new com.epl.geometry.Point(-117, 20)); basePl.LineTo(new com.epl.geometry.Point(-100, 20)); basePl.LineTo(new com.epl.geometry.Point(-100, 10)); basePl.LineTo(new com.epl.geometry.Point(-117, 10)); com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline(); compPl.StartPath(new com.epl.geometry.Point(-117, 20)); compPl.LineTo(new com.epl.geometry.Point(-108, 25)); compPl.LineTo(new com.epl.geometry.Point(-100, 20)); compPl.LineTo(new com.epl.geometry.Point(-100, 30)); bool isTouched; try { isTouched = com.epl.geometry.GeometryEngine.Touches(basePl, compPl, sr); } catch (System.ArgumentException) { isTouched = false; } NUnit.Framework.Assert.AreEqual(isTouched, true); }
public static com.epl.geometry.Polyline MakePolyline1() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(0, 0); poly.LineTo(15, 15); return(poly); }
public static void Test4() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(0, System.Math.Sqrt(0.0)); poly.LineTo(0, System.Math.Sqrt(1.0)); poly.StartPath(0, System.Math.Sqrt(1.0)); poly.LineTo(0, System.Math.Sqrt(2.0)); poly.StartPath(0, System.Math.Sqrt(2.0)); poly.LineTo(0, System.Math.Sqrt(3.0)); poly.StartPath(0, System.Math.Sqrt(3.0)); poly.LineTo(0, System.Math.Sqrt(4.0)); poly.StartPath(0, System.Math.Sqrt(4.0)); poly.LineTo(0, System.Math.Sqrt(5.0)); poly.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, System.Math.Sqrt(1.0)); poly.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 8, 0, System.Math.Sqrt(4.0)); poly.InterpolateAttributes(com.epl.geometry.VertexDescription.Semantics.M, 0, 1, 4, 0); NUnit.Framework.Assert.IsTrue(com.epl.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 0, 0))); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0) == System.Math.Sqrt(1.0)); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 2, 0) == System.Math.Sqrt(1.0)); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 3, 0) == System.Math.Sqrt(2.0)); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 4, 0) == System.Math.Sqrt(2.0)); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 5, 0) == System.Math.Sqrt(3.0)); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 6, 0) == System.Math.Sqrt(3.0)); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 7, 0) == System.Math.Sqrt(4.0)); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 8, 0) == System.Math.Sqrt(4.0)); NUnit.Framework.Assert.IsTrue(com.epl.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 9, 0))); }
public virtual void TestIntersectBetweenPolylineAndPolygon() { com.epl.geometry.Polyline basePl = new com.epl.geometry.Polyline(); basePl.StartPath(new com.epl.geometry.Point(-117, 20)); basePl.LineTo(new com.epl.geometry.Point(-117, 10)); basePl.LineTo(new com.epl.geometry.Point(-130, 10)); basePl.LineTo(new com.epl.geometry.Point(-130, 20)); basePl.LineTo(new com.epl.geometry.Point(-117, 20)); com.epl.geometry.Polygon compPl = new com.epl.geometry.Polygon(); compPl.StartPath(-116, 20); compPl.LineTo(-131, 10); compPl.LineTo(-121, 50); com.epl.geometry.Geometry intersectGeom = null; int noException = 1; // no exception try { intersectGeom = com.epl.geometry.GeometryEngine.Intersect(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326)); } catch (System.Exception) { noException = 0; } NUnit.Framework.Assert.IsNotNull(intersectGeom); }
public static void TestEngine(com.epl.geometry.SpatialReference spatialReference) { com.epl.geometry.Polygon polygon8 = MakePolygon8(); com.epl.geometry.Polyline cutter8 = MakePolygonCutter8(); com.epl.geometry.Geometry[] cuts = com.epl.geometry.GeometryEngine.Cut(polygon8, cutter8, spatialReference); com.epl.geometry.Polygon cut; int pathCount; int pointCount; double area; cut = (com.epl.geometry.Polygon)cuts[0]; pathCount = cut.GetPathCount(); pointCount = cut.GetPointCount(); area = cut.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(pointCount == 4); NUnit.Framework.Assert.IsTrue(area == 100); cut = (com.epl.geometry.Polygon)cuts[1]; pathCount = cut.GetPathCount(); pointCount = cut.GetPointCount(); area = cut.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(pathCount == 2); NUnit.Framework.Assert.IsTrue(pointCount == 8); NUnit.Framework.Assert.IsTrue(area == 800); }
public static void TestPolygon9(com.epl.geometry.SpatialReference spatialReference) { com.epl.geometry.OperatorFactoryLocal engine = com.epl.geometry.OperatorFactoryLocal.GetInstance(); com.epl.geometry.OperatorCut opCut = (com.epl.geometry.OperatorCut)engine.GetOperator(com.epl.geometry.Operator.Type.Cut); com.epl.geometry.Polygon cut; int path_count; int point_count; double area; com.epl.geometry.Polygon polygon9 = MakePolygon9(); com.epl.geometry.Polyline cutter9 = MakePolygonCutter9(); com.epl.geometry.GeometryCursor cursor = opCut.Execute(false, polygon9, cutter9, spatialReference, null); cut = (com.epl.geometry.Polygon)cursor.Next(); path_count = cut.GetPathCount(); point_count = cut.GetPointCount(); area = cut.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(path_count == 3); NUnit.Framework.Assert.IsTrue(point_count == 12); NUnit.Framework.Assert.IsTrue(area == 150); cut = (com.epl.geometry.Polygon)cursor.Next(); path_count = cut.GetPathCount(); point_count = cut.GetPointCount(); area = cut.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(path_count == 3); NUnit.Framework.Assert.IsTrue(point_count == 12); NUnit.Framework.Assert.IsTrue(area == 150); cut = (com.epl.geometry.Polygon)cursor.Next(); NUnit.Framework.Assert.IsTrue(cut == null); }
public virtual void TestEmptyPolyline() { com.epl.geometry.Polyline p = new com.epl.geometry.Polyline(); com.epl.geometry.OperatorExportToGeoJson exporter = (com.epl.geometry.OperatorExportToGeoJson)factory.GetOperator(com.epl.geometry.Operator.Type.ExportToGeoJson); string result = exporter.Execute(p); NUnit.Framework.Assert.AreEqual("{\"type\":\"LineString\",\"coordinates\":[]}", result); }
internal static com.epl.geometry.Polyline MakePolyline() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(0, 0); poly.LineTo(10, 10); poly.LineTo(20, 0); return(poly); }
internal static com.epl.geometry.Geometry Calculate(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker) { int gt = geom.GetType().Value(); if (gt == com.epl.geometry.Geometry.GeometryType.Polygon) { com.epl.geometry.Polyline dst = new com.epl.geometry.Polyline(geom.GetDescription()); if (!geom.IsEmpty()) { ((com.epl.geometry.MultiPathImpl)geom._getImpl())._copyToUnsafe((com.epl.geometry.MultiPathImpl)dst._getImpl()); } return(dst); } else { if (gt == com.epl.geometry.Geometry.GeometryType.Polyline) { return(CalculatePolylineBoundary_(geom._getImpl(), progress_tracker, false, null)); } else { if (gt == com.epl.geometry.Geometry.GeometryType.Envelope) { com.epl.geometry.Polyline dst = new com.epl.geometry.Polyline(geom.GetDescription()); if (!geom.IsEmpty()) { dst.AddEnvelope((com.epl.geometry.Envelope)geom, false); } return(dst); } else { if (com.epl.geometry.Geometry.IsSegment(gt)) { com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint(geom.GetDescription()); if (!geom.IsEmpty() && !((com.epl.geometry.Segment)geom).IsClosed()) { com.epl.geometry.Point pt = new com.epl.geometry.Point(); ((com.epl.geometry.Segment)geom).QueryStart(pt); mp.Add(pt); ((com.epl.geometry.Segment)geom).QueryEnd(pt); mp.Add(pt); } return(mp); } else { if (com.epl.geometry.Geometry.IsPoint(gt)) { // returns empty point for points and multipoints. return(null); } } } } } throw new System.ArgumentException(); }
public OGCLineString(com.epl.geometry.MultiPath mp, int pathIndex, com.epl.geometry.SpatialReference sr, bool reversed) { multiPath = new com.epl.geometry.Polyline(); if (!mp.IsEmpty()) { multiPath.AddPath(mp, pathIndex, !reversed); } esriSR = sr; }
public static void TestConsiderTouch2(com.epl.geometry.SpatialReference spatialReference) { com.epl.geometry.OperatorFactoryLocal engine = com.epl.geometry.OperatorFactoryLocal.GetInstance(); com.epl.geometry.OperatorCut opCut = (com.epl.geometry.OperatorCut)engine.GetOperator(com.epl.geometry.Operator.Type.Cut); com.epl.geometry.Polyline polyline2 = MakePolyline2(); com.epl.geometry.Polyline cutter2 = MakePolylineCutter2(); com.epl.geometry.GeometryCursor cursor = opCut.Execute(true, polyline2, cutter2, spatialReference, null); com.epl.geometry.Polyline cut; int pathCount; int segmentCount; double length; cut = (com.epl.geometry.Polyline)cursor.Next(); pathCount = cut.GetPathCount(); segmentCount = cut.GetSegmentCount(); length = cut.CalculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 4); NUnit.Framework.Assert.IsTrue(segmentCount == 4); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 5.74264068) <= 0.001); cut = (com.epl.geometry.Polyline)cursor.Next(); pathCount = cut.GetPathCount(); segmentCount = cut.GetSegmentCount(); length = cut.CalculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 6); NUnit.Framework.Assert.IsTrue(segmentCount == 8); NUnit.Framework.Assert.IsTrue(length == 6.75); cut = (com.epl.geometry.Polyline)cursor.Next(); pathCount = cut.GetPathCount(); segmentCount = cut.GetSegmentCount(); length = cut.CalculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 0.5) <= 0.001); cut = (com.epl.geometry.Polyline)cursor.Next(); pathCount = cut.GetPathCount(); segmentCount = cut.GetSegmentCount(); length = cut.CalculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 0.25) <= 0.001); cut = (com.epl.geometry.Polyline)cursor.Next(); pathCount = cut.GetPathCount(); segmentCount = cut.GetSegmentCount(); length = cut.CalculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 1) <= 0.001); cut = (com.epl.geometry.Polyline)cursor.Next(); pathCount = cut.GetPathCount(); segmentCount = cut.GetSegmentCount(); length = cut.CalculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 1.41421356) <= 0.001); cut = (com.epl.geometry.Polyline)cursor.Next(); NUnit.Framework.Assert.IsTrue(cut == null); }
public virtual void TestSerializePolyline() { try { java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream(); java.io.ObjectOutputStream oo = new java.io.ObjectOutputStream(streamOut); com.epl.geometry.Polyline pt = new com.epl.geometry.Polyline(); pt.StartPath(10, 10); pt.LineTo(100, 100); pt.LineTo(200, 100); oo.WriteObject(pt); System.IO.BinaryWriter streamIn = new System.IO.BinaryWriter(streamOut.ToByteArray()); java.io.ObjectInputStream ii = new java.io.ObjectInputStream(streamIn); com.epl.geometry.Polyline ptRes = (com.epl.geometry.Polyline)ii.ReadObject(); NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt)); } catch (System.Exception) { Fail("Polyline serialization failure"); } //try //{ //FileOutputStream streamOut = new FileOutputStream("c:/temp/savedPolyline1.txt"); //ObjectOutputStream oo = new ObjectOutputStream(streamOut); //Polyline pt = new Polyline(); //pt.startPath(10, 10); //pt.lineTo(100, 100); //pt.lineTo(200, 100); //oo.writeObject(pt); //} //catch(Exception ex) //{ //fail("Polyline serialization failure"); //} try { java.io.InputStream s = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedPolyline.txt"); java.io.ObjectInputStream ii = new java.io.ObjectInputStream(s); com.epl.geometry.Polyline ptRes = (com.epl.geometry.Polyline)ii.ReadObject(); NUnit.Framework.Assert.IsTrue(ptRes != null); } catch (System.Exception) { Fail("Polyline serialization failure"); } try { java.io.InputStream s = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedPolyline1.txt"); java.io.ObjectInputStream ii = new java.io.ObjectInputStream(s); com.epl.geometry.Polyline ptRes = (com.epl.geometry.Polyline)ii.ReadObject(); NUnit.Framework.Assert.IsTrue(ptRes != null); } catch (System.Exception) { Fail("Polyline serialization failure"); } }
internal static void TestPointsOnPolyline2D_(com.epl.geometry.Polyline poly, com.epl.geometry.Point2D[] input_points, int count, double tolerance, com.epl.geometry.PolygonUtils.PiPResult[] test_results) { com.epl.geometry.MultiPathImpl mp_impl = (com.epl.geometry.MultiPathImpl)poly._getImpl(); com.epl.geometry.GeometryAccelerators accel = mp_impl._getAccelerators(); com.epl.geometry.RasterizedGeometry2D rgeom = null; if (accel != null) { rgeom = accel.GetRasterizedGeometry(); } int pointsLeft = count; for (int i = 0; i < count; i++) { test_results[i] = com.epl.geometry.PolygonUtils.PiPResult.PiPInside; // set to impossible value if (rgeom != null) { com.epl.geometry.Point2D input_point = input_points[i]; com.epl.geometry.RasterizedGeometry2D.HitType hit = rgeom.QueryPointInGeometry(input_point.x, input_point.y); if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Outside) { test_results[i] = com.epl.geometry.PolygonUtils.PiPResult.PiPOutside; pointsLeft--; } } } if (pointsLeft != 0) { com.epl.geometry.SegmentIteratorImpl iter = mp_impl.QuerySegmentIterator(); while (iter.NextPath() && pointsLeft != 0) { while (iter.HasNextSegment() && pointsLeft != 0) { com.epl.geometry.Segment segment = iter.NextSegment(); for (int i_1 = 0; i_1 < count && pointsLeft != 0; i_1++) { if (test_results[i_1] == com.epl.geometry.PolygonUtils.PiPResult.PiPInside) { if (segment.IsIntersecting(input_points[i_1], tolerance)) { test_results[i_1] = com.epl.geometry.PolygonUtils.PiPResult.PiPBoundary; pointsLeft--; } } } } } } for (int i_2 = 0; i_2 < count; i_2++) { if (test_results[i_2] == com.epl.geometry.PolygonUtils.PiPResult.PiPInside) { test_results[i_2] = com.epl.geometry.PolygonUtils.PiPResult.PiPOutside; } } }
private static int QuickTest2DPolylinePoint(com.epl.geometry.Polyline geomA, com.epl.geometry.Point2D ptB, double tolerance, int testType) { int mask = com.epl.geometry.OperatorInternalRelationUtils.Relation.Touches | com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains | com.epl.geometry.OperatorInternalRelationUtils.Relation.Within | com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint | com.epl.geometry.OperatorInternalRelationUtils.Relation .Intersects; if ((testType & mask) == 0) { return(com.epl.geometry.OperatorInternalRelationUtils.Relation.NoThisRelation); } int res = QuickTest2DMVPointRasterOnly(geomA, ptB, tolerance); if (res > 0) { return(res); } // Go through the segments: double toleranceSqr = tolerance * tolerance; com.epl.geometry.MultiPathImpl mpImpl = (com.epl.geometry.MultiPathImpl)geomA._getImpl(); com.epl.geometry.SegmentIteratorImpl iter = mpImpl.QuerySegmentIterator(); while (iter.NextPath()) { int pathIndex = iter.GetPathIndex(); if (!geomA.IsClosedPath(pathIndex)) { int pathSize = geomA.GetPathSize(pathIndex); int pathStart = geomA.GetPathStart(pathIndex); if (pathSize == 0) { continue; } if (com.epl.geometry.Point2D.SqrDistance(geomA.GetXY(pathStart), ptB) <= toleranceSqr || (pathSize > 1 && com.epl.geometry.Point2D.SqrDistance(geomA.GetXY(pathStart + pathSize - 1), ptB) <= toleranceSqr)) { return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Touches); } } if (testType != com.epl.geometry.OperatorInternalRelationUtils.Relation.Touches) { while (iter.HasNextSegment()) { com.epl.geometry.Segment segment = iter.NextSegment(); double t = segment.GetClosestCoordinate(ptB, false); com.epl.geometry.Point2D pt = segment.GetCoord2D(t); if (com.epl.geometry.Point2D.SqrDistance(pt, ptB) <= toleranceSqr) { if ((testType & com.epl.geometry.OperatorInternalRelationUtils.Relation.IntersectsOrDisjoint) != 0) { return(com.epl.geometry.OperatorInternalRelationUtils.Relation.Intersects); } return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains); } } } } return((testType & com.epl.geometry.OperatorInternalRelationUtils.Relation.IntersectsOrDisjoint) != 0 ? com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint : com.epl.geometry.OperatorInternalRelationUtils.Relation.NoThisRelation); }
public static void TestCR254240() { com.epl.geometry.OperatorProximity2D proximityOp = com.epl.geometry.OperatorProximity2D.Local(); com.epl.geometry.Point inputPoint = new com.epl.geometry.Point(-12, 12); com.epl.geometry.Polyline line = new com.epl.geometry.Polyline(); line.StartPath(-10, 0); line.LineTo(0, 0); com.epl.geometry.Proximity2DResult result = proximityOp.GetNearestCoordinate(line, inputPoint, false, true); NUnit.Framework.Assert.IsTrue(result.IsRightSide() == false); }
public static com.epl.geometry.Polyline MakePolygonCutter8() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 20); poly.LineTo(20, 20); poly.LineTo(20, 10); poly.LineTo(10, 10); return(poly); }
public static com.epl.geometry.Polyline MakePolygonCutter5() { com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(15, 0); poly.LineTo(0, 15); poly.LineTo(15, 30); poly.LineTo(30, 15); poly.LineTo(15, 0); return(poly); }
private static int QuickTest2DPolylinePolyline(com.epl.geometry.Polyline geomA, com.epl.geometry.Polyline geomB, double tolerance) { int res = QuickTest2DMVMVRasterOnly(geomA, geomB, tolerance); if (res > 0) { return(res); } // TODO: implement me return(0); }
public virtual void TestPolylineWithTwoPaths() { com.epl.geometry.Polyline p = new com.epl.geometry.Polyline(); p.StartPath(100.0, 0.0); p.LineTo(100.0, 1.0); p.StartPath(100.2, 0.2); p.LineTo(100.8, 0.2); string result = com.epl.geometry.GeometryEngine.GeometryToGeoJson(p); NUnit.Framework.Assert.AreEqual("{\"type\":\"MultiLineString\",\"coordinates\":[[[100,0],[100,1]],[[100.2,0.2],[100.8,0.2]]]}", result); }