public override void CopyTo(com.epl.geometry.Geometry dst) { if (dst.GetType() != GetType()) { throw new System.ArgumentException(); } com.epl.geometry.Segment segDst = (com.epl.geometry.Segment)dst; segDst.m_description = m_description; segDst._resizeAttributes(m_description.GetTotalComponentCount() - 2); _attributeCopy(m_attributes, 0, segDst.m_attributes, 0, (m_description.GetTotalComponentCount() - 2) * 2); segDst.m_xStart = m_xStart; segDst.m_yStart = m_yStart; segDst.m_xEnd = m_xEnd; segDst.m_yEnd = m_yEnd; dst._touch(); _copyToImpl(segDst); }
public override void CopyTo(com.epl.geometry.Geometry dst) { if (dst.GetType() != GetType()) { throw new System.ArgumentException(); } com.epl.geometry.Envelope envDst = (com.epl.geometry.Envelope)dst; dst._touch(); envDst.m_description = m_description; envDst.m_envelope.SetCoords(m_envelope); envDst.m_attributes = null; if (m_attributes != null) { envDst._ensureAttributes(); System.Array.Copy(m_attributes, 0, envDst.m_attributes, 0, (m_description.GetTotalComponentCount() - 2) * 2); } }
/// <exception cref="java.io.ObjectStreamException"/> public void SetGeometryByValue(com.epl.geometry.Geometry geometry) { try { if (com.epl.geometry.Geometry.IsMultiPath(geometry.GetType().Value())) { geometryData = new com.epl.geometry.GeometrySerializer.MultiPathData(); } else { if (com.epl.geometry.Geometry.IsMultiVertex(geometry.GetType().Value())) { geometryData = new com.epl.geometry.GeometrySerializer.MultiVertexData(); } else { geometryData = new com.epl.geometry.GeometrySerializer.BaseGeometryData(); } } geometryData.esriShape = com.epl.geometry.GeometryEngine.GeometryToEsriShape(geometry); geometryData.geometryType = geometry.GetType(); if (com.epl.geometry.Geometry.IsMultiVertex(geometryData.geometryType.Value())) { com.epl.geometry.GeometrySerializer.MultiVertexData mvd = (com.epl.geometry.GeometrySerializer.MultiVertexData)geometryData; com.epl.geometry.MultiVertexGeometryImpl mvImpl = (com.epl.geometry.MultiVertexGeometryImpl)geometry._getImpl(); mvd.tolerance = mvImpl.m_simpleTolerance; mvd.simpleFlag = mvImpl.GetIsSimple(0); if (!geometry.IsEmpty() && com.epl.geometry.Geometry.IsMultiPath(geometryData.geometryType.Value())) { com.epl.geometry.GeometrySerializer.MultiPathData mpd = (com.epl.geometry.GeometrySerializer.MultiPathData)geometryData; com.epl.geometry.MultiPathImpl mpImpl = (com.epl.geometry.MultiPathImpl)geometry._getImpl(); mpd.ogcFlags = new bool[mpImpl.GetPathCount()]; com.epl.geometry.AttributeStreamOfInt8 pathFlags = mpImpl.GetPathFlagsStreamRef(); for (int i = 0, n = mpImpl.GetPathCount(); i < n; i++) { mpd.ogcFlags[i] = (pathFlags.Read(i) & unchecked ((byte)com.epl.geometry.PathFlags.enumOGCStartPolygon)) != 0; } } } } catch (System.Exception) { throw new System.IO.InvalidDataException("Cannot serialize this geometry"); } }
internal static int ExportToESRIShape(int exportFlags, com.epl.geometry.Geometry geometry, System.IO.BinaryWriter shapeBuffer) { if (geometry == null) { if (shapeBuffer != null) { shapeBuffer.Write(com.epl.geometry.ShapeType.ShapeNull); } return(4); } int type = geometry.GetType().Value(); switch (type) { case com.epl.geometry.Geometry.GeometryType.Polygon: { return(ExportMultiPathToESRIShape(true, exportFlags, (com.epl.geometry.MultiPath)geometry, shapeBuffer)); } case com.epl.geometry.Geometry.GeometryType.Polyline: { return(ExportMultiPathToESRIShape(false, exportFlags, (com.epl.geometry.MultiPath)geometry, shapeBuffer)); } case com.epl.geometry.Geometry.GeometryType.MultiPoint: { return(ExportMultiPointToESRIShape(exportFlags, (com.epl.geometry.MultiPoint)geometry, shapeBuffer)); } case com.epl.geometry.Geometry.GeometryType.Point: { return(ExportPointToESRIShape(exportFlags, (com.epl.geometry.Point)geometry, shapeBuffer)); } case com.epl.geometry.Geometry.GeometryType.Envelope: { return(ExportEnvelopeToESRIShape(exportFlags, (com.epl.geometry.Envelope)geometry, shapeBuffer)); } default: { throw com.epl.geometry.GeometryException.GeometryInternalError(); } } }
/// <summary>Calculates the convex hull.</summary> /// <remarks> /// Calculates the convex hull. /// See OperatorConvexHull /// </remarks> /// <param name="geometries">The input geometry array.</param> /// <param name="b_merge"> /// Put true if you want the convex hull of all the geometries in /// the array combined. Put false if you want the convex hull of /// each geometry in the array individually. /// </param> /// <returns> /// Returns an array of convex hulls. If b_merge is true, the result /// will be a one element array consisting of the merged convex hull. /// </returns> public static com.epl.geometry.Geometry[] ConvexHull(com.epl.geometry.Geometry[] geometries, bool b_merge) { com.epl.geometry.OperatorConvexHull op = (com.epl.geometry.OperatorConvexHull)factory.GetOperator(com.epl.geometry.Operator.Type.ConvexHull); com.epl.geometry.SimpleGeometryCursor simple_cursor = new com.epl.geometry.SimpleGeometryCursor(geometries); com.epl.geometry.GeometryCursor cursor = op.Execute(simple_cursor, b_merge, null); System.Collections.Generic.List <com.epl.geometry.Geometry> resultGeoms = new System.Collections.Generic.List <com.epl.geometry.Geometry>(); com.epl.geometry.Geometry g; while ((g = cursor.Next()) != null) { resultGeoms.Add(g); } com.epl.geometry.Geometry[] output = new com.epl.geometry.Geometry[resultGeoms.Count]; for (int i = 0; i < resultGeoms.Count; i++) { output[i] = resultGeoms[i]; } return(output); }
internal OperatorIntersectionCursor(com.epl.geometry.GeometryCursor inputGeoms, com.epl.geometry.GeometryCursor geomIntersector, com.epl.geometry.SpatialReference sr, com.epl.geometry.ProgressTracker progress_tracker, int dimensionMask) { // holds empty geometry of intersector // type. m_bEmpty = geomIntersector == null; m_index = -1; m_inputGeoms = inputGeoms; m_spatial_reference = sr; m_geomIntersector = geomIntersector.Next(); m_geomIntersectorType = m_geomIntersector.GetType().Value(); m_currentGeomType = com.epl.geometry.Geometry.Type.Unknown.Value(); m_progress_tracker = progress_tracker; m_dimensionMask = dimensionMask; if (m_dimensionMask != -1 && (m_dimensionMask <= 0 || m_dimensionMask > 7)) { throw new System.ArgumentException("bad dimension mask"); } }
public CutPair(com.epl.geometry.Geometry geometry, int side, int ipartCuttee, int ivertexCuttee, double scalarCuttee, int sidePrev, int ipartCutteePrev, int ivertexCutteePrev, double scalarCutteePrev, int ipartCutter, int ivertexCutter, double scalarCutter, int ipartCutterPrev, int ivertexCutterPrev , double scalarCutterPrev) { m_geometry = geometry; m_side = side; m_ipartCuttee = ipartCuttee; m_ivertexCuttee = ivertexCuttee; m_scalarCuttee = scalarCuttee; m_sidePrev = sidePrev; m_ipartCutteePrev = ipartCutteePrev; m_ivertexCutteePrev = ivertexCutteePrev; m_scalarCutteePrev = scalarCutteePrev; m_ipartCutter = ipartCutter; m_ivertexCutter = ivertexCutter; m_scalarCutter = scalarCutter; m_ipartCutterPrev = ipartCutterPrev; m_ivertexCutterPrev = ivertexCutterPrev; m_scalarCutterPrev = scalarCutterPrev; }
/// <summary>Calculates the cut geometry from a target geometry using a polyline.</summary> /// <remarks> /// Calculates the cut geometry from a target geometry using a polyline. For /// Polylines, all left cuts will be grouped together in the first Geometry, /// Right cuts and coincident cuts are grouped in the second Geometry, and /// each undefined cut, along with any uncut parts, are output as separate /// Polylines. For Polygons, all left cuts are grouped in the first Polygon, /// all right cuts are in the second Polygon, and each undefined cut, along /// with any left-over parts after cutting, are output as a separate Polygon. /// If there were no cuts then the array will be empty. An undefined cut will /// only be produced if a left cut or right cut was produced, and there was a /// part left over after cutting or a cut is bounded to the left and right of /// the cutter. /// See OperatorCut. /// </remarks> /// <param name="cuttee">The geometry to be cut.</param> /// <param name="cutter">The polyline to cut the geometry.</param> /// <param name="spatialReference">The spatial reference of the geometries.</param> /// <returns>An array of geometries created from cutting.</returns> public static com.epl.geometry.Geometry[] Cut(com.epl.geometry.Geometry cuttee, com.epl.geometry.Polyline cutter, com.epl.geometry.SpatialReference spatialReference) { if (cuttee == null || cutter == null) { return(null); } com.epl.geometry.OperatorCut op = (com.epl.geometry.OperatorCut)factory.GetOperator(com.epl.geometry.Operator.Type.Cut); com.epl.geometry.GeometryCursor cursor = op.Execute(true, cuttee, cutter, spatialReference, null); System.Collections.Generic.List <com.epl.geometry.Geometry> cutsList = new System.Collections.Generic.List <com.epl.geometry.Geometry>(); com.epl.geometry.Geometry geometry; while ((geometry = cursor.Next()) != null) { if (!geometry.IsEmpty()) { cutsList.Add(geometry); } } return(cutsList.ToArray()); }
public virtual void TestWKB() { // JSON -> GEOM -> WKB string strPolygon1 = "{\"xmin\":-1.1663479012889031E7,\"ymin\":4919777.494405342,\"xmax\":-1.1658587043078788E7,\"ymax\":4924669.464215587,\"spatialReference\":{\"wkid\":102100}}"; // String strPolygon1 = // "{\"rings\":[[[-119.152450421001,38.4118009590513],[-119.318825070203,38.5271086243914],[-119.575687062955,38.7029101298904],[-119.889341639399,38.9222515603984],[-119.995254694357,38.9941061536377],[-119.995150114198,39.0634913594691],[-119.994541258334,39.1061318056708],[-119.995527335641,39.1587132866355],[-119.995304181493,39.3115454332125],[-119.996011479298,39.4435009764511],[-119.996165311172,39.7206108077274],[-119.996324660047,41.1775662656441],[-119.993459369715,41.9892049531992],[-119.351692186077,41.9888529749781],[-119.3109421304,41.9891353872811],[-118.185316829038,41.9966370981387],[-117.018864363596,41.9947941808341],[-116.992313337997,41.9947945094663],[-115.947544658193,41.9945994628997],[-115.024862911148,41.996506455953],[-114.269471632824,41.9959242345073],[-114.039072662345,41.9953908974688],[-114.038151248682,40.9976868405942],[-114.038108189376,40.1110466529553],[-114.039844684228,39.9087788600023],[-114.040105338584,39.5386849268845],[-114.044267501155,38.6789958815881],[-114.045090206153,38.5710950539539],[-114.047272999176,38.1376524399918],[-114.047260595159,37.5984784866001],[-114.043939384154,36.9965379371421],[-114.043716435713,36.8418489458647],[-114.037392074194,36.2160228969702],[-114.045105557286,36.1939778840226],[-114.107775185788,36.1210907070504],[-114.12902308363,36.041730493896],[-114.206768869568,36.0172554164834],[-114.233472615347,36.0183310595897],[-114.307587598189,36.0622330993643],[-114.303857056018,36.0871084040611],[-114.316095374696,36.1114380366653],[-114.344233941709,36.1374802520568],[-114.380803116644,36.1509912717765],[-114.443945697733,36.1210532841897],[-114.466613475422,36.1247112590539],[-114.530573568745,36.1550902046725],[-114.598935242024,36.1383354528834],[-114.621610747198,36.1419666834504],[-114.712761724737,36.1051810523675],[-114.728150311069,36.0859627711604],[-114.728966012834,36.0587530361083],[-114.717673567756,36.0367580437018],[-114.736212493583,35.9876483502758],[-114.699275906446,35.9116119537412],[-114.661600122152,35.8804735854242],[-114.662462095522,35.8709599070091],[-114.689867343369,35.8474424944766],[-114.682739704595,35.7647034175617],[-114.688820027649,35.7325957399896],[-114.665091345861,35.6930994107107],[-114.668486064922,35.6563989882404],[-114.654065925137,35.6465840800053],[-114.6398667219,35.6113485698329],[-114.653134321223,35.5848331056108],[-114.649792053474,35.5466373866597],[-114.672215155693,35.5157541647721],[-114.645396168451,35.4507608261463],[-114.589584275424,35.3583787306827],[-114.587889840369,35.30476812919],[-114.559583045727,35.2201828714608],[-114.561039964054,35.1743461616313],[-114.572255261053,35.1400677445931],[-114.582616239058,35.1325604694085],[-114.626440825485,35.1339067529872],[-114.6359090842,35.1186557767895],[-114.595631971944,35.0760579746697],[-114.633779872695,35.0418633504303],[-114.621068606189,34.9989144286133],[-115.626197382816,35.7956983148418],[-115.88576934392,36.0012259572723],[-117.160423771838,36.9595941441767],[-117.838686423167,37.457298239715],[-118.417419755966,37.8866767486211],[-119.152450421001,38.4118009590513]]], \"spatialReference\":{\"wkid\":4326}}"; com.epl.geometry.MapGeometry mapGeom = com.epl.geometry.GeometryEngine.JsonToGeometry(strPolygon1); com.epl.geometry.Geometry geom = mapGeom.GetGeometry(); com.epl.geometry.OperatorExportToWkb operatorExport = (com.epl.geometry.OperatorExportToWkb)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.ExportToWkb); System.IO.MemoryStream byteBuffer = operatorExport.Execute(0, geom, null); byte[] wkb = ((byte[])byteBuffer.Array()); // WKB -> GEOM -> JSON com.epl.geometry.OperatorImportFromWkb operatorImport = (com.epl.geometry.OperatorImportFromWkb)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.ImportFromWkb); geom = operatorImport.Execute(0, com.epl.geometry.Geometry.Type.Polygon, System.IO.MemoryStream.Wrap(wkb), null); // geom = operatorImport.execute(0, Geometry.Type.Polygon, // byteBuffer); string outputPolygon1 = com.epl.geometry.GeometryEngine.GeometryToJson(-1, geom); }
public virtual void TestPointAndPoint2() { com.epl.geometry.Point basePl = new com.epl.geometry.Point(-115, 20); com.epl.geometry.Point compPl = new com.epl.geometry.Point(-116, 20); 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.IsTrue(intersectGeom.IsEmpty()); }
public override com.epl.geometry.OGCStructure ExecuteOGC(int import_flags, string wkt_string, com.epl.geometry.ProgressTracker progress_tracker) { System.Collections.Generic.List <com.epl.geometry.OGCStructure> stack = new System.Collections.Generic.List <com.epl.geometry.OGCStructure>(0); com.epl.geometry.WktParser wkt_parser = new com.epl.geometry.WktParser(wkt_string); com.epl.geometry.OGCStructure root = new com.epl.geometry.OGCStructure(); root.m_structures = new System.Collections.Generic.List <com.epl.geometry.OGCStructure>(0); stack.Add(root); // add dummy root while (wkt_parser.NextToken() != com.epl.geometry.WktParser.WktToken.not_available) { int current_token = wkt_parser.CurrentToken(); if (current_token == com.epl.geometry.WktParser.WktToken.right_paren) { stack.RemoveAt(stack.Count - 1); continue; } int ogc_type = current_token; com.epl.geometry.OGCStructure last = stack[stack.Count - 1]; if (current_token == com.epl.geometry.WktParser.WktToken.geometrycollection) { current_token = wkt_parser.NextToken(); if (current_token == com.epl.geometry.WktParser.WktToken.attribute_z || current_token == com.epl.geometry.WktParser.WktToken.attribute_m || current_token == com.epl.geometry.WktParser.WktToken.attribute_zm) { wkt_parser.NextToken(); } com.epl.geometry.OGCStructure next = new com.epl.geometry.OGCStructure(); next.m_type = ogc_type; next.m_structures = new System.Collections.Generic.List <com.epl.geometry.OGCStructure>(0); last.m_structures.Add(next); if (current_token != com.epl.geometry.WktParser.WktToken.empty) { stack.Add(next); } continue; } com.epl.geometry.Geometry geometry = ImportFromWkt(import_flags, com.epl.geometry.Geometry.Type.Unknown, wkt_parser); com.epl.geometry.OGCStructure leaf = new com.epl.geometry.OGCStructure(); leaf.m_type = ogc_type; leaf.m_geometry = geometry; last.m_structures.Add(leaf); } return(root); }
internal static void TestPointsOnLine2D(com.epl.geometry.Geometry line, com.epl.geometry.Point2D[] input_points, int count, double tolerance, com.epl.geometry.PolygonUtils.PiPResult[] test_results) { com.epl.geometry.Geometry.Type gt = line.GetType(); if (gt == com.epl.geometry.Geometry.Type.Polyline) { TestPointsOnPolyline2D_((com.epl.geometry.Polyline)line, input_points, count, tolerance, test_results); } else { if (com.epl.geometry.Geometry.IsSegment(gt.Value())) { TestPointsOnSegment_((com.epl.geometry.Segment)line, input_points, count, tolerance, test_results); } else { throw new com.epl.geometry.GeometryException("Invalid call."); } } }
public virtual void TestMP2onCR175871() { com.epl.geometry.Polygon pg = new com.epl.geometry.Polygon(); pg.StartPath(-50, 10); pg.LineTo(-50, 12); pg.LineTo(-45, 12); pg.LineTo(-45, 10); com.epl.geometry.Polygon pg1 = new com.epl.geometry.Polygon(); pg1.StartPath(-45, 10); pg1.LineTo(-40, 10); pg1.LineTo(-40, 8); pg.Add(pg1, false); com.epl.geometry.SpatialReference spatialReference = com.epl.geometry.SpatialReference.Create(4326); try { string jSonStr = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReference, pg); com.fasterxml.jackson.core.JsonFactory jf = new com.fasterxml.jackson.core.JsonFactory(); com.fasterxml.jackson.core.JsonParser jp = jf.CreateJsonParser(jSonStr); jp.NextToken(); com.epl.geometry.MapGeometry mg = com.epl.geometry.GeometryEngine.JsonToGeometry(jp); com.epl.geometry.Geometry gm = mg.GetGeometry(); NUnit.Framework.Assert.AreEqual(com.epl.geometry.Geometry.Type.Polygon, gm.GetType()); NUnit.Framework.Assert.IsTrue(mg.GetSpatialReference().GetID() == 4326); com.epl.geometry.Polygon pgNew = (com.epl.geometry.Polygon)gm; NUnit.Framework.Assert.AreEqual(pgNew.GetPathCount(), pg.GetPathCount()); NUnit.Framework.Assert.AreEqual(pgNew.GetPointCount(), pg.GetPointCount()); NUnit.Framework.Assert.AreEqual(pgNew.GetSegmentCount(), pg.GetSegmentCount()); NUnit.Framework.Assert.AreEqual(pgNew.GetPoint(0).GetX(), pg.GetPoint(0).GetX(), 0.000000001); NUnit.Framework.Assert.AreEqual(pgNew.GetPoint(1).GetX(), pg.GetPoint(1).GetX(), 0.000000001); NUnit.Framework.Assert.AreEqual(pgNew.GetPoint(2).GetX(), pg.GetPoint(2).GetX(), 0.000000001); NUnit.Framework.Assert.AreEqual(pgNew.GetPoint(3).GetX(), pg.GetPoint(3).GetX(), 0.000000001); NUnit.Framework.Assert.AreEqual(pgNew.GetPoint(0).GetY(), pg.GetPoint(0).GetY(), 0.000000001); NUnit.Framework.Assert.AreEqual(pgNew.GetPoint(1).GetY(), pg.GetPoint(1).GetY(), 0.000000001); NUnit.Framework.Assert.AreEqual(pgNew.GetPoint(2).GetY(), pg.GetPoint(2).GetY(), 0.000000001); NUnit.Framework.Assert.AreEqual(pgNew.GetPoint(3).GetY(), pg.GetPoint(3).GetY(), 0.000000001); } catch (System.Exception ex) { string err = ex.Message; System.Console.Out.Write(err); throw; } }
private static void ExportGeometryToGeoJson_(int export_flags, com.epl.geometry.Geometry geometry, com.epl.geometry.JsonWriter json_writer) { int type = geometry.GetType().Value(); switch (type) { case com.epl.geometry.Geometry.GeometryType.Polygon: { ExportPolygonToGeoJson_(export_flags, (com.epl.geometry.Polygon)geometry, json_writer); return; } case com.epl.geometry.Geometry.GeometryType.Polyline: { ExportPolylineToGeoJson_(export_flags, (com.epl.geometry.Polyline)geometry, json_writer); return; } case com.epl.geometry.Geometry.GeometryType.MultiPoint: { ExportMultiPointToGeoJson_(export_flags, (com.epl.geometry.MultiPoint)geometry, json_writer); return; } case com.epl.geometry.Geometry.GeometryType.Point: { ExportPointToGeoJson_(export_flags, (com.epl.geometry.Point)geometry, json_writer); return; } case com.epl.geometry.Geometry.GeometryType.Envelope: { ExportEnvelopeToGeoJson_(export_flags, (com.epl.geometry.Envelope)geometry, json_writer); return; } default: { throw new System.Exception("not implemented for this geometry type"); } } }
private com.epl.geometry.Geometry DensifyByLength(com.epl.geometry.Geometry geom) { if (geom.IsEmpty() || geom.GetDimension() < 1) { return(geom); } int geometryType = geom.GetType().Value(); // TODO implement IsMultiPath and remove Polygon and Polyline call to // match Native // if (Geometry.IsMultiPath(geometryType)) if (geometryType == com.epl.geometry.Geometry.GeometryType.Polygon) { return(DensifyMultiPath((com.epl.geometry.MultiPath)geom)); } else { if (com.epl.geometry.Geometry.GeometryType.Polyline == geometryType) { return(DensifyMultiPath((com.epl.geometry.MultiPath)geom)); } else { if (com.epl.geometry.Geometry.IsSegment(geometryType)) { return(DensifySegment((com.epl.geometry.Segment)geom)); } else { if (geometryType == com.epl.geometry.Geometry.GeometryType.Envelope) { return(DensifyEnvelope((com.epl.geometry.Envelope)geom)); } else { // TODO fix geometry exception to match native implementation throw com.epl.geometry.GeometryException.GeometryInternalError(); } } } } }
internal virtual com.epl.geometry.Geometry NormalizeIntersectionOutput(com.epl.geometry.Geometry geom, int GT_1, int GT_2) { if (GT_1 == com.epl.geometry.Geometry.GeometryType.Point || GT_2 == com.epl.geometry.Geometry.GeometryType.Point) { System.Diagnostics.Debug.Assert((geom.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Point)); } if (GT_1 == com.epl.geometry.Geometry.GeometryType.MultiPoint) { if (geom.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Point) { com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint(geom.GetDescription()); if (!geom.IsEmpty()) { mp.Add((com.epl.geometry.Point)geom); } return mp; } } return geom; }
// GEOMTHROW(invalid_call); public static void TestPointsInArea2D(com.epl.geometry.Geometry polygon, double[] xyStreamBuffer, int count, double tolerance, com.epl.geometry.PolygonUtils.PiPResult[] testResults) { if (polygon.GetType() == com.epl.geometry.Geometry.Type.Polygon) { TestPointsInPolygon2D((com.epl.geometry.Polygon)polygon, xyStreamBuffer, count, tolerance, testResults); } else { if (polygon.GetType() == com.epl.geometry.Geometry.Type.Envelope) { com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D(); ((com.epl.geometry.Envelope)polygon).QueryEnvelope2D(env2D); _testPointsInEnvelope2D(env2D, xyStreamBuffer, count, tolerance, testResults); } else { throw new com.epl.geometry.GeometryException("invalid_call"); } } }
public override com.epl.geometry.Proximity2DResult[] GetNearestVertices(com.epl.geometry.Geometry geom, com.epl.geometry.Point inputPoint, double searchRadius, int maxVertexCountToReturn) { if (maxVertexCountToReturn < 0) { throw new System.ArgumentException(); } if (geom.IsEmpty()) { return(new com.epl.geometry.Proximity2DResult[] { }); } com.epl.geometry.Point2D inputPoint2D = inputPoint.GetXY(); com.epl.geometry.Geometry proxmityTestGeom = geom; int gt = geom.GetType().Value(); if (gt == com.epl.geometry.Geometry.GeometryType.Envelope) { com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon(); polygon.AddEnvelope((com.epl.geometry.Envelope)geom, false); proxmityTestGeom = polygon; gt = com.epl.geometry.Geometry.GeometryType.Polygon; } switch (gt) { case com.epl.geometry.Geometry.GeometryType.Point: { return(PointGetNearestVertices((com.epl.geometry.Point)proxmityTestGeom, inputPoint2D, searchRadius, maxVertexCountToReturn)); } case com.epl.geometry.Geometry.GeometryType.MultiPoint: case com.epl.geometry.Geometry.GeometryType.Polyline: case com.epl.geometry.Geometry.GeometryType.Polygon: { return(MultiVertexGetNearestVertices((com.epl.geometry.MultiVertexGeometry)proxmityTestGeom, inputPoint2D, searchRadius, maxVertexCountToReturn)); } default: { throw new com.epl.geometry.GeometryException("not implemented"); } } }
public override com.epl.geometry.Proximity2DResult GetNearestCoordinate(com.epl.geometry.Geometry geom, com.epl.geometry.Point inputPoint, bool bTestPolygonInterior, bool bCalculateLeftRightSide) { if (geom.IsEmpty()) { return(new com.epl.geometry.Proximity2DResult()); } com.epl.geometry.Point2D inputPoint2D = inputPoint.GetXY(); com.epl.geometry.Geometry proxmityTestGeom = geom; int gt = geom.GetType().Value(); if (gt == com.epl.geometry.Geometry.GeometryType.Envelope) { com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon(); polygon.AddEnvelope((com.epl.geometry.Envelope)geom, false); proxmityTestGeom = polygon; gt = com.epl.geometry.Geometry.GeometryType.Polygon; } switch (gt) { case com.epl.geometry.Geometry.GeometryType.Point: { return(PointGetNearestVertex((com.epl.geometry.Point)proxmityTestGeom, inputPoint2D)); } case com.epl.geometry.Geometry.GeometryType.MultiPoint: { return(MultiVertexGetNearestVertex((com.epl.geometry.MultiVertexGeometry)proxmityTestGeom, inputPoint2D)); } case com.epl.geometry.Geometry.GeometryType.Polyline: case com.epl.geometry.Geometry.GeometryType.Polygon: { return(MultiPathGetNearestCoordinate((com.epl.geometry.MultiPath)proxmityTestGeom, inputPoint2D, bTestPolygonInterior, bCalculateLeftRightSide)); } default: { throw new com.epl.geometry.GeometryException("not implemented"); } } }
public override bool Equals(object other) { if (other == null) { return(false); } if (other == this) { return(true); } if (other.GetType() != GetType()) { return(false); } com.epl.geometry.ogc.OGCGeometry another = (com.epl.geometry.ogc.OGCGeometry)other; com.epl.geometry.Geometry geom1 = GetEsriGeometry(); com.epl.geometry.Geometry geom2 = another.GetEsriGeometry(); if (geom1 == null) { if (geom2 != null) { return(false); } } else { if (!geom1.Equals(geom2)) { return(false); } } if (esriSR == another.esriSR) { return(true); } if (esriSR != null && another.esriSR != null) { return(esriSR.Equals(another.esriSR)); } return(false); }
public override void CopyTo(com.epl.geometry.Geometry dst) { if (dst.GetType() != com.epl.geometry.Geometry.Type.Point) { throw new System.ArgumentException(); } com.epl.geometry.Point pointDst = (com.epl.geometry.Point)dst; dst._touch(); if (m_attributes == null) { pointDst.SetEmpty(); pointDst.m_attributes = null; pointDst.AssignVertexDescription(m_description); } else { pointDst.AssignVertexDescription(m_description); pointDst.ResizeAttributes(m_description.GetTotalComponentCount()); AttributeCopy(m_attributes, pointDst.m_attributes, m_description.GetTotalComponentCount()); } }
// dimension // mask // can // be // -1, // for // the // default // behavior, // or a // value // between // 1 and // 7. public override com.epl.geometry.Geometry Next() { if (m_bEmpty) { return null; } com.epl.geometry.Geometry geom; if (m_smallCursor != null) { // when dimension mask is used, we produce a geom = m_smallCursor.Next(); if (geom != null) { return geom; } else { m_smallCursor = null; } } // done with the small cursor while ((geom = m_inputGeoms.Next()) != null) { m_index = m_inputGeoms.GetGeometryID(); if (m_dimensionMask == -1) { com.epl.geometry.Geometry resGeom = Intersect(geom); System.Diagnostics.Debug.Assert((resGeom != null)); return resGeom; } else { m_smallCursor = IntersectEx(geom); com.epl.geometry.Geometry resGeom = m_smallCursor.Next(); System.Diagnostics.Debug.Assert((resGeom != null)); return resGeom; } } return null; }
// resets Iterators if they are used. private bool WeakIntersectionTest_(com.epl.geometry.Geometry geometryA, com.epl.geometry.Geometry geometryB, com.epl.geometry.SegmentIterator segIterA, com.epl.geometry.SegmentIterator segIterB) { /* const */ /* const */ if (geometryA.GetType() == com.epl.geometry.Geometry.Type.Polygon) { // test PolygonA vs. first segment of each of geometryB's paths while (segIterB.NextPath()) { if (segIterB.HasNextSegment()) { /* const */ com.epl.geometry.Segment segmentB = segIterB.NextSegment(); if (com.epl.geometry.PolygonUtils.IsPointInPolygon2D((com.epl.geometry.Polygon)geometryA, segmentB.GetEndXY(), 0) != com.epl.geometry.PolygonUtils.PiPResult.PiPOutside) { return(true); } } } segIterB.ResetToFirstPath(); } if (geometryB.GetType() == com.epl.geometry.Geometry.Type.Polygon) { // test PolygonB vs. first segment of each of geometryA's paths while (segIterA.NextPath()) { if (segIterA.HasNextSegment()) { /* const */ com.epl.geometry.Segment segmentA = segIterA.NextSegment(); if (com.epl.geometry.PolygonUtils.IsPointInPolygon2D((com.epl.geometry.Polygon)geometryB, segmentA.GetEndXY(), 0) != com.epl.geometry.PolygonUtils.PiPResult.PiPOutside) { return(true); } } } segIterA.ResetToFirstPath(); } return(false); }
public static void TestDifferenceOnPolyline() { // # * * # // # * @ // # @ * // # * // // /////////////////////////////// // // The polyline drawn in *s represents basePl // The polyline drawn in #s represents compPl // The @ represents their intersection points, so that // the difference polyline will be basePl with two new vertices @ added. 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(-130, 10)); basePl.LineTo(new com.epl.geometry.Point(-120, 50)); 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)); com.epl.geometry.Geometry diffGeom = com.epl.geometry.GeometryEngine.Difference(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326)); NUnit.Framework.Assert.IsTrue(diffGeom is com.epl.geometry.Polyline); com.epl.geometry.Polyline diffPolyline = (com.epl.geometry.Polyline)diffGeom; int pointCountDiffPolyline = diffPolyline.GetPointCount(); // first line in comp_pl is 3y = 2x + 292 NUnit.Framework.Assert.AreEqual(3 * 20, 2 * (-116) + 292); NUnit.Framework.Assert.AreEqual(3 * 10, 2 * (-131) + 292); // new points should also lie on this line NUnit.Framework.Assert.IsTrue(3.0 * diffPolyline.GetCoordinates2D()[1].y - 2.0 * diffPolyline.GetCoordinates2D()[1].x - 292.0 == 0.0); NUnit.Framework.Assert.IsTrue(3.0 * diffPolyline.GetCoordinates2D()[3].y - 2.0 * diffPolyline.GetCoordinates2D()[3].x - 292.0 == 0.0); for (int i = 0; i < 3; i++) { NUnit.Framework.Assert.IsTrue(basePl.GetCoordinates2D()[i].x == diffPolyline.GetCoordinates2D()[2 * i].x); NUnit.Framework.Assert.IsTrue(basePl.GetCoordinates2D()[i].y == diffPolyline.GetCoordinates2D()[2 * i].y); } NUnit.Framework.Assert.AreEqual(5, pointCountDiffPolyline); }
internal static void SimpleTest(com.epl.geometry.Geometry point) { NUnit.Framework.Assert.IsTrue(point != null); // point->AddAttribute(VertexDescription::Semantics::Z); // assertTrue(point->HasAttribute(VertexDescription::Semantics::POSITION)); // assertTrue(point.->HasAttribute(VertexDescription::Semantics::Z)); // point->AddAttribute(VertexDescription::Semantics::Z);//duplicate call // assertTrue(point->GetDescription()->GetAttributeCount() == 2); // assertTrue(point->GetDescription()->GetSemantics(1) == // VertexDescription::Semantics::Z); // point->DropAttribute(VertexDescription::Semantics::Z); // assertFalse(point->HasAttribute(VertexDescription::Semantics::Z)); // point->DropAttribute(VertexDescription::Semantics::Z);//duplicate // call // assertFalse(point->HasAttribute(VertexDescription::Semantics::Z)); // assertTrue(point->GetDescription()->GetAttributeCount() == 1); // assertTrue(point->GetDescription()->GetSemantics(0) == // VertexDescription::Semantics::POSITION); // point->AddAttribute(VertexDescription::Semantics::M); // assertTrue(point->HasAttribute(VertexDescription::Semantics::POSITION)); // assertFalse(point->HasAttribute(VertexDescription::Semantics::Z)); // assertTrue(point->HasAttribute(VertexDescription::Semantics::M)); // point->DropAttribute(VertexDescription::Semantics::M); // assertFalse(point->HasAttribute(VertexDescription::Semantics::M)); // // point->AddAttribute(VertexDescription::Semantics::ID); // assertTrue(point->HasAttribute(VertexDescription::Semantics::POSITION)); // assertFalse(point->HasAttribute(VertexDescription::Semantics::Z)); // assertFalse(point->HasAttribute(VertexDescription::Semantics::M)); // point->DropAttribute(VertexDescription::Semantics::ID); // assertFalse(point->HasAttribute(VertexDescription::Semantics::ID)); // / // assertTrue(point->IsEmpty()); // assertTrue(point->GetPointCount() == 0); // assertTrue(point->GetPartCount() == 0); point = null; NUnit.Framework.Assert.IsFalse(point != null); }
public override com.epl.geometry.Geometry Next() { while (true) { if (m_curs != null) { com.epl.geometry.Geometry g = m_curs.Next(); if (g != null) { m_index++; return(g); } m_curs = null; } if (m_ind >= m_geoms.Count) { return(null); } int i = m_ind; m_ind++; if (m_geoms[i] == null) { continue; } // filter out nulls if (!m_geoms[i].IsConcreteGeometryCollection()) { m_index++; return(m_geoms[i].GetEsriGeometry()); } else { com.epl.geometry.ogc.OGCConcreteGeometryCollection gc = (com.epl.geometry.ogc.OGCConcreteGeometryCollection)m_geoms[i]; m_curs = new com.epl.geometry.ogc.OGCConcreteGeometryCollection.GeometryCursorOGC(gc.geometries); return(Next()); } } }
public virtual void TestIntersectBetweenPolylines() { 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(-130, 10)); basePl.LineTo(new com.epl.geometry.Point(-120, 50)); 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 try { com.epl.geometry.Geometry 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); }
public virtual void TestPointAndPoint1() { com.epl.geometry.Point basePl = new com.epl.geometry.Point(-116, 20); com.epl.geometry.Point compPl = new com.epl.geometry.Point(-116, 20); 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 virtual void TestGeometryOperationSupport() { com.epl.geometry.Geometry baseGeom = new com.epl.geometry.Point(-130, 10); com.epl.geometry.Geometry comparisonGeom = new com.epl.geometry.Point(-130, 10); com.epl.geometry.SpatialReference sr = com.epl.geometry.SpatialReference.Create(4326); com.epl.geometry.Geometry diffGeom = null; int noException = 1; // no exception try { diffGeom = com.epl.geometry.GeometryEngine.Difference(baseGeom, comparisonGeom, sr); } catch (System.ArgumentException) { noException = 0; } catch (com.epl.geometry.GeometryException) { noException = 0; } NUnit.Framework.Assert.AreEqual(noException, 1); }
public virtual void OffsetPolygon_(double distance, com.epl.geometry.OperatorOffset.JoinType joins) { com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon(); polygon.StartPath(0, 0); polygon.LineTo(0, 16); polygon.LineTo(16, 16); polygon.LineTo(16, 11); polygon.LineTo(10, 10); polygon.LineTo(10, 12); polygon.LineTo(3, 12); polygon.LineTo(3, 4); polygon.LineTo(10, 4); polygon.LineTo(10, 6); polygon.LineTo(16, 5); polygon.LineTo(16, 0); com.epl.geometry.OperatorOffset offset = (com.epl.geometry.OperatorOffset)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Offset); com.epl.geometry.Geometry outputGeom = offset.Execute(polygon, null, distance, joins, 2, 0, null); NUnit.Framework.Assert.IsNotNull(outputGeom); if (distance > 2) { NUnit.Framework.Assert.IsTrue(outputGeom.IsEmpty()); } }