예제 #1
0
  protected Rectangle makeNormRect(double minX, double maxX, double minY, double maxY) {
    if (ctx.isGeo()) {
      if (Math.abs(maxX - minX) >= 360) {
        minX = -180;
        maxX = 180;
      } else {
        minX = DistanceUtils.normLonDEG(minX);
        maxX = DistanceUtils.normLonDEG(maxX);
      }

    } else {
      if (maxX < minX) {
        double t = minX;
        minX = maxX;
        maxX = t;
      }
      minX = boundX(minX, ctx.getWorldBounds());
      maxX = boundX(maxX, ctx.getWorldBounds());
    }
    if (maxY < minY) {
      double t = minY;
      minY = maxY;
      maxY = t;
    }
    minY = boundY(minY, ctx.getWorldBounds());
    maxY = boundY(maxY, ctx.getWorldBounds());
    return ctx.makeRectangle(minX, maxX, minY, maxY);
  }
예제 #2
0
 private void init() {
   if (radiusDEG > 90) {
     // --spans more than half the globe
     assert enclosingBox.getWidth() == 360;
     double backDistDEG = 180 - radiusDEG;
     if (backDistDEG > 0) {
       double backRadius = 180 - radiusDEG;
       double backX = DistanceUtils.normLonDEG(getCenter().getX() + 180);
       double backY = DistanceUtils.normLatDEG(getCenter().getY() + 180);
       // Shrink inverseCircle as small as possible to avoid accidental overlap.
       // Note that this is tricky business to come up with a value small enough
       // but not too small or else numerical conditioning issues become a problem.
       backRadius -=
           Math.max(
               Math.ulp(Math.abs(backY) + backRadius), Math.ulp(Math.abs(backX) + backRadius));
       if (inverseCircle != null) {
         inverseCircle.reset(backX, backY, backRadius);
       } else {
         inverseCircle = new GeoCircle(ctx.makePoint(backX, backY), backRadius, ctx);
       }
     } else {
       inverseCircle = null; // whole globe
     }
     horizAxisY = getCenter().getY(); // although probably not used
   } else {
     inverseCircle = null;
     double _horizAxisY =
         ctx.getDistCalc().calcBoxByDistFromPt_yHorizAxisDEG(getCenter(), radiusDEG, ctx);
     // some rare numeric conditioning cases can cause this to be barely beyond the box
     if (_horizAxisY > enclosingBox.getMaxY()) {
       horizAxisY = enclosingBox.getMaxY();
     } else if (_horizAxisY < enclosingBox.getMinY()) {
       horizAxisY = enclosingBox.getMinY();
     } else {
       horizAxisY = _horizAxisY;
     }
     // assert enclosingBox.relate_yRange(horizAxis,horizAxis,ctx).intersects();
   }
 }
예제 #3
0
 protected double normX(double x) {
   return ctx.isGeo() ? DistanceUtils.normLonDEG(x) : x;
 }