Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Envelope


    }

    List<Feature> features = new ArrayList<Feature>();

    Resolution bestResolution = getResolutionForScale(layerScale);
    RasterGrid grid = getRasterGrid(new Envelope(layerCoordinate), bestResolution.getTileWidth(),
        bestResolution.getTileHeight(), layerScale);
    int x = (int) (((layerCoordinate.x - grid.getLowerLeft().x) * bestResolution.getTileWidthPx())
        / grid.getTileWidth());
    int y = (int) (bestResolution.getTileHeightPx() - (((layerCoordinate.y - grid.getLowerLeft().y) *
        bestResolution .getTileHeightPx()) / grid.getTileHeight()));
View Full Code Here


   * @return a list of raster images that covers the bounds
   * @throws GeomajasException oops
   */
  public List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale)
      throws GeomajasException {
    Envelope layerBounds = bounds;
    double layerScale = scale;
    CrsTransform layerToMap = null;
    boolean needTransform = !crs.equals(targetCrs);

    try {
      // We don't necessarily need to split into same CRS and different CRS cases, the latter implementation uses
      // identity transform if crs's are equal for map and layer but might introduce bugs in rounding and/or
      // conversions.
      if (needTransform) {
        layerToMap = geoService.getCrsTransform(crs, targetCrs);
        CrsTransform mapToLayer = geoService.getCrsTransform(targetCrs, crs);

        // Translate the map coordinates to layer coordinates, assumes equal x-y orientation
        layerBounds = geoService.transform(bounds, mapToLayer);
        layerScale = bounds.getWidth() * scale / layerBounds.getWidth();
      }
    } catch (MismatchedDimensionException e) {
      throw new GeomajasException(e, ExceptionCode.RENDER_DIMENSION_MISMATCH);
    }
    layerBounds = clipBounds(layerBounds);
    if (layerBounds.isNull()) {
      return new ArrayList<RasterTile>(0);
    }

    // Grid is in layer coordinate space!
    Resolution bestResolution = getResolutionForScale(layerScale);
View Full Code Here

    Coordinate lowerLeft = new Coordinate(realXmin + xmin * realWidth, realYmin + ymin * realHeight);
    return new RasterGrid(lowerLeft, xmin, ymin, xmax, ymax, realWidth, realHeight);
  }

  private Envelope clipBounds(Envelope bounds) {
    Envelope maxExtent = converterService.toInternal(layerInfo.getMaxExtent());
    return bounds.intersection(maxExtent);
  }
View Full Code Here

    this.id = id;
  }

  public void execute(PipelineContext context, List<RasterTile> response) throws GeomajasException {
    RasterLayer layer = context.get(PipelineCode.LAYER_KEY, RasterLayer.class);
    Envelope bounds = context.get(PipelineCode.BOUNDS_KEY, Envelope.class);
    double scale = context.get(PipelineCode.SCALE_KEY, Double.class);
    CoordinateReferenceSystem crs = context.get(PipelineCode.CRS_KEY, CoordinateReferenceSystem.class);
    List<RasterTile> images = layer.paint(crs, bounds, scale);
    response.addAll(images);
  }
View Full Code Here

  private class TestAuthorization extends AllowAllAuthorization implements AreaAuthorization {
    private Geometry geometry;
    private boolean partly;
   
    public TestAuthorization(int which) {
      Envelope envelope;
      if (1 == which) {
        partly = false;
         envelope = new Envelope(1, 3, 1, 3);
      } else {
        partly = true;
         envelope = new Envelope(2, 4, 2, 4);
      }
      PrecisionModel precisionModel  = new PrecisionModel(PrecisionModel.FLOATING);
      GeometryFactory geometryFactory = new GeometryFactory(precisionModel, LAYER_SRID);
      geometry = geometryFactory.toGeometry(envelope);
    }
View Full Code Here

  }

  protected Geometry getAuthorizedArea(String layerId) {
    if (null == biggestGeometry) {
      // build Geometry which covers biggest possible area
      Envelope maxBounds = new Envelope(-Double.MAX_VALUE, Double.MAX_VALUE,
          -Double.MAX_VALUE, Double.MAX_VALUE);
      PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
      GeometryFactory geometryFactory = new GeometryFactory(precisionModel, 0);
      biggestGeometry = geometryFactory.toGeometry(maxBounds);
    }
View Full Code Here

  private static final double DELTA = 1e-20;

  @Test
  public void testCombine() throws Exception {
    Envelope e1 = new Envelope(10, 40, 10, 30);
    GetLocationResult glr1 = new GetLocationResult();
    glr1.setEnvelope(e1);
    Envelope e2 = new Envelope(20, 35, 25, 50);
    GetLocationResult glr2 = new GetLocationResult();
    glr2.setEnvelope(e2);
    List<GetLocationResult> list = new ArrayList<GetLocationResult>();
    list.add(glr1);
    list.add(glr2);

    CombineResultService cis = new CombineIntersectionService();
    Envelope res = cis.combine(list);
    Assert.assertEquals(20.0, res.getMinX(), DELTA);
    Assert.assertEquals(25.0, res.getMinY(), DELTA);
    Assert.assertEquals(35.0, res.getMaxX(), DELTA);
    Assert.assertEquals(30.0, res.getMaxY(), DELTA);
  }
View Full Code Here

  @Test
  public void transformEnvelopeTest() throws Exception {
    CoordinateReferenceSystem source = geoService.getCrs("EPSG:900913");
    CoordinateReferenceSystem target = geoService.getCrs("EPSG:4326");
    Envelope envelope = new Envelope(10, 20, 30, 40);
    Envelope transformed = geocoderUtilService.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);
  }
View Full Code Here

  @Test
  public void extendPointTest() throws Exception {
    CoordinateReferenceSystem crs;
    Coordinate coordinate;
    Envelope envelope;

    crs = geoService.getCrs("EPSG:900913");
    coordinate = new Coordinate(0, 0);
    envelope = geocoderUtilService.extendPoint(coordinate, crs, 200, 100);
    Assert.assertEquals(-100.00000376900834, envelope.getMinX(), DELTA);
    Assert.assertEquals(-50.33697512339748, envelope.getMinY(), DELTA);
    Assert.assertEquals(100.00000376900834, envelope.getMaxX(), DELTA);
    Assert.assertEquals(50.33697512339748, envelope.getMaxY(), DELTA);

    coordinate = new Coordinate(10000, 10000);
    envelope = geocoderUtilService.extendPoint(coordinate, crs, 200, 100);
    Assert.assertEquals(9899.999874146251, envelope.getMinX(), DELTA);
    Assert.assertEquals(9949.6629648107, envelope.getMinY(), DELTA);
    Assert.assertEquals(10100.000125853749, envelope.getMaxX(), DELTA);
    Assert.assertEquals(10050.3370351893, envelope.getMaxY(), DELTA);

    crs = geoService.getCrs("EPSG:4326");
    coordinate = new Coordinate(0, 0);
    envelope = geocoderUtilService.extendPoint(coordinate, crs, 200, 100);
    Assert.assertEquals(-8.983152841199021E-4, envelope.getMinX(), DELTA);
    Assert.assertEquals(-4.5218473391466234E-4, envelope.getMinY(), DELTA);
    Assert.assertEquals(8.983152841199021E-4, envelope.getMaxX(), DELTA);
    Assert.assertEquals(4.5218473391466234E-4, envelope.getMaxY(), DELTA);

    coordinate = new Coordinate(100, 50);
    envelope = geocoderUtilService.extendPoint(coordinate, crs, 200, 100);
    Assert.assertEquals(99.99860521715158, envelope.getMinX(), DELTA);
    Assert.assertEquals(49.99955048109636, envelope.getMinY(), DELTA);
    Assert.assertEquals(100.00139478284842, envelope.getMaxX(), DELTA);
    Assert.assertEquals(50.00044951890364, envelope.getMaxY(), DELTA);
  }
View Full Code Here

      List<StyleFilter> styleFilters = context.getOptional(GetFeaturesStyleStep.STYLE_FILTERS_KEY, List.class);

      if (log.isDebugEnabled()) {
        log.debug("getElements " + filter + ", offset = " + offset + ", maxResultSize= " + maxResultSize);
      }
      Envelope bounds = null;
      Iterator<?> it = layer.getElements(filter, 0, 0); // do not limit result here, security needs to be applied

      int count = 0;
      while (it.hasNext()) {
        log.debug("process feature");
        Object featureObj = it.next();
        Geometry geometry = layer.getFeatureModel().getGeometry(featureObj);
        InternalFeature feature = convertFeature(featureObj, geometry, layer, transformation,
            styleFilters, style.getLabelStyle(), featureIncludes);
        if (null != feature) {
          count++;
          if (count > offset) {
            features.add(feature);

            if (null != geometry) {
              Envelope envelope = geometry.getEnvelopeInternal();
              if (null == bounds) {
                bounds = new Envelope();
              }
              bounds.expandToInclude(envelope);
            }

            if (features.size() == maxResultSize) {
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.