Package org.geomajas.geometry

Examples of org.geomajas.geometry.Bbox


    geo.setLayerType(LayerType.POLYGON);

    ClientMapInfo mapInfo = new ClientMapInfo();
    mapInfo.setCrs("EPSG:4326");
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(new Bbox(0, 0, 100, 100));
    mapRasterizingInfo.setScale(1);
    mapRasterizingInfo.setTransparent(true);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);

    DefaultMapContext mapContext = new DefaultMapContext();
View Full Code Here


    }
    org.geomajas.geometry.Coordinate requestLocation = request.getLocation();
    if (null == requestLocation) {
      throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "location");
    }
    Bbox mapBounds = request.getMapBounds();
    if (null == mapBounds) {
      throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "mapBounds");
    }

    Coordinate coordinate = new Coordinate(requestLocation.getX(), requestLocation.getY());
View Full Code Here

      // identity transform if CRSs are equal for map and layer but might introduce bugs in rounding and/or
      // conversions.
      if (!mapCrs.equals(layerCrs)) {

        // Translate the map coordinates to layer coordinates, assumes equal x-y orientation
        Bbox layerBounds = geoService.transform(mapBounds, mapCrs, layerCrs);
        layerScale = mapBounds.getWidth() * mapScale / layerBounds.getWidth();
      }
    } catch (MismatchedDimensionException e) {
      throw new GeomajasException(e, ExceptionCode.RENDER_DIMENSION_MISMATCH);
    }
    return layerScale;
View Full Code Here

        Envelope transformableArea = crsTransform.getTransformableEnvelope();
        if (null != transformableArea) {
          envelope = envelope.intersection(transformableArea);
        }
        if (envelope.isNull()) {
          return new Bbox();
        } else {
          ReferencedEnvelope refEnvelope = new ReferencedEnvelope(envelope, crsTransform.getSource());
          envelope = refEnvelope.transform(crsTransform.getTarget(), true);
          return new Bbox(envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight());
        }
      } else {
        return source;
      }
    } catch (Exception e) { // typically TopologyException, TransformException or FactoryException, but be safe
      log.warn("Problem during transformation " + crsTransform.getId() + "of " + source
          + ", maybe you need to configure the transformable area using a CrsTransformInfo object for this "
          + "transformation. Object replaced by empty Bbox.", e);
      return new Bbox();
    }
  }
View Full Code Here

          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);
          int imageWidth = configurationService.getRasterLayerInfo(getLayerId()).getTileWidth();
          int imageHeight = configurationService.getRasterLayerInfo(getLayerId()).getTileHeight();
          // 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() * imageWidth
                    - pixelBounds.getX();
                double yOffset = 0;
                // 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() * imageHeight
                      - pixelBounds.getY();
                } else {
                  yOffset = (float) (pixelBounds.getMaxY() - (result.getRasterImage().getCode()
                      .getY() + 1)
                      * imageHeight);
                }
                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(context, (ImageException) (e.getCause()));
              } 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(imageWidth);
            imageLayout.setTileHeight(imageHeight);

            // create the mosaic image
View Full Code Here

    }
    return false;
  }

  private Bbox getPixelBounds(List<RasterTile> tiles) {
    Bbox bounds = null;
    int imageWidth = configurationService.getRasterLayerInfo(getLayerId()).getTileWidth();
    int imageHeight = configurationService.getRasterLayerInfo(getLayerId()).getTileHeight();
    for (RasterTile tile : tiles) {
      Bbox tileBounds = new Bbox(tile.getCode().getX() * imageWidth, tile.getCode().getY() * imageHeight,
          imageWidth, imageHeight);
      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

    try {
      Crs mapCrs = geoService.getCrs2(mapCrsKey);
      Crs layerCrs = geoService.getCrs2(layerCrsKey);
      Envelope serverEnvelope = converterService.toInternal(serverBbox);
      CrsTransform transformer = geoService.getCrsTransform(layerCrs, mapCrs);
      Bbox res = converterService.toDto(geoService.transform(serverEnvelope, transformer));
      if (Double.isNaN(res.getX()) || Double.isNaN(res.getY()) || Double.isNaN(res.getWidth())
          || Double.isNaN(res.getHeight())) {
        throw new LayerException(ExceptionCode.LAYER_EXTENT_CANNOT_CONVERT, layer, mapCrsKey);
      }
      return res;
    } catch (GeomajasException e) {
      throw new LayerException(e, ExceptionCode.TRANSFORMER_CREATE_LAYER_TO_MAP_FAILED);
View Full Code Here

    }
    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

      }
    }
  }

  protected void addImage(PdfContext context, ImageResult imageResult) throws BadElementException, IOException {
    Bbox imageBounds = imageResult.getRasterImage().getBounds();
    float scaleFactor = (float) (72 / getMap().getRasterResolution());
    float width = (float) imageBounds.getWidth() * scaleFactor;
    float height = (float) imageBounds.getHeight() * scaleFactor;
    // subtract screen position of lower-left corner
    float x = (float) (imageBounds.getX() - rasterScale * bbox.getMinX()) * scaleFactor;
    // shift y to lowerleft corner, flip y to user space and subtract
    // screen position of lower-left
    // corner
    float y = (float) (-imageBounds.getY() - imageBounds.getHeight() - rasterScale * bbox.getMinY()) * scaleFactor;
    if (log.isDebugEnabled()) {
      log.debug("adding image, width=" + width + ",height=" + height + ",x=" + x + ",y=" + y);
    }
    // opacity
    log.debug("before drawImage");
View Full Code Here

        getSize(), getOpacity());
    log.debug("after drawImage");
  }

  protected void addLoadError(PdfContext context, ImageException e) {
    Bbox imageBounds = e.getRasterImage().getBounds();
    float scaleFactor = (float) (72 / getMap().getRasterResolution());
    float width = (float) imageBounds.getWidth() * scaleFactor;
    float height = (float) imageBounds.getHeight() * scaleFactor;
    // subtract screen position of lower-left corner
    float x = (float) (imageBounds.getX() - rasterScale * bbox.getMinX()) * scaleFactor;
    // shift y to lower left corner, flip y to user space and subtract
    // screen position of lower-left
    // corner
    float y = (float) (-imageBounds.getY() - imageBounds.getHeight() - rasterScale * bbox.getMinY()) * scaleFactor;
    if (log.isDebugEnabled()) {
      log.debug("adding failed message=" + width + ",height=" + height + ",x=" + x + ",y=" + y);
    }
    float textHeight = context.getTextSize("failed", ERROR_FONT).getHeight() * 3f;
    Rectangle rec = new Rectangle(x, y, x + width, y + height);
View Full Code Here

TOP

Related Classes of org.geomajas.geometry.Bbox

Copyright © 2018 www.massapicom. 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.