public static void TestImportExportShapePolyline() { com.esri.core.geometry.OperatorExportToESRIShape exporterShape = (com.esri.core.geometry.OperatorExportToESRIShape)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ExportToESRIShape); com.esri.core.geometry.OperatorImportFromESRIShape importerShape = (com.esri.core.geometry.OperatorImportFromESRIShape)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ImportFromESRIShape); com.esri.core.geometry.Polyline polyline = MakePolyline(); // Test Import Polyline from Polyline System.IO.MemoryStream polylineShapeBuffer = exporterShape.Execute(0, polyline); com.esri.core.geometry.Geometry polylineShapeGeometry = importerShape.Execute(0, com.esri.core.geometry.Geometry.Type.Polyline, polylineShapeBuffer); // TODO test this //com.esri.core.geometry.TestCommonMethods.CompareGeometryContent((com.esri.core.geometry.MultiPath)polylineShapeGeometry, polyline); // Test Import Envelope from Polyline; com.esri.core.geometry.Geometry envelopeShapeGeometry = importerShape.Execute(0, com.esri.core.geometry.Geometry.Type.Envelope, polylineShapeBuffer); com.esri.core.geometry.Envelope envelope = (com.esri.core.geometry.Envelope)envelopeShapeGeometry; com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(); com.esri.core.geometry.Envelope otherenv = new com.esri.core.geometry.Envelope(); envelope.QueryEnvelope(env); polyline.QueryEnvelope(otherenv); NUnit.Framework.Assert.IsTrue(env.GetXMin() == otherenv.GetXMin()); NUnit.Framework.Assert.IsTrue(env.GetXMax() == otherenv.GetXMax()); NUnit.Framework.Assert.IsTrue(env.GetYMin() == otherenv.GetYMin()); NUnit.Framework.Assert.IsTrue(env.GetYMax() == otherenv.GetYMax()); com.esri.core.geometry.Envelope1D interval; com.esri.core.geometry.Envelope1D otherinterval; interval = envelope.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0); otherinterval = polyline.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0); NUnit.Framework.Assert.IsTrue(interval.vmin == otherinterval.vmin); NUnit.Framework.Assert.IsTrue(interval.vmax == otherinterval.vmax); }
public static void TestImportExportShapeMultiPoint() { com.esri.core.geometry.OperatorExportToESRIShape exporterShape = (com.esri.core.geometry.OperatorExportToESRIShape)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ExportToESRIShape); com.esri.core.geometry.OperatorImportFromESRIShape importerShape = (com.esri.core.geometry.OperatorImportFromESRIShape)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ImportFromESRIShape); com.esri.core.geometry.MultiPoint multipoint = MakeMultiPoint(); // Test Import MultiPoint from MultiPoint System.IO.MemoryStream multipointShapeBuffer = exporterShape.Execute(0, multipoint); com.esri.core.geometry.MultiPoint multipointShapeGeometry = (com.esri.core.geometry.MultiPoint)importerShape.Execute(0, com.esri.core.geometry.Geometry.Type.MultiPoint, multipointShapeBuffer); //com.esri.core.geometry.TestCommonMethods.CompareGeometryContent((com.esri.core.geometry.MultiPoint)multipointShapeGeometry, multipoint); // Test Import Envelope from MultiPoint com.esri.core.geometry.Geometry envelopeShapeGeometry = importerShape.Execute(0, com.esri.core.geometry.Geometry.Type.Envelope, multipointShapeBuffer); com.esri.core.geometry.Envelope envelope = (com.esri.core.geometry.Envelope)envelopeShapeGeometry; com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(); com.esri.core.geometry.Envelope otherenv = new com.esri.core.geometry.Envelope(); envelope.QueryEnvelope(env); multipoint.QueryEnvelope(otherenv); NUnit.Framework.Assert.IsTrue(env.GetXMin() == otherenv.GetXMin()); NUnit.Framework.Assert.IsTrue(env.GetXMax() == otherenv.GetXMax()); NUnit.Framework.Assert.IsTrue(env.GetYMin() == otherenv.GetYMin()); NUnit.Framework.Assert.IsTrue(env.GetYMax() == otherenv.GetYMax()); com.esri.core.geometry.Envelope1D interval; com.esri.core.geometry.Envelope1D otherinterval; interval = envelope.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0); otherinterval = multipoint.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0); NUnit.Framework.Assert.IsTrue(interval.vmin == otherinterval.vmin); NUnit.Framework.Assert.IsTrue(interval.vmax == otherinterval.vmax); interval = envelope.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.ID, 0); otherinterval = multipoint.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.ID, 0); NUnit.Framework.Assert.IsTrue(interval.vmin == otherinterval.vmin); NUnit.Framework.Assert.IsTrue(interval.vmax == otherinterval.vmax); }
public static void TestImportExportShapePoint() { com.esri.core.geometry.OperatorExportToESRIShape exporterShape = (com.esri.core.geometry.OperatorExportToESRIShape)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ExportToESRIShape); com.esri.core.geometry.OperatorImportFromESRIShape importerShape = (com.esri.core.geometry.OperatorImportFromESRIShape)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ImportFromESRIShape); // Point com.esri.core.geometry.Point point = MakePoint(); // Test Import Point from Point System.IO.MemoryStream pointShapeBuffer = exporterShape.Execute(0, point); com.esri.core.geometry.Point pointShapeGeometry = (com.esri.core.geometry.Point)importerShape.Execute(0, com.esri.core.geometry.Geometry.Type.Point, pointShapeBuffer); double x1 = point.GetX(); double x2 = pointShapeGeometry.GetX(); NUnit.Framework.Assert.IsTrue(x1 == x2); double y1 = point.GetY(); double y2 = pointShapeGeometry.GetY(); NUnit.Framework.Assert.IsTrue(y1 == y2); double z1 = point.GetZ(); double z2 = pointShapeGeometry.GetZ(); NUnit.Framework.Assert.IsTrue(z1 == z2); double m1 = point.GetM(); double m2 = pointShapeGeometry.GetM(); NUnit.Framework.Assert.IsTrue(m1 == m2); int id1 = point.GetID(); int id2 = pointShapeGeometry.GetID(); NUnit.Framework.Assert.IsTrue(id1 == id2); // Test Import Multipoint from Point com.esri.core.geometry.MultiPoint multipointShapeGeometry = (com.esri.core.geometry.MultiPoint)importerShape.Execute(0, com.esri.core.geometry.Geometry.Type.MultiPoint, pointShapeBuffer); com.esri.core.geometry.Point point2d = multipointShapeGeometry.GetPoint(0); NUnit.Framework.Assert.IsTrue(x1 == point2d.GetX() && y1 == point2d.GetY()); int pointCount = multipointShapeGeometry.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 1); z2 = multipointShapeGeometry.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0); NUnit.Framework.Assert.IsTrue(z1 == z2); m2 = multipointShapeGeometry.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0); NUnit.Framework.Assert.IsTrue(m1 == m2); id2 = multipointShapeGeometry.GetAttributeAsInt(com.esri.core.geometry.VertexDescription.Semantics.ID, 0, 0); NUnit.Framework.Assert.IsTrue(id1 == id2); // Test Import Envelope from Point com.esri.core.geometry.Geometry envelopeShapeGeometry = importerShape.Execute(0, com.esri.core.geometry.Geometry.Type.Envelope, pointShapeBuffer); com.esri.core.geometry.Envelope envelope = (com.esri.core.geometry.Envelope)envelopeShapeGeometry; com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(); com.esri.core.geometry.Envelope otherenv = new com.esri.core.geometry.Envelope(); envelope.QueryEnvelope(env); point.QueryEnvelope(otherenv); NUnit.Framework.Assert.IsTrue(env.GetXMin() == otherenv.GetXMin()); NUnit.Framework.Assert.IsTrue(env.GetXMax() == otherenv.GetXMax()); NUnit.Framework.Assert.IsTrue(env.GetYMin() == otherenv.GetYMin()); NUnit.Framework.Assert.IsTrue(env.GetYMax() == otherenv.GetYMax()); com.esri.core.geometry.Envelope1D interval; com.esri.core.geometry.Envelope1D otherinterval; interval = envelope.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0); otherinterval = point.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0); NUnit.Framework.Assert.IsTrue(interval.vmin == otherinterval.vmin); NUnit.Framework.Assert.IsTrue(interval.vmax == otherinterval.vmax); interval = envelope.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.ID, 0); otherinterval = point.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.ID, 0); NUnit.Framework.Assert.IsTrue(interval.vmin == otherinterval.vmin); NUnit.Framework.Assert.IsTrue(interval.vmax == otherinterval.vmax); }
public static void TestImportExportShapeEnvelope() { com.esri.core.geometry.OperatorExportToESRIShape exporterShape = (com.esri.core.geometry.OperatorExportToESRIShape)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ExportToESRIShape); com.esri.core.geometry.OperatorImportFromESRIShape importerShape = (com.esri.core.geometry.OperatorImportFromESRIShape)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ImportFromESRIShape); // Test Export Envelope to Polygon com.esri.core.geometry.Envelope envelope = MakeEnvelope(); System.IO.MemoryStream polygonShapeBuffer = exporterShape.Execute(0, envelope); com.esri.core.geometry.Polygon polygon = (com.esri.core.geometry.Polygon)importerShape.Execute(0, com.esri.core.geometry.Geometry.Type.Polygon, polygonShapeBuffer); int pointCount = polygon.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 4); com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(); envelope.QueryEnvelope(env); // interval = envelope.queryInterval(VertexDescription.Semantics.Z, 0); com.esri.core.geometry.Point point3d; point3d = polygon.GetPoint(0); NUnit.Framework.Assert.IsTrue(point3d.GetX() == env.GetXMin() && point3d.GetY() == env.GetYMin()); // && point3d.z == // interval.vmin); point3d = polygon.GetPoint(1); NUnit.Framework.Assert.IsTrue(point3d.GetX() == env.GetXMin() && point3d.GetY() == env.GetYMax()); // && point3d.z == // interval.vmax); point3d = polygon.GetPoint(2); NUnit.Framework.Assert.IsTrue(point3d.GetX() == env.GetXMax() && point3d.GetY() == env.GetYMax()); // && point3d.z == // interval.vmin); point3d = polygon.GetPoint(3); NUnit.Framework.Assert.IsTrue(point3d.GetX() == env.GetXMax() && point3d.GetY() == env.GetYMin()); // && point3d.z == // interval.vmax); com.esri.core.geometry.Envelope1D interval; interval = envelope.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.M, 0); double m = polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0); NUnit.Framework.Assert.IsTrue(m == interval.vmin); m = polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0); NUnit.Framework.Assert.IsTrue(m == interval.vmax); m = polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0); NUnit.Framework.Assert.IsTrue(m == interval.vmin); m = polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0); NUnit.Framework.Assert.IsTrue(m == interval.vmax); interval = envelope.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.ID, 0); double id = polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.ID, 0, 0); NUnit.Framework.Assert.IsTrue(id == interval.vmin); id = polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.ID, 1, 0); NUnit.Framework.Assert.IsTrue(id == interval.vmax); id = polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.ID, 2, 0); NUnit.Framework.Assert.IsTrue(id == interval.vmin); id = polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.ID, 3, 0); NUnit.Framework.Assert.IsTrue(id == interval.vmax); }
public static void TestClipIssue258243() { com.esri.core.geometry.Polygon poly1 = new com.esri.core.geometry.Polygon(); poly1.StartPath(21.476191371901479, 41.267022001907215); poly1.LineTo(59.669186665158051, 36.62700518555863); poly1.LineTo(20.498578117352313, 30.363180148246094); poly1.LineTo(18.342565836615044, 46.303295352085627); poly1.LineTo(17.869569458621626, 23.886816966894159); poly1.LineTo(19.835465558090434, 20); poly1.LineTo(18.83911285048551, 43.515995498114791); poly1.LineTo(20.864485260298004, 20.235921201027757); poly1.LineTo(18.976127544787012, 20); poly1.LineTo(34.290201277718218, 61.801369014954794); poly1.LineTo(20.734727419368866, 20); poly1.LineTo(18.545865698148113, 20); poly1.LineTo(19.730260558565515, 20); poly1.LineTo(19.924806216827005, 23.780315893949187); poly1.LineTo(21.675168105421452, 36.699924873001258); poly1.LineTo(22.500527828912158, 43.703424859922983); poly1.LineTo(42.009527116514818, 36.995486982256089); poly1.LineTo(24.469729873835782, 58.365871758247039); poly1.LineTo(24.573736036545878, 36.268390409195824); poly1.LineTo(22.726502169802746, 20); poly1.LineTo(23.925834885228145, 20); poly1.LineTo(25.495346880936729, 20); poly1.LineTo(23.320941499288317, 20); poly1.LineTo(24.05655665646276, 28.659578774758632); poly1.LineTo(23.205940789341135, 38.491506888710504); poly1.LineTo(21.472847203385509, 53.057228182018044); poly1.LineTo(25.04257681654104, 20); poly1.LineTo(25.880572351149542, 25.16102863979474); poly1.LineTo(26.756283333879658, 20); poly1.LineTo(21.476191371901479, 41.267022001907215); com.esri.core.geometry.Envelope2D env = new com.esri.core.geometry.Envelope2D(); env.SetCoords(24.269517325186033, 19.999998900000001, 57.305574253225409, 61.801370114954793); try { com.esri.core.geometry.Geometry output_geom = com.esri.core.geometry.OperatorClip.Local().Execute(poly1, env, com.esri.core.geometry.SpatialReference.Create(4326), null); com.esri.core.geometry.Envelope envPoly = new com.esri.core.geometry.Envelope(); poly1.QueryEnvelope(envPoly); com.esri.core.geometry.Envelope e = new com.esri.core.geometry.Envelope(env); e.Intersect(envPoly); com.esri.core.geometry.Envelope clippedEnv = new com.esri.core.geometry.Envelope(); output_geom.QueryEnvelope(clippedEnv); NUnit.Framework.Assert.IsTrue(System.Math.Abs(clippedEnv.GetXMin() - e.GetXMin()) < 1e-10 && System.Math.Abs(clippedEnv.GetYMin() - e.GetYMin()) < 1e-10 && System.Math.Abs(clippedEnv.GetXMax() - e.GetXMax()) < 1e-10 && System.Math.Abs(clippedEnv.GetYMax() - e.GetYMax()) < 1e-10); } catch (System.Exception) { NUnit.Framework.Assert.IsTrue(false); } }