Esempio n. 1
0
  private void updateState(WMSRequest request) {
    b =
        new ProjectionBounds(
            layer.getEastNorth(request.getXIndex(), request.getYIndex()),
            layer.getEastNorth(request.getXIndex() + 1, request.getYIndex() + 1));
    if (b.min != null && b.max != null && WMSLayer.PROP_OVERLAP.get()) {
      double eastSize = b.max.east() - b.min.east();
      double northSize = b.max.north() - b.min.north();

      double eastCoef = WMSLayer.PROP_OVERLAP_EAST.get() / 100.0;
      double northCoef = WMSLayer.PROP_OVERLAP_NORTH.get() / 100.0;

      this.b =
          new ProjectionBounds(
              new EastNorth(b.min.east(), b.min.north()),
              new EastNorth(
                  b.max.east() + eastCoef * eastSize, b.max.north() + northCoef * northSize));
    }

    this.proj = Main.proj;
    this.pixelPerDegree = request.getPixelPerDegree();
    this.request = request;
  }
Esempio n. 2
0
  protected void attempt(WMSRequest request) { // try to fetch the image
    int maxTries = 5; // n tries for every image
    for (int i = 1; i <= maxTries; i++) {
      if (canceled) return;
      try {
        if (!layer.requestIsValid(request)) return;
        fetch(request, i);
        break; // break out of the retry loop
      } catch (Exception e) {
        try { // sleep some time and then ask the server again
          Thread.sleep(random(1000, 2000));
        } catch (InterruptedException e1) {
        }

        if (i == maxTries) {
          e.printStackTrace();
          request.finish(State.FAILED, null);
        }
      }
    }
  }