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); }
private static void ShowProjectedGeometryInfo(com.epl.geometry.MapGeometry mapGeom) { System.Console.Out.WriteLine("\n"); com.epl.geometry.MapGeometry geom = mapGeom; // while ((geom = geomCursor.next()) != null) { if (geom.GetGeometry() is com.epl.geometry.Point) { com.epl.geometry.Point pnt = (com.epl.geometry.Point)geom.GetGeometry(); System.Console.Out.WriteLine("Point(" + pnt.GetX() + " , " + pnt.GetY() + ")"); if (geom.GetSpatialReference() == null) { System.Console.Out.WriteLine("No spatial reference"); } else { System.Console.Out.WriteLine("wkid: " + geom.GetSpatialReference().GetID()); } } else { if (geom.GetGeometry() is com.epl.geometry.MultiPoint) { com.epl.geometry.MultiPoint mp = (com.epl.geometry.MultiPoint)geom.GetGeometry(); System.Console.Out.WriteLine("Multipoint has " + mp.GetPointCount() + " points."); System.Console.Out.WriteLine("wkid: " + geom.GetSpatialReference().GetID()); } else { if (geom.GetGeometry() is com.epl.geometry.Polygon) { com.epl.geometry.Polygon mp = (com.epl.geometry.Polygon)geom.GetGeometry(); System.Console.Out.WriteLine("Polygon has " + mp.GetPointCount() + " points and " + mp.GetPathCount() + " parts."); if (mp.GetPathCount() > 1) { System.Console.Out.WriteLine("Part start of 2nd segment : " + mp.GetPathStart(1)); System.Console.Out.WriteLine("Part end of 2nd segment : " + mp.GetPathEnd(1)); System.Console.Out.WriteLine("Part size of 2nd segment : " + mp.GetPathSize(1)); int start = mp.GetPathStart(1); int end = mp.GetPathEnd(1); for (int i = start; i < end; i++) { com.epl.geometry.Point pp = mp.GetPoint(i); System.Console.Out.WriteLine("Point(" + i + ") = (" + pp.GetX() + ", " + pp.GetY() + ")"); } } System.Console.Out.WriteLine("wkid: " + geom.GetSpatialReference().GetID()); } else { if (geom.GetGeometry() is com.epl.geometry.Polyline) { com.epl.geometry.Polyline mp = (com.epl.geometry.Polyline)geom.GetGeometry(); System.Console.Out.WriteLine("Polyline has " + mp.GetPointCount() + " points and " + mp.GetPathCount() + " parts."); System.Console.Out.WriteLine("Part start of 2nd segment : " + mp.GetPathStart(1)); System.Console.Out.WriteLine("Part end of 2nd segment : " + mp.GetPathEnd(1)); System.Console.Out.WriteLine("Part size of 2nd segment : " + mp.GetPathSize(1)); int start = mp.GetPathStart(1); int end = mp.GetPathEnd(1); for (int i = start; i < end; i++) { com.epl.geometry.Point pp = mp.GetPoint(i); System.Console.Out.WriteLine("Point(" + i + ") = (" + pp.GetX() + ", " + pp.GetY() + ")"); } System.Console.Out.WriteLine("wkid: " + geom.GetSpatialReference().GetID()); } } } } }