private static boolean polygonEqualsPolygon_(Polygon polygon_a, Polygon polygon_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polygon_a.queryEnvelope2D(env_a); polygon_b.queryEnvelope2D(env_b); // Quick envelope rejection test for false equality. if (!envelopeEqualsEnvelope_(env_a, env_b, tolerance, progress_tracker)) return false; // Quick rasterize test to see whether the the geometries are disjoint, // or if one is contained in the other. int relation = tryRasterizedContainsOrDisjoint_(polygon_a, polygon_b, tolerance, false); if (relation == Relation.disjoint || relation == Relation.contains || relation == Relation.within) return false; // Quick point equality check for true equality. This just checks if all // the points in each ring are the same (within a tolerance) and in the // same order if (multiPathExactlyEqualsMultiPath_(polygon_a, polygon_b, tolerance, progress_tracker)) return true; double length_a = polygon_a.calculateLength2D(); double length_b = polygon_b.calculateLength2D(); int max_vertices = Math.max(polygon_a.getPointCount(), polygon_b.getPointCount()); if (Math.abs(length_a - length_b) > max_vertices * 4.0 * tolerance) return false; return linearPathEqualsLinearPath_(polygon_a, polygon_b, tolerance, true); }
private static boolean polygonEqualsPolygon_(Polygon polygon_a, Polygon polygon_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polygon_a.queryEnvelope2D(env_a); polygon_b.queryEnvelope2D(env_b); // Quick envelope rejection test for false equality. if (!envelopeEqualsEnvelope_(env_a, env_b, tolerance, progress_tracker)) return false; // Quick rasterize test to see whether the the geometries are disjoint, // or if one is contained in the other. int relation = tryRasterizedContainsOrDisjoint_(polygon_a, polygon_b, tolerance, false); if (relation == Relation.disjoint || relation == Relation.contains || relation == Relation.within) return false; // Quick point equality check for true equality. This just checks if all // the points in each ring are the same (within a tolerance) and in the // same order if (multiPathExactlyEqualsMultiPath_(polygon_a, polygon_b, tolerance, progress_tracker)) return true; double length_a = polygon_a.calculateLength2D(); double length_b = polygon_b.calculateLength2D(); int max_vertices = Math.max(polygon_a.getPointCount(), polygon_b.getPointCount()); if (Math.abs(length_a - length_b) > max_vertices * 4.0 * tolerance) return false; return linearPathEqualsLinearPath_(polygon_a, polygon_b, tolerance, true); }