Package org.geotools.coverage

Examples of org.geotools.coverage.GridSampleDimension


         */
        public void handleSampleDimensionRange(SampleDimension sd) {
            // look for ranges on the sample dimension
            boolean setRange = false;
            if (sd instanceof GridSampleDimension) {
                GridSampleDimension gridSd = ((GridSampleDimension) sd);
                setRange = setRange(gridSd.getRange());
            }
            if (!setRange) {
                // fallback on sampleDimensionType
                SampleDimensionType sdType = sd.getSampleDimensionType();
                handleSampleDimensionType(sdType);
View Full Code Here


        final int length = sampleDimensions.length;
        List<CoverageDimensionInfo> dims = new ArrayList<CoverageDimensionInfo>();

        for (int i = 0; i < length; i++) {
            CoverageDimensionInfo dim = catalog.getFactory().createCoverageDimension();
            GridSampleDimension sd = sampleDimensions[i];
            String name = sd.getDescription().toString(Locale.getDefault());
            dim.setName(name);

            StringBuilder label = new StringBuilder("GridSampleDimension".intern());
            final Unit uom = sd.getUnits();

            String uName = name.toUpperCase();
            if (uom != null) {
                label.append("(".intern());
                parseUOM(label, uom);
                label.append(")".intern());
                dim.setUnit(uom.toString());
            } else if(uName.startsWith("RED") || uName.startsWith("GREEN") || uName.startsWith("BLUE")) {
                // radiance in SI
                dim.setUnit("W.m-2.Sr-1");
            }
           
            dim.setDimensionType(sd.getSampleDimensionType());

            label.append("[".intern());
            label.append(sd.getMinimumValue());
            label.append(",".intern());
            label.append(sd.getMaximumValue());
            label.append("]".intern());

            dim.setDescription(label.toString());

            if (sd.getRange() != null) {
                dim.setRange(sd.getRange());   
            }
            else {
                dim.setRange(NumberRange.create(sd.getMinimumValue(), sd.getMaximumValue()));
            }
           
            final List<Category> categories = sd.getCategories();
            if (categories != null) {
                for (Category cat : categories) {

                    if ((cat != null) && cat.getName().toString().equalsIgnoreCase("no data")) {
                        double min = cat.getRange().getMinimum();
View Full Code Here

               
                // loop
                boolean add=false;
                for(SampleDimension sd: bands){
                    if(sd instanceof GridSampleDimension){
                        final GridSampleDimension band=(GridSampleDimension) sd;
                        final String name=band.getDescription().toString();
                        if(name.equals(startRangeComponent)){
                            returnValue.add(startRangeComponent);
                            add=true;
                        } else if(name.equals(endRangeComponent)){
                            returnValue.add(endRangeComponent);
View Full Code Here

     * configured on the {@link CoverageDimensionInfo} object used to customize them 
     * @throws IOException
     */
    @Test
    public void testDimensionsWrapping() throws IOException {
        final GridSampleDimension sampleDim = new GridSampleDimension("original",
                SampleDimensionType.REAL_64BITS, ColorInterpretation.GRAY_INDEX,
                null, null, new double[]{-9999.0}, -1000d, 1000d, 1d, 0d, null);

        // Setting coverage dimension
        final CoverageDimensionImpl coverageDim = new CoverageDimensionImpl();
View Full Code Here

        nullValues.add(noData1);
        nullValues.add(noData2);
        coverageDim.setNullValues(nullValues);

        // Qualitative nodata category
        GridSampleDimension sampleDim = new GridSampleDimension("original",
                new Category[] { new Category(
                        Vocabulary.formatInternational(VocabularyKeys.NODATA),
                        new Color(0, 0, 0, 0), 0) }, null);

        // Wrap the dimension
        GridSampleDimension wrappedDim = new WrappedSampleDimension(sampleDim, coverageDim);

        // Ensure nodata are correct
        double[] noData = wrappedDim.getNoDataValues();
        assertEquals(2, noData.length);
        assertEquals(noData1, noData[0], DELTA);
        assertEquals(noData2, noData[1], DELTA);

        // Extract categories
        List<Category> categories = wrappedDim.getCategories();

        // Ensure NoData Category is present
        Category category = categories.get(0);
        assertTrue(category.getName().equals(Category.NODATA.getName()));

        // Check that it does not contain sampleToGeophisics and that the Range contains only NaN
        assertNull(category.getSampleToGeophysics());
        assertEquals(category.geophysics(true).getRange().getMinimum(), Double.NaN, DELTA);
        assertEquals(category.geophysics(true).getRange().getMaximum(), Double.NaN, DELTA);

        // Quantitative nodata category
        sampleDim = new GridSampleDimension("original", new Category[] { new Category(
                Vocabulary.formatInternational(VocabularyKeys.NODATA), new Color[] { new Color(0,
                        0, 0, 0) }, NumberRange.create(-9999, -9999), NumberRange.create(-9999,
                        -9999)) }, null);

        // Wrap the dimension
        wrappedDim = new WrappedSampleDimension(sampleDim, coverageDim);

        // Ensure nodata are correct
        noData = wrappedDim.getNoDataValues();
        assertEquals(2, noData.length);
        assertEquals(noData1, noData[0], DELTA);
        assertEquals(noData2, noData[1], DELTA);

        // Extract categories
        categories = wrappedDim.getCategories();

        // Ensure NoData Category is present
        category = categories.get(0);
        assertTrue(category.getName().equals(Category.NODATA.getName()));
View Full Code Here

     *
     * @throws IOException
     */
    @Test
    public void testNoRange() throws IOException {
        GridSampleDimension sampleDim = new GridSampleDimension("original",
                SampleDimensionType.REAL_64BITS, ColorInterpretation.GRAY_INDEX, null, null,
                new double[] { -9999.0 }, -1000d, 1000d, 1d, 0d, null);

        // Setting coverage dimension
        final CoverageDimensionImpl coverageDim = new CoverageDimensionImpl();
        final String wrappedName = "wrapped";
        coverageDim.setName(wrappedName);
        coverageDim.setDimensionType(SampleDimensionType.REAL_64BITS);
        // Creation of the WrappedSampleDimension
        SampleDimension wrappedDim = new WrappedSampleDimension(sampleDim, coverageDim);
        // Get the range
        NumberRange<? extends Number> wrappedRange = ((WrappedSampleDimension) wrappedDim)
                .getRange();
        // Ensure the range is not present
        assertNull(wrappedRange);
        // Check if min and max are taken from the categories
        assertEquals(-9999, wrappedDim.getMinimumValue(), DELTA);
        assertEquals(1000, wrappedDim.getMaximumValue(), DELTA);
        // Check that the description is equal to the sample dimension name
        assertEquals(wrappedName, wrappedDim.getDescription().toString());

        // Configure a new GridSampleDimension without categories
        sampleDim = new GridSampleDimension("original", null, new BaseUnit<Quantity>("test"));
        // New wrapped sample dimension
        wrappedDim = new WrappedSampleDimension(sampleDim, coverageDim);
        // Get the range
        wrappedRange = ((WrappedSampleDimension) wrappedDim).getRange();
        // Ensure the range is not present
View Full Code Here

                // we return a multiband coverage that uses the original ones as sources
                final ImageWorker worker= new ImageWorker(returnValues.get(0).getRenderedImage());
                for(int i=1;i<size;i++){
                    worker.addBand(returnValues.get(i).getRenderedImage(), false);
                }
                final GridSampleDimension sds[]= new GridSampleDimension[size];
                Arrays.fill(sds, returnValues.get(0).getSampleDimensions()[0]);
                return new GridCoverageFactory().create(
                        "result",
                        worker.getRenderedImage(),
                        returnValues.get(0).getEnvelope(),
View Full Code Here

                NumberRange.create(DEFAULT_NODATA, DEFAULT_NODATA));
        Category[] categories = new Category[] { noDataCategory };
        GridSampleDimension[] bands;
        bands = new GridSampleDimension[1];
        bands[0] =
            new GridSampleDimension(null, categories, null).geophysics(true);
        final Map<String, Double> properties = new HashMap<String, Double>();
        properties.put("GC_NODATA", DEFAULT_NODATA);
        return this.coverageFactory.create(name, image, this.originalEnvelope,
                                           bands, null, properties);
    }
View Full Code Here

        GridCoverageReader reader = null;
        GridCoverage2D coverage = null;
        try {
            reader = catalog.getResourcePool().getGridCoverageReader(coverageStore, "tazdem", null);
            coverage = (GridCoverage2D) reader.read("tazdem", null);
            GridSampleDimension sampleDim = (GridSampleDimension) coverage.getSampleDimension(0);
            double[] noDataValues = sampleDim.getNoDataValues();
            assertEquals( -999.0, noDataValues[0], DELTA);
            range = sampleDim.getRange();
            assertEquals( -100.0, range.getMinimum(), DELTA);
            assertEquals( 1000.0, range.getMaximum(), DELTA);
        } finally {
            if (coverage != null) {
                try {
View Full Code Here

TOP

Related Classes of org.geotools.coverage.GridSampleDimension

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.