Package org.geotools.geometry

Examples of org.geotools.geometry.Envelope2D


        final GridCoverage2D coverage = readCoverage(reader, reqWidth, reqHeight, reqEnvelope);
        assertNotNull("read coverage returned null", coverage);

        GridGeometry2D gg = coverage.getGridGeometry();
        Envelope2D envelope2D = gg.getEnvelope2D();
        GridEnvelope gridRange = gg.getGridRange();

        System.out.println("requested size: " + reqWidth + "x" + reqHeight);
        System.out.println("result size   : " + gridRange.getSpan(0) + "x" + gridRange.getSpan(1));
View Full Code Here


        reqEnv.setEnvelope(33192.0, 774244.0, 333224.0, 962136.0);
        GridCoverage2D coverage = readCoverage(reader, reqWidth, reqHeight, reqEnv);

        GridGeometry2D gridGeometry = coverage.getGridGeometry();
        GridEnvelope gridRange = gridGeometry.getGridRange();
        Envelope2D envelope2d = gridGeometry.getEnvelope2D();

        System.out.println("requested size: " + reqWidth + "x" + reqHeight);
        System.out.println("result size   : " + gridRange.getSpan(0) + "x" + gridRange.getSpan(1));

        System.out.println("requested envelope: " + reqEnv);
View Full Code Here

        // do we need to transform the requested envelope?
        if (!CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) {
            GeneralEnvelope env = CRS.transform(envelope, DefaultGeographicCRS.WGS84);
            if (get2D) {
                requestedWGS84 = new Envelope2D(env);
                ((Envelope2D) requestedWGS84)
                        .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
            } else {
                requestedWGS84 = env;
                ((GeneralEnvelope) requestedWGS84)
                        .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
            }
            return requestedWGS84;

        } else {
            if (get2D)
                return new Envelope2D(envelope);
            else
                return new GeneralEnvelope(envelope);
        }
    }
View Full Code Here

        assertNotNull(reader);

        // ask to extract an area that is inside the coverage bbox, but in a hole (no data)
        final ParameterValue<GridGeometry2D> ggp =  AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue();
        Envelope2D env = new Envelope2D(reader.getCoordinateReferenceSystem(), 500000, 3200000, 1000, 1000);
        GridGeometry2D gg = new GridGeometry2D(new GridEnvelope2D(0, 0, 100, 100), (Envelope) env);
        ggp.setValue(gg);

        // red background
        final ParameterValue<double[]> bgp =  ImageMosaicFormat.BACKGROUND_VALUES.createValue();
View Full Code Here

        assertNotNull(reader);

        // ask to extract an area that is inside the coverage bbox, so that the area is partly
        // inside the raster, and partly outside
        final ParameterValue<GridGeometry2D> ggp =  AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue();
        Envelope2D env = new Envelope2D(reader.getCoordinateReferenceSystem(), 64887, 2499342, 646897 - 64887 , 3155705 - 2499342);
        GridGeometry2D gg = new GridGeometry2D(new GridEnvelope2D(0, 0, 100, 100), (Envelope) env);
        ggp.setValue(gg);

        // red background
        final ParameterValue<double[]> bgp =  ImageMosaicFormat.BACKGROUND_VALUES.createValue();
View Full Code Here

    @Test
    public void getEnvelope2D() {
        ReferencedEnvelope refEnv = new ReferencedEnvelope(
                -10, 10, -5, 5, DefaultGeographicCRS.WGS84);
       
        Envelope2D env2D = JTS.getEnvelope2D(refEnv, refEnv.getCoordinateReferenceSystem());
       
        CRS.equalsIgnoreMetadata(
                refEnv.getCoordinateReferenceSystem(),
                env2D.getCoordinateReferenceSystem());
       
        assertTrue(env2D.boundsEquals(refEnv, 0, 1, TOL));
    }
View Full Code Here

        final Color[] colors = new Color[]{
            Color.BLUE, Color.CYAN, Color.WHITE, Color.YELLOW, Color.RED
        };

        return factory.create("Float coverage", raster,
                new Envelope2D(DefaultGeographicCRS.WGS84, envX0, envY0, envWidth, envHeight),
                null, null,
                null, new Color[][]{colors}, null);
    }
View Full Code Here

      DefaultFilterVisitor filterVisitor = new DefaultFilterVisitor() {

    @Override
    public Object visit(BBOX filter, Object data) {
        Envelope2D envelope = (Envelope2D) data;
        filter.getBounds();
        envelope.setBounds(filter.getBounds());
        return super.visit(filter, data);
    }
   
   

    @Override
    public Object visit(Intersects filter, Object data) {
        Envelope2D envelope = (Envelope2D) data;
       
        Geometry polygon= ((Geometry)((Literal)filter.getExpression2()).getValue());
        org.opengis.geometry.Geometry polygon2 = JTSUtils.jtsToGo1(polygon, envelope.getCoordinateReferenceSystem());
        envelope.setBounds(new Envelope2D(polygon2.getEnvelope()));
        return super.visit(filter, data);
    }



    /**
     * Used by WCS 2.0 to select a time range
     */
    @Override
    public Object visit(PropertyIsGreaterThanOrEqualTo filter, Object data) {
        PropertyName prop;
        Literal lit;
        if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
      prop = (PropertyName) filter.getExpression1();
      lit = (Literal) filter.getExpression2();
        } else if (filter.getExpression2() instanceof PropertyName
          && filter.getExpression1() instanceof Literal) {
      prop = (PropertyName) filter.getExpression1();
      lit = (Literal) filter.getExpression2();
        } else {
      return super.visit(filter, data);
        }
        if (prop.getPropertyName().equals(TIME_ATTRIBUTE)) {     
      if(lit.getValue()!=null){
          beginDate.setTime(((Date) lit.getValue()).getTime());
      }
        }
        return super.visit(filter, data);
    }

    /**
     * Used by WCS 2.0 to select a time range
     */
    @Override
    public Object visit(PropertyIsLessThanOrEqualTo filter, Object data) {
        PropertyName prop;
        Literal lit;
        if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
      prop = (PropertyName) filter.getExpression1();
      lit = (Literal) filter.getExpression2();
        } else if (filter.getExpression2() instanceof PropertyName
          && filter.getExpression1() instanceof Literal) {
      prop = (PropertyName) filter.getExpression1();
      lit = (Literal) filter.getExpression2();
        } else {
      return super.visit(filter, data);
        }
        if (prop.getPropertyName().equals(TIME_ATTRIBUTE)) {
      if(lit.getValue()!=null){
          endDate.setTime(((Date) lit.getValue()).getTime());         
      }
        }
        return super.visit(filter, data);
    }

    @Override
    public Object visit(PropertyIsEqualTo filter, Object data) {
        PropertyName prop;
        Literal lit;
        if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
      prop = (PropertyName) filter.getExpression1();
      lit = (Literal) filter.getExpression2();
        } else if (filter.getExpression2() instanceof PropertyName
          && filter.getExpression1() instanceof Literal) {
      prop = (PropertyName) filter.getExpression1();
      lit = (Literal) filter.getExpression2();
        } else {
      return super.visit(filter, data);
        }
        if (prop.getPropertyName().equals(TIME_ATTRIBUTE)) {
      date.setTime(((Date) lit.getValue()).getTime());
        }
        if (prop.getPropertyName().equals(BAND_DIMENSION)) {
      band.add((String) lit.getValue());

        }
        return super.visit(filter, data);
    }

    @Override
    public Object visit(PropertyIsBetween filter, Object data) {
        PropertyName prop = (PropertyName) filter.getExpression();       
       
        if (prop.getPropertyName().equals(TIME_ATTRIBUTE)) {
      beginDate.setTime(((Date) ((Literal)filter.getLowerBoundary()).getValue()).getTime());
      endDate.setTime(((Date) ((Literal)filter.getUpperBoundary()).getValue()).getTime());
        } if (prop.getPropertyName().equals(BAND_DIMENSION)) {
      String bands = (String) ((Literal)filter.getLowerBoundary()).getValue();
      String[] singleBands = bands.split(",");
      band.addAll(Arrays.asList(singleBands));

        }
        return super.visit(filter, data);
    }

      };
      Envelope2D bbox = new Envelope2D(DefaultGeographicCRS.WGS84,-180,-90,360,180);
     
     
      query.getFilter().accept(filterVisitor, bbox);
      LOGGER.fine("Mosaic query on bbox: " + bbox);
               
      //very rudimentary filtering, for unit test only!
      if(bbox.getMaxX()<=35.){
    return wrapAndCache(Arrays.asList(feature1));
      }else{
    return wrapAndCache(Arrays.asList(feature1,feature2));
      }
     
View Full Code Here

        try {           
           
            // === slicing on Y axis
            // source
            sourceCoverage=(GridCoverage2D) this.getCatalog().getCoverageByName(LAMBERTMOSAIC.getLocalPart()).getGridCoverageReader(null, null).read(null);
            final Envelope2D sourceEnvelope = sourceCoverage.getEnvelope2D();
           
           
            // subsample using the original extension
            MockHttpServletResponse response = getAsServletResponse("wcs?request=GetCoverage&service=WCS&version=2.0.1" +
                            "&coverageId=wcs__lambert&&Format=application/custom" +
View Full Code Here

        GridEnvelope actualRange = result.getGridGeometry().getGridRange();
        assertEquals(originalRange.getSpan(0), actualRange.getSpan(0));
        assertEquals(originalRange.getSpan(1), actualRange.getSpan(1));

        // check also the geographic bounds
        Envelope2D originalEnv = original.getEnvelope2D();
        Envelope2D actualEnv = result.getEnvelope2D();
        assertEquals(originalEnv.getMinX(), actualEnv.getMinX(), 1e-6);
        assertEquals(originalEnv.getMinY(), actualEnv.getMinY(), 1e-6);
        assertEquals(originalEnv.getMaxX(), actualEnv.getMaxX(), 1e-6);
        assertEquals(originalEnv.getMaxY(), actualEnv.getMaxY(), 1e-6);

        // cleanup
        tiffFile.delete();
    }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.Envelope2D

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.