docs: private static float pointToPolygonDist(double x, double y, Polygon polygon) {
          boolean inside = false;
          double minDistSq = Double.POSITIVE_INFINITY;
  
          // External ring
          LineString exterior = polygon.getExteriorRing();
          for (int i = 0, n = exterior.getNumPoints() - 1, j = n - 1; i < n; j = i, i++) {
              Coordinate a = exterior.getCoordinateN(i);
              Coordinate b = exterior.getCoordinateN(j);
  
              if (((a.y > y) ^ (b.y > y)) &&
                      (x < (b.x - a.x) * (y - a.y) / (b.y - a.y) + a.x))
                  inside = !inside;
  
              double seqDistSq = getSegDistSq(x, y, a, b);
              minDistSq = Math.min(minDistSq, seqDistSq);
          }
          // Internal rings
          for (int k = 0; k < polygon.getNumInteriorRing(); k++) {
              LineString interior = polygon.getInteriorRingN(k);
              for (int i = 0, n = interior.getNumPoints() - 1, j = n - 1; i < n; j = i, i++) {
                  Coordinate a = interior.getCoordinateN(i);
                  Coordinate b = interior.getCoordinateN(j);
  
                  if (((a.y > y) ^ (b.y > y)) &&
                          (x < (b.x - a.x) * (y - a.y) / (b.y - a.y) + a.x))
                      inside = !inside;
  
                  minDistSq = Math.min(minDistSq, getSegDistSq(x, y, a, b));
              }
          }
  
          return (float) ((inside ? 1 : -1) * Math.sqrt(minDistSq));
      }