Package org.geotools.coverage

Examples of org.geotools.coverage.Category


                categoryXS[i] = categoryArray[indexOfQuantitative];
            }
            if (categoryArray == null) {
                continue;
            }
            final Category oldCategory = categoryArray[indexOfQuantitative];
            final Unit<?>  oldUnit     = sampleDim.getUnits();
            final Category newCategory = deriveCategory(categoryXS, parameters);
            final Unit<?>  newUnit     = deriveUnit(unitXS, parameters);
            if (newCategory == null) {
                return null;
            }
            if (!oldCategory.equals(newCategory) || !Utilities.equals(oldUnit, newUnit)) {
View Full Code Here


            }
            ranges[i] = categories[i].getRange();
        }
        final NumberRange range = deriveRange(ranges, parameters);
        if (range != null) {
            final Category category = categories[PRIMARY_SOURCE_INDEX];
            return new Category(category.getName(), category.getColors(),
                                category.geophysics(false).getRange(), range).geophysics(true);
        }
        return null;
    }
View Full Code Here

        final BufferedImage      image;  // The GridCoverage's data.
        final WritableRaster    raster;  // The image's data as a raster.
        final Rectangle2D       bounds;  // The GridCoverage's envelope.
        final GridSampleDimension band;  // The only image's band.
        band = new GridSampleDimension("Temperature", new Category[] {
            new Category("No data",     null, 0),
            new Category("Land",        null, 1),
            new Category("Cloud",       null, 2),
            new Category("Temperature", null, BEGIN_VALID, 256, SCALE, OFFSET)
        }, CELSIUS);
        image  = new BufferedImage(120, 80, BufferedImage.TYPE_BYTE_INDEXED);
        raster = image.getRaster();
        for (int i=raster.getWidth(); --i>=0;) {
            for (int j=raster.getHeight(); --j>=0;) {
View Full Code Here

        // no data management
        final GridSampleDimension sd = (GridSampleDimension) gc.getSampleDimension(0);
        final List<Category> categories = sd.getCategories();
        double inNoData = Double.NaN;
        if (categories != null) {
            Category candidate;
            final String noDataName = Vocabulary.format(VocabularyKeys.NODATA);
            for (Category category : categories) {
                candidate = category;
                final String name = candidate.getName().toString();
                if (name.equalsIgnoreCase("No Data") || name.equalsIgnoreCase(noDataName)) {
                    inNoData = candidate.getRange().getMaximum();
                    break;
                }
            }
        }
        return inNoData;
View Full Code Here

    } catch (ParseException ex1) {
      uom = null;
    }

   
    final Category nan =
        new Category(Vocabulary.format(VocabularyKeys.NODATA), new Color[] { new Color(0, 0, 0, 0) },
        NumberRange.create(0, 0), NumberRange.create((short) -9999,
            (short) -9999));
    final GridSampleDimension band = new GridSampleDimension(
        "digital-elevation", new Category[] { nan }, uom);
View Full Code Here

        final ColorModel cm = image.getColorModel();
        final int numBands = sm.getNumBands();
        final GridSampleDimension[] bands = new GridSampleDimension[numBands];
        // setting bands names.

        Category noDataCategory = null;
        final Map<String, Double> properties = new HashMap<String, Double>();       
        if (!Double.isNaN(noData)) {
            noDataCategory = new Category(
                    Vocabulary.formatInternational(VocabularyKeys.NODATA),
                    new Color[] { new Color(0, 0, 0, 0) }, NumberRange.create(
                            noData, noData), NumberRange.create(noData, noData));
            properties.put("GC_NODATA", new Double(noData));
        }
View Full Code Here

        final double offset,
        final Unit<?> unit ) {
      super(
          description,
          !Double.isNaN(nodata) ? new Category[] {
            new Category(
                Vocabulary.formatInternational(VocabularyKeys.NODATA),
                new Color[] {
                  new Color(
                      0,
                      0,
                      0,
                      0)
                },
                NumberRange.create(
                    nodata,
                    nodata),
                NumberRange.create(
                    nodata,
                    nodata))
          } : null,
          unit);
      this.nodata = nodata;
      this.minimum = minimum;
      this.maximum = maximum;
      this.scale = scale;
      this.offset = offset;
      this.unit = unit;
      this.type = type;
      this.color = color;
      bkg = new Category(
          "Background",
          TRANSPARENT,
          0);
    }
View Full Code Here

            boolean nodataConfigured = configuredNoDataValues != null
                    && configuredNoDataValues.length > 0;
            // custom categories
            if (categories != null) {
                this.customCategories = new ArrayList<Category>(categories.size());
                Category wrapped = null;
                for (Category category : categories) {
                    wrapped = category;
                    if (Category.NODATA.getName().equals(category.getName())) {
                        if (category.isQuantitative()) {
                            // Get minimum and maximum value
                            double minimum = nodataConfigured ? configuredNoDataValues[0]
                                    : category.getRange().getMinimum();
                            double maximum = nodataConfigured ? configuredNoDataValues[0]
                                    : category.getRange().getMaximum();
                            if (Double.isNaN(minimum) && Double.isNaN(maximum)) {
                                // Create a qualitative category
                                wrapped = new Category(Category.NODATA.getName(),
                                        category.getColors()[0], minimum);
                            } else {
                                // Create the wrapped category
                                wrapped = new Category(Category.NODATA.getName(),
                                        category.getColors(), NumberRange.create(minimum, maximum),
                                        category.getSampleToGeophysics());
                            }
                        }
                    }
View Full Code Here

        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()));

        // Check if it contains sampleToGeophisics and the Range contains the first nodata defined
        assertNotNull(category.getSampleToGeophysics());
        assertEquals(category.geophysics(true).getRange().getMinimum(), noData1, DELTA);
        assertEquals(category.geophysics(true).getRange().getMaximum(), noData1, DELTA);
    }
View Full Code Here

            final List<Category> categories = sd[i].getCategories();
            if (categories != null && categories.size() >= 1) {
        writer.write("<nullValues>\n");
        for (Iterator<Category> it = sd[i].getCategories().iterator(); it
            .hasNext();) {
          Category cat = (Category) it.next();
          if ((cat != null)
              && cat.getName().toString().equalsIgnoreCase(
                  "no data")) {
            double min = cat.getRange().getMinimum();
            double max = cat.getRange().getMaximum();
            writer.write("<value>" + min + "</value>\n");
            if (min != max)
              writer.write("<value>" + max + "</value>\n");
          }
        }
View Full Code Here

TOP

Related Classes of org.geotools.coverage.Category

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.