Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Envelope


    request.setTargetCrs(LONLAT);
    // execute
    TransformGeometryResponse response = (TransformGeometryResponse) dispatcher.execute(
        TransformGeometryRequest.COMMAND, request, null, "en");
    Geometry transformed = response.getGeometry();
    Envelope bounds = converterService.toInternal(transformed).getEnvelopeInternal();
    Assert.assertEquals(8.983152841195215E-5, bounds.getMinX(), DELTA);
    Assert.assertEquals(2.6949458522981454E-4, bounds.getMinY(), DELTA);
    Assert.assertEquals(1.796630568239043E-4, bounds.getMaxX(), DELTA);
    Assert.assertEquals(3.593261136397527E-4, bounds.getMaxY(), DELTA);
  }
View Full Code Here


    // execute
    TransformGeometryResponse response = (TransformGeometryResponse) dispatcher.execute(
        TransformGeometryRequest.COMMAND, request, null, "en");
    List<Geometry> transformed = response.getGeometryCollection();
    Assert.assertEquals(1, transformed.size());
    Envelope bounds = converterService.toInternal(transformed.get(0)).getEnvelopeInternal();
    Assert.assertEquals(8.983152841195215E-5, bounds.getMinX(), DELTA);
    Assert.assertEquals(2.6949458522981454E-4, bounds.getMinY(), DELTA);
    Assert.assertEquals(1.796630568239043E-4, bounds.getMaxX(), DELTA);
    Assert.assertEquals(3.593261136397527E-4, bounds.getMaxY(), DELTA);
  }
View Full Code Here

   * @return the bounds of the specified features
   */
  public Envelope getBounds(Filter queryFilter) throws LayerException {
    Iterator<?> it = getElements(queryFilter, 0, 0);
    // start with null envelope
    Envelope bounds = new Envelope();
    while (it.hasNext()) {
      Object o = it.next();
      Geometry g = featureModel.getGeometry(o);
      bounds.expandToInclude(g.getEnvelopeInternal());
    }
    return bounds;
  }
View Full Code Here

    ReferencedEnvelope metaArea = new ReferencedEnvelope(areaOfInterest);
    metaArea.expandBy(bufferInPixels / tileInpix.getWidth() * areaOfInterest.getWidth(),
        bufferInPixels / tileInpix.getHeight() * areaOfInterest.getHeight());
    // fetch features in meta area
    Crs layerCrs = vectorLayerService.getCrs(layer);
    Envelope layerBounds = geoService.transform(metaArea, (Crs) areaOfInterest.getCoordinateReferenceSystem(),
        layerCrs);
    Filter filter = filterService.createBboxFilter(layerCrs, layerBounds,
        layer.getLayerInfo().getFeatureInfo().getGeometryType().getName());
    if (extraInfo.getFilter() != null) {
      filter = filterService.createAndFilter(filter, filterService.parseFilter(extraInfo.getFilter()));
View Full Code Here

  @Test
  public void transformEnvelopeCrsTest() throws Exception {
    Crs source = geoService.getCrs2(MERCATOR);
    Crs target = geoService.getCrs2(LONLAT);
    Envelope envelope = new Envelope(10, 20, 30, 40);
    Envelope transformed = geoService.transform(envelope, source, target);
    Assert.assertEquals(8.983152841195215E-5, transformed.getMinX(), DELTA);
    Assert.assertEquals(2.6949458522981454E-4, transformed.getMinY(), DELTA);
    Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA);
    Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA);

    Assert.assertEquals(envelope, geoService.transform(envelope, source, source));
  }
View Full Code Here

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

  @Test
  public void transformEnvelopeStringTest() throws Exception {
    Envelope envelope = new Envelope(10, 20, 30, 40);
    Envelope transformed = geoService.transform(envelope, MERCATOR, LONLAT);
    Assert.assertEquals(8.983152841195215E-5, transformed.getMinX(), DELTA);
    Assert.assertEquals(2.6949458522981454E-4, transformed.getMinY(), DELTA);
    Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA);
    Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA);
  }
View Full Code Here

  }

  @Test
  public void transformEnvelopeCrsTransformTest() throws Exception {
    CrsTransform crsTransform = geoService.getCrsTransform(MERCATOR, LONLAT);
    Envelope envelope = new Envelope(10, 20, 30, 40);
    Envelope transformed = geoService.transform(envelope, crsTransform);
    Assert.assertEquals(8.983152841195215E-5, transformed.getMinX(), DELTA);
    Assert.assertEquals(2.6949458522981454E-4, transformed.getMinY(), DELTA);
    Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA);
    Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA);

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

  }

  @Test
  public void transformEnvelopeCrsNoTransformTest() throws Exception {
    CrsTransform crsTransform = geoService.getCrsTransform(MERCATOR, MERCATOR);
    Envelope envelope = new Envelope(10, 20, 30, 40);
    Envelope transformed = geoService.transform(envelope, crsTransform);
    Assert.assertEquals(10, transformed.getMinX(), DELTA);
    Assert.assertEquals(30, transformed.getMinY(), DELTA);
    Assert.assertEquals(20, transformed.getMaxX(), DELTA);
    Assert.assertEquals(40, transformed.getMaxY(), DELTA);

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

    feature.setGeometry(factory.createMultiPolygon(new Polygon[] {}));
    coordinate = geoService.calcDefaultLabelPosition(feature);
    Assert.assertNull(coordinate);

    feature.setGeometry(JTS.toGeometry(new Envelope(10, 20, 30, 40)));
    coordinate = geoService.calcDefaultLabelPosition(feature);
    // this tests current behaviour, without claims that this is the "best" (or even "good") position
    Assert.assertEquals(15.0, coordinate.x, DELTA);
    Assert.assertEquals(35.0, coordinate.y, DELTA);
View Full Code Here

  protected void addImage(Graphics2D graphics, ImageResult imageResult, MapViewport viewport) throws IOException {
    Rectangle screenArea = viewport.getScreenArea();
    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);
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.Envelope

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.