Examples of BBox


Examples of org.geomajas.geometry.Bbox

    Assert.assertEquals(bbox, geoService.transform(bbox, source, source));
  }

  @Test
  public void transformBboxStringTest() throws Exception {
    Bbox bbox = new Bbox(10, 30, 10, 10);
    Bbox transformed = geoService.transform(bbox, MERCATOR, LONLAT);
    Assert.assertEquals(8.983152841195215E-5, transformed.getX(), DELTA);
    Assert.assertEquals(2.6949458522981454E-4, transformed.getY(), DELTA);
    Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA);
    Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA);

    Assert.assertEquals(bbox, geoService.transform(bbox, MERCATOR, MERCATOR));
  }
View Full Code Here

Examples of org.geomajas.geometry.Bbox

  }

  @Test
  public void transformBboxCrsTransformTest() throws Exception {
    CrsTransform crsTransform = geoService.getCrsTransform(MERCATOR, LONLAT);
    Bbox bbox = new Bbox(10, 30, 10, 10);
    Bbox transformed = geoService.transform(bbox, crsTransform);
    Assert.assertEquals(8.983152841195215E-5, transformed.getX(), DELTA);
    Assert.assertEquals(2.6949458522981454E-4, transformed.getY(), DELTA);
    Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA);
    Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA);
  }
View Full Code Here

Examples of org.geomajas.geometry.Bbox

  }

  @Test
  public void transformBboxCrsNoTransformTest() throws Exception {
    CrsTransform crsTransform = geoService.getCrsTransform(MERCATOR, MERCATOR);
    Bbox bbox = new Bbox(10, 20, 30, 40);
    Bbox transformed = geoService.transform(bbox, crsTransform);
    Assert.assertEquals(10, transformed.getX(), DELTA);
    Assert.assertEquals(20, transformed.getY(), DELTA);
    Assert.assertEquals(30, transformed.getWidth(), DELTA);
    Assert.assertEquals(40, transformed.getHeight(), DELTA);
  }
View Full Code Here

Examples of org.geomajas.geometry.Bbox

        long totalTimeout = DOWNLOAD_TIMEOUT + DOWNLOAD_TIMEOUT_ONE_TILE * tiles.size();
        log.debug("=== total timeout (millis): {}", totalTimeout);
        ExecutorService service = Executors.newFixedThreadPool(DOWNLOAD_MAX_THREADS);
        List<Future<ImageResult>> futures = service.invokeAll(callables, totalTimeout, TimeUnit.MILLISECONDS);
        // determine the pixel bounds of the mosaic
        Bbox pixelBounds = getPixelBounds(tiles);
        // create the images for the mosaic
        List<RenderedImage> images = new ArrayList<RenderedImage>();
        for (Future<ImageResult> future : futures) {
          if (future.isDone()) {
            try {
              ImageResult result;
              result = future.get();
              // create a rendered image
              RenderedImage image = JAI.create("stream", new ByteArraySeekableStream(result.getImage()));
              // convert to common direct colormodel (some images have their own indexed color model)
              RenderedImage colored = toDirectColorModel(image);

              // translate to the correct position in the tile grid
              double xOffset = result.getRasterImage().getCode().getX() * tileWidth - pixelBounds.getX();
              double yOffset;
              // TODO: in some cases, the y-index is up (e.g. WMS), should be down for
              // all layers !!!!
              if (isYIndexUp(tiles)) {
                yOffset = result.getRasterImage().getCode().getY() * tileHeight - pixelBounds.getY();
              } else {
                yOffset = (pixelBounds.getMaxY() - (result.getRasterImage().getCode().getY() + 1)
                    * tileHeight);
              }
              log.debug("adding to(" + xOffset + "," + yOffset + "), url = "
                  + result.getRasterImage().getUrl());
              RenderedImage translated = TranslateDescriptor.create(colored, (float) xOffset,
                  (float) yOffset, new InterpolationNearest(), null);
              images.add(translated);
            } catch (ExecutionException e) {
              addLoadError(graphics, (ImageException) (e.getCause()), viewport);
            } catch (InterruptedException e) {
              log.warn("missing tile in mosaic " + e.getMessage());
            } catch (MalformedURLException e) {
              log.warn("missing tile in mosaic " + e.getMessage());
            } catch (IOException e) {
              log.warn("missing tile in mosaic " + e.getMessage());
            }
          }
        }

        if (images.size() > 0) {
          ImageLayout imageLayout = new ImageLayout(0, 0, (int) pixelBounds.getWidth(),
              (int) pixelBounds.getHeight());
          imageLayout.setTileWidth(tileWidth);
          imageLayout.setTileHeight(tileHeight);

          // create the mosaic image
          ParameterBlock pbMosaic = new ParameterBlock();
View Full Code Here

Examples of org.geomajas.geometry.Bbox

    ReferencedEnvelope worldBounds = viewport.getBounds();
    // convert map bounds to application bounds
    double rasterScale = screenArea.getWidth() / worldBounds.getWidth();
    Envelope applicationBounds = new Envelope(worldBounds.getMinX() * rasterScale, worldBounds.getMaxX()
        * rasterScale, -worldBounds.getMinY() * rasterScale, -worldBounds.getMaxY() * rasterScale);
    Bbox imageBounds = imageResult.getRasterImage().getBounds();
    // find transform between image bounds and application bounds
    double tx = (imageBounds.getX() - applicationBounds.getMinX());
    double ty = (imageBounds.getY() - applicationBounds.getMinY());
    BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageResult.getImage()));
    double scaleX = imageBounds.getWidth() / image.getWidth();
    double scaleY = imageBounds.getHeight() / image.getHeight();
    AffineTransform transform = new AffineTransform();
    transform.translate(tx, ty);
    transform.scale(scaleX, scaleY);
    if (log.isDebugEnabled()) {
      log.debug("adding image, width=" + image.getWidth() + ",height=" + image.getHeight() + ",x=" + tx + ",y="
View Full Code Here

Examples of org.geomajas.geometry.Bbox

      return 1f;
    }
  }

  protected void addLoadError(Graphics2D graphics, ImageException imageResult, MapViewport viewport) {
    Bbox imageBounds = imageResult.getRasterImage().getBounds();
    ReferencedEnvelope viewBounds = viewport.getBounds();
    double rasterScale = viewport.getScreenArea().getWidth() / viewport.getBounds().getWidth();
    double width = imageBounds.getWidth();
    double height = imageBounds.getHeight();
    // subtract screen position of lower-left corner
    double x = imageBounds.getX() - rasterScale * viewBounds.getMinX();
    // shift y to lowerleft corner, flip y to user space and subtract
    // screen position of lower-left
    // corner
    double y = -imageBounds.getY() - imageBounds.getHeight() - rasterScale * viewBounds.getMinY();
    if (log.isDebugEnabled()) {
      log.debug("adding image, width=" + width + ",height=" + height + ",x=" + x + ",y=" + y);
    }
    // opacity
    log.debug("before drawImage");
View Full Code Here

Examples of org.geomajas.geometry.Bbox

    }
    return false;
  }

  private Bbox getPixelBounds(List<RasterTile> tiles) {
    Bbox bounds = null;
    for (RasterTile tile : tiles) {
      Bbox tileBounds = new Bbox(tile.getCode().getX() * tileWidth, tile.getCode().getY() * tileHeight,
          tileWidth, tileHeight);
      if (bounds == null) {
        bounds = new Bbox(tileBounds.getX(), tileBounds.getY(), tileBounds.getWidth(), tileBounds.getHeight());

      } else {
        double minx = Math.min(tileBounds.getX(), bounds.getX());
        double maxx = Math.max(tileBounds.getMaxX(), bounds.getMaxX());
        double miny = Math.min(tileBounds.getY(), bounds.getY());
        double maxy = Math.max(tileBounds.getMaxY(), bounds.getMaxY());
        bounds = new Bbox(minx, miny, maxx - minx, maxy - miny);
      }
    }
    return bounds;
  }
View Full Code Here

Examples of org.geomajas.geometry.Bbox

    }
    return bounds;
  }

  private Bbox getWorldBounds(List<RasterTile> tiles) {
    Bbox bounds = null;
    for (RasterTile tile : tiles) {
      Bbox tileBounds = new Bbox(tile.getBounds().getX(), tile.getBounds().getY(), tile.getBounds().getWidth(),
          tile.getBounds().getHeight());
      if (bounds == null) {
        bounds = new Bbox(tileBounds.getX(), tileBounds.getY(), tileBounds.getWidth(), tileBounds.getHeight());

      } else {
        double minx = Math.min(tileBounds.getX(), bounds.getX());
        double maxx = Math.max(tileBounds.getMaxX(), bounds.getMaxX());
        double miny = Math.min(tileBounds.getY(), bounds.getY());
        double maxy = Math.max(tileBounds.getMaxY(), bounds.getMaxY());
        bounds = new Bbox(minx, miny, maxx - minx, maxy - miny);
      }
    }
    return bounds;
  }
View Full Code Here

Examples of org.geomajas.geometry.Bbox

  private CommandDispatcher dispatcher;

  @Test
  public void testConvertMaxExtent() throws Exception {
    Layer layer = configurationService.getLayer("countries");
    Bbox configMaxExtent = layer.getLayerInfo().getMaxExtent();
    Assert.assertEquals(-85.05112877980659, configMaxExtent.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(-85.05112877980659, configMaxExtent.getY(), DOUBLE_TOLERANCE);
    Assert.assertEquals(170.102257, configMaxExtent.getWidth(), DOUBLE_TOLERANCE);
    Assert.assertEquals(170.102257, configMaxExtent.getHeight(), DOUBLE_TOLERANCE);

    GetMapConfigurationRequest request = new GetMapConfigurationRequest();
    request.setApplicationId("simplevectors");
    request.setMapId("coordTestMap");
    GetMapConfigurationResponse response = (GetMapConfigurationResponse) dispatcher.execute(
        GetMapConfigurationRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
    ClientMapInfo mapInfo = response.getMapInfo();
    Assert.assertNotNull(mapInfo);
    Bbox mapMaxExtent = mapInfo.getLayers().get(0).getMaxExtent();
    // these values were registered during a first run, they have *not* been externally verified
    Assert.assertEquals(-9467848.347161204, mapMaxExtent.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(-2.0037508342789236E7, mapMaxExtent.getY(), DOUBLE_TOLERANCE);
    Assert.assertEquals(1.8935696632026553E7, mapMaxExtent.getWidth(), DOUBLE_TOLERANCE);
    Assert.assertEquals(4.007501596344786E7, mapMaxExtent.getHeight(), DOUBLE_TOLERANCE);

    // user data
    ClientUserDataInfo info = mapInfo.getUserData();
    Assert.assertNotNull(info);
    Assert.assertTrue(info instanceof ClientApplicationInfo.DummyClientUserDataInfo);
View Full Code Here

Examples of org.geomajas.geometry.Bbox

  }

  private void verifyMap(ClientMapInfo mapInfo) {
    // first test base assumptions
    Layer layer = configurationService.getLayer("countries");
    Bbox configMaxExtent = layer.getLayerInfo().getMaxExtent();
    Assert.assertEquals(-85.05112877980659, configMaxExtent.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(-85.05112877980659, configMaxExtent.getY(), DOUBLE_TOLERANCE);
    Assert.assertEquals(170.102257, configMaxExtent.getWidth(), DOUBLE_TOLERANCE);
    Assert.assertEquals(170.102257, configMaxExtent.getHeight(), DOUBLE_TOLERANCE);

    // now test the map conversion

    Assert.assertNotNull(mapInfo);
    Bbox mapMaxExtent = mapInfo.getLayers().get(0).getMaxExtent();

    // these values were registered during a first run, they have *not* been externally verified
    Assert.assertEquals(-9467848.347161204, mapMaxExtent.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(-2.0037508342789236E7, mapMaxExtent.getY(), DOUBLE_TOLERANCE);
    Assert.assertEquals(1.8935696632026553E7, mapMaxExtent.getWidth(), DOUBLE_TOLERANCE);
    Assert.assertEquals(4.007501596344786E7, mapMaxExtent.getHeight(), DOUBLE_TOLERANCE);

    // user data
    ClientUserDataInfo info = mapInfo.getUserData();
    Assert.assertNotNull(info);
    Assert.assertTrue(info instanceof ClientApplicationInfo.DummyClientUserDataInfo);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.