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); }
internal static bool IsConvex_(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker) { if (geom.IsEmpty()) { return(true); } // vacuously true com.epl.geometry.Geometry.Type type = geom.GetType(); if (type == com.epl.geometry.Geometry.Type.Point) { return(true); } // vacuously true if (type == com.epl.geometry.Geometry.Type.Envelope) { com.epl.geometry.Envelope envelope = (com.epl.geometry.Envelope)geom; if (envelope.GetXMin() == envelope.GetXMax() || envelope.GetYMin() == envelope.GetYMax()) { return(false); } return(true); } if (com.epl.geometry.MultiPath.IsSegment(type.Value())) { com.epl.geometry.Segment segment = (com.epl.geometry.Segment)geom; if (segment.GetStartXY().Equals(segment.GetEndXY())) { return(false); } return(true); } // true, but we will upgrade to a Polyline for the ConvexHull operation if (type == com.epl.geometry.Geometry.Type.MultiPoint) { com.epl.geometry.MultiPoint multi_point = (com.epl.geometry.MultiPoint)geom; if (multi_point.GetPointCount() == 1) { return(true); } // vacuously true, but we will downgrade to a Point for the ConvexHull operation return(false); } if (type == com.epl.geometry.Geometry.Type.Polyline) { com.epl.geometry.Polyline polyline = (com.epl.geometry.Polyline)geom; if (polyline.GetPathCount() == 1 && polyline.GetPointCount() == 2) { if (!polyline.GetXY(0).Equals(polyline.GetXY(1))) { return(true); } } // vacuously true return(false); } // create convex hull com.epl.geometry.Polygon polygon = (com.epl.geometry.Polygon)geom; if (polygon.GetPathCount() != 1 || polygon.GetPointCount() < 3) { return(false); } return(com.epl.geometry.ConvexHull.IsPathConvex(polygon, 0, progress_tracker)); }