Package org.geotools.coverage

Examples of org.geotools.coverage.Category


              double maximum,
              double scale,
              double offset,
              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;
            this.bkg=new Category("Background", GeoTiffUtils.TRANSPARENT, 0);
          }
View Full Code Here


    // getting categories
    final List oldCategories = visibleSD.getCategories();

    // removing old nodata category
    // candidate
    Category candidate = null;
    NumberRange candidateRange = null;
    final Iterator it = oldCategories.iterator();

    while (it.hasNext()) {
      candidate = (Category) it.next();

      // removing candidate for NaN
      if (candidate.getName().toString().equalsIgnoreCase("no data")) {
        candidateRange = candidate.getRange();

        break;
      }
    }
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

        double maximum,
        double scale,
        double offset,
        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;
      this.bkg=new Category("Background", Utils.TRANSPARENT, 0);
    }
View Full Code Here

                    colors[i][1] = colors[i][0];
                }
                // System.out.println("Processing colorrule: " + colorRule);
            }

            Category noData = new Category("novalue", new Color(Color.WHITE.getRed(), Color.WHITE //$NON-NLS-1$
                    .getGreen(), Color.WHITE.getBlue(), 0), 0);
            catsList.add(noData);

            double a = (values[values.length - 1][1] - values[0][0]) / (double) (COLORNUM - 1);
            double pmin = 1.0;
            double scale = a;
            if (scale == 0) {
                scale = 1;
            }
            double offSet = values[0][0] - scale * pmin;

            int previousUpper = -Integer.MAX_VALUE;
            for( int i = 0; i < rulesNum; i++ ) {
                StringBuilder sB = new StringBuilder();
                sB.append(name);
                sB.append("_"); //$NON-NLS-1$
                sB.append(i);

                double tmpLower = values[i][0];
                double tmpUpper = values[i][1];
                int lower = (int) ((tmpLower - values[0][0]) / scale + pmin);
                int upper = (int) ((tmpUpper - values[0][0]) / scale + pmin);
                if (lower <= previousUpper) {
                    lower = previousUpper + 1;
                }
                if (lower >= upper) {
                    upper = lower + 1;
                }
                previousUpper = upper;

                Category dataCategory = new Category(sB.toString(), colors[i], lower, upper, scale, offSet);

                catsList.add(dataCategory);
            }

            Category[] array = (Category[]) catsList.toArray(new Category[catsList.size()]);
View Full Code Here

      double[] bkg=CoverageUtilities.getBackgroundValues(gc);
      assertEquals(1, bkg.length);
      assertEquals(Double.valueOf(-9999.0), bkg[0]);
     
      // test grid sampledimension no data property
      final Category noDataCategory= new Category(CoverageUtilities.NODATA,new Color[]{Color.black},NumberRange.create(Double.valueOf(-9999.0),Double.valueOf(-9999.0)),NumberRange.create(Double.valueOf(-9999.0),Double.valueOf(-9999.0)));
      final GridSampleDimension gsd = new GridSampleDimension("test", new Category[]{noDataCategory},Unit.ONE);
      gc= CoverageFactoryFinder.getGridCoverageFactory(null).
      create(
          "test",
          ImageFunctionDescriptor.create(new MyImageFunction(), Integer.valueOf(800), Integer.valueOf(600), Float.valueOf(1.0f),  Float.valueOf(1.0f),  Float.valueOf(0.0f),  Float.valueOf(0.0f), null),
View Full Code Here

        final ColorModel cm=image.getColorModel();
                final int numBands = sm.getNumBands();
                final GridSampleDimension[] bands = new GridSampleDimension[numBands];
                // setting bands names.
               
                Category nan = null;
                if (!Double.isInfinite(noData)){
                    nan = new Category(Vocabulary
                            .formatInternational(VocabularyKeys.NODATA), new Color[] { new Color(0, 0, 0, 0) }, NumberRange
                            .create(noData, noData), NumberRange
                            .create(noData, noData));
                }
               
View Full Code Here

                .getSampleDimension(0);
        final List<Category> categories = sd.getCategories();
        double inNoData = Double.NaN;
        if (categories != null) {
            final Iterator<Category> it = categories.iterator();
            Category candidate;
            final String noDataName = Vocabulary.format(VocabularyKeys.NODATA);
            while (it.hasNext()) {
                candidate = (Category) it.next();
                final String name = candidate.getName().toString();
                if (name.equalsIgnoreCase("No Data")
                        || name.equalsIgnoreCase(noDataName)) {
                    inNoData = candidate.getRange().getMaximum();
                }
            }
        }
        return inNoData;
    }
View Full Code Here

                            lower = sample + 1;
                        } else {
                            upper = sample;
                        }
                    }
                    categories[i++] = new Category(entry.getValue(), null, sample);
                }
                range = NumberRange.create(lower, true, upper, false);
                categories[i] = new Category(name, null, range, (transform != null) ?
                                             transform : LinearTransform1D.IDENTITY);
                sampleDimension = new GridSampleDimension(name, categories, units);
            }
            return sampleDimension;
        }
View Full Code Here

     * This implementation computes the expected gradient range from the two
     * masks and the value range in the source grid coverage.
     */
    protected Category deriveCategory(final Category[] categories, final Parameters parameters) {
        NumberRange          range = null;
        Category          category = categories[0];
        final NumberRange  samples = category.geophysics(false).getRange();
        final boolean isGeophysics = (category == category.geophysics(true));
        /*
         * Computes a default range of output values one from the normalized kernels.
         * The normalization has been done by 'deriveGridCoverage' before this method
         * is invoked. The algorithm is as below:
         *
         * - Computes the value produced by the kernels for an artificial gradient of 1 unit/pixel.
         * - Transforms into a lower gradient of 1 unit/(kernel size).
         * - Transforms into a gradient of (maximal range)/(kernel size).
         * - Applies an arbitrary correction factor for more convenient range in most cases.
         */
        final ParameterList block = parameters.parameters;
        final KernelJAI mask1 = (KernelJAI) block.getObjectParameter("Mask1");
        final KernelJAI mask2 = (KernelJAI) block.getObjectParameter("Mask2");
        final double size = (mask1.getWidth() + mask1.getHeight() +
                             mask2.getWidth() + mask2.getHeight()) / 4.0;
        double factor = getNormalizationFactor(mask1, mask2) / (size-1);
        if (factor>0 && !Double.isInfinite(factor)) {
            range = category.geophysics(true).getRange();
            final double minimum = range.getMinimum();
            final double maximum = range.getMaximum();
            factor *= (maximum - minimum) * DEFAULT_RANGE_SCALE;
            range = NumberRange.create(0, factor);
        }
        if (range != null) {
            category = new Category(category.getName(), DEFAULT_COLOR_PALETTE, samples, range);
            return category.geophysics(isGeophysics);
        }
        return super.deriveCategory(categories, parameters);
    }
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.