boolean boundaryApproxEquals(S2Polygon b,double maxError){
  if (numLoops() != b.numLoops()) {
    log.severe("!= loops: " + Integer.toString(numLoops()) + " vs. "+ Integer.toString(b.numLoops()));
    return false;
  }
  for (int i=0; i < numLoops(); ++i) {
    S2Loop aLoop=loop(i);
    boolean success=false;
    for (int j=0; j < numLoops(); ++j) {
      S2Loop bLoop=b.loop(j);
      if (bLoop.depth() == aLoop.depth() && bLoop.boundaryApproxEquals(aLoop,maxError)) {
        success=true;
        break;
      }
    }
    if (!success) {
      return false;
    }
  }
  return true;
}

boolean boundaryApproxEquals ( S2Polygon b , double maxError ) { if ( numLoops ( ) != b . numLoops ( ) ) { log . severe ( "!= loops: " + Integer . toString ( numLoops ( ) ) + " vs. " + Integer . toString ( b . numLoops ( ) ) ) ; return false ; } for ( int i = 0 ; i < numLoops ( ) ; ++ i ) { S2Loop aLoop = loop ( i ) ; boolean success = false ; for ( int j = 0 ; j < numLoops ( ) ; ++ j ) { S2Loop bLoop = b . loop ( j ) ; if ( bLoop . depth ( ) == aLoop . depth ( ) && bLoop . boundaryApproxEquals ( aLoop , maxError ) ) { success = true ; break ; } } if ( ! success ) { return false ; } } return true ; }
return true if two polygons have the same boundary except for vertex perturbations . both polygons must have loops with the same cyclic vertex order and the same nesting hierarchy , but the vertex locations are allowed to differ by up to " max_error " . note : this method mostly useful only for testing purposes .
