Examples of NumberRange


Examples of org.geotools.util.NumberRange

    /**
     * Returns the expected range of values for the resulting image.
     */
    protected NumberRange deriveRange(final NumberRange[] ranges, final Parameters parameters) {
        final NumberRange range = ranges[0];
        final double min = -range.getMaximum();
        final double max = -range.getMinimum();
        return NumberRange.create(min, max);
    }
View Full Code Here

Examples of org.geotools.util.NumberRange

                         * - In "geophysics to packed" transform, we can still use "Rescale"
                         *   if the NaN value maps to 0.
                         */
                        if (toGeo) {
                            canRescale = false;
                            final NumberRange target = sourceCategory.geophysics(true).getRange();
                            offset = target.getMinimum();
                            if (Double.doubleToRawLongBits(offset) != Double.doubleToRawLongBits(target.getMaximum())) {
                                canPiecewise = false;
                                break testLinear;
                            }
                            scale = 0;
                        } else {
                            canPiecewise = false;
                            assert !packedCategory.equals(sourceCategory) : packedCategory;
                            final NumberRange range = packedCategory.getRange();
                            if (range.getMinimum(true) == 0 && range.getMaximum(true) == 0) {
                                assert isNaN(sourceCategory.getRange().getMinimum()) : sourceCategory;
                                conditional = true;
                                continue;
                            }
                            canRescale = false;
                            break testLinear;
                        }
                    } else {
                        if (!toGeo) {
                            // We are going to convert geophysics values to packed ones.
                            transform = transform.inverse();
                        }
                        offset = transform.transform(0);
                        scale  = transform.derivative(Double.NaN);
                        if (isNaN(scale) || isNaN(offset)) {
                            // One category doesn't use a linear transformation. We can't deal with
                            // that with "Rescale" or "Piecewise". Fallback on our "SampleTranscode".
                            canRescale   = false;
                            canPiecewise = false;
                            break testLinear;
                        }
                    }
                    // Allocates arrays the first time the loop is run up to this point.
                    // Store scale and offset, and check if they still the same.
                    if (j == 0) {
                        if (i == 0) {
                            scales      = new double[numBands];
                            offsets     = new double[numBands];
                            breakpoints = new float [numBands][][];
                        }
                        sourceBreakpoints = new float[numCategories * 2];
                        targetBreakpoints = new float[numCategories * 2];
                        breakpoints[i] = new float[][] {sourceBreakpoints, targetBreakpoints};
                        offsets    [i] = offset;
                        scales     [i] = scale;
                    }
                    if (offset!=offsets[i] || scale!=scales[i]) {
                        canRescale = false;
                    }
                    // Computes breakpoints.
                    final NumberRange range = sourceCategory.getRange();
                    final double    minimum = range.getMinimum(true);
                    final double    maximum = range.getMaximum(true);
                    final float   sourceMin = (float) minimum;
                    final float   sourceMax = (float) maximum;
                    final float   targetMin = (float)(minimum * scale + offset);
                    final float   targetMax = (float)(maximum * scale + offset);
                    assert sourceMin <= sourceMax : range;
                    if (Math.abs(minimum - expectedSource) <= EPS) {
                        if (Math.abs(targetMin - expectedTarget) <= EPS || isNaN(expectedTarget)) {
                            /*
                             * This breakpoint is identical to the previous one. Do not duplicate;
                             * overwrites the previous breakpoint since the later is likely to be
                             * more accurate. Note that we accept NaN in expected (not calculated)
                             * target values but not in source values, because "Piecewise" performs
                             * its search on source values, wich must be monotonically increasing.
                             */
                            jbp--;
                        } else {
                            // Found a discontinuity!!! The "piecewise" operation is not really
                            // designed for such case. The behavior between the last breakpoint
                            // and the current one may not be what the user expected.
                            assert sourceBreakpoints[jbp-1] < sourceMin : expectedSource;
                            canPiecewise = false;
                        }
                    } else if (j != 0) {
                        // Found a gap between the last category and the current one. But the
                        // piecewise operation still work as expected for values not in the gap.
                        assert !(expectedSource > sourceMin) : expectedSource;
                    }
                    sourceBreakpoints[jbp  ] = sourceMin;
                    sourceBreakpoints[jbp+1] = sourceMax;
                    targetBreakpoints[jbp  ] = targetMin;
                    targetBreakpoints[jbp+1] = targetMax;
                    jbp += 2;
                    expectedSource = range.getMaximum(false);
                    expectedTarget = expectedSource * scale + offset;
                }
                breakpoints[i][0] = sourceBreakpoints = XArray.resize(sourceBreakpoints, jbp);
                breakpoints[i][1] = targetBreakpoints = XArray.resize(targetBreakpoints, jbp);
                assert XArray.isSorted(sourceBreakpoints);
View Full Code Here

Examples of org.geotools.util.NumberRange

        // /////////////////////////////////////////////////////////////////////
        final Style style = currLayer.getStyle();
        final FeatureSource featureSource = currLayer.getFeatureSource();

        final CoordinateReferenceSystem sourceCrs;
        final NumberRange scaleRange = NumberRange.create(scaleDenominator,scaleDenominator);
        final ArrayList<LiteFeatureTypeStyle> lfts ;

        if ( featureSource != null ) {
            FeatureCollection features = null;
            final FeatureType schema = featureSource.getSchema();
View Full Code Here

Examples of org.geotools.util.NumberRange

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

    // new no data category
    final double oldNoData = candidateRange.getMinimum();
    final ParameterBlockJAI pbjM = new ParameterBlockJAI(
        "org.geotools.gce.gtopo30.NoDataReplacer");
    pbjM.addSource(image);
    pbjM.setParameter("oldNoData", oldNoData);
    image = JAI.create("org.geotools.gce.gtopo30.NoDataReplacer", pbjM,
View Full Code Here

Examples of org.geotools.util.NumberRange

                List<Range<Double>> novalueRangeList = null;
                if (categories != null) {
                    for (Category category : categories) {
                        String catName = category.getName().toString();
                        if (catName.equalsIgnoreCase("no data")) {
                            NumberRange range = category.getRange();
                            double min = range.getMinimum();
                            double max = category.getRange().getMaximum();
                            if (!Double.isNaN(min) && !Double.isNaN(max)) {
                                // we have to filter those out
                                Range<Double> novalueRange = new Range<Double>(min, true, max, true);
                                novalueRangeList = new ArrayList<Range<Double>>();
View Full Code Here

Examples of org.geotools.util.NumberRange

        NumberRange<?> range = null;
        for (E element:elements) {
          final NumberRange<? extends Number> extent =  element.getRange();
          if (!Double.isNaN(extent.getMinimum())&& !Double.isNaN(extent.getMaximum())) {
            if (range != null) {
              range = new NumberRange(range.union(extent));
            } else {
              range = extent;
            }
          }
        }
View Full Code Here

Examples of org.geotools.util.NumberRange

            if (categories[i] == null) {
                continue;
            }
            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);
        }
View Full Code Here

Examples of org.geotools.util.NumberRange

     */
    protected NumberRange deriveRange(final NumberRange[] ranges, final Parameters parameters) {
        final double[] constants = (double[]) parameters.parameters.getObjectParameter("constants");
        if (constants.length == 1) {
            final double c = constants[0];
            final NumberRange range = ranges[0];
            final double min = range.getMinimum() + c;
            final double max = range.getMaximum() + c;
            return NumberRange.create(min, max);
        }
        return super.deriveRange(ranges, parameters);
    }
View Full Code Here

Examples of org.geotools.util.NumberRange

    protected NumberRange deriveRange(final NumberRange[] ranges, final Parameters parameters) {
       
        // Note that they will not be exact ranges since this will require really computing
        // the pixel by pixel operation
        if (ranges != null && ranges.length == 2){
            final NumberRange range0 = ranges[0];
            final NumberRange range1 = ranges[1];
            final double min0 = range0.getMinimum();
            final double min1 = range1.getMinimum();
            final double max0 = range0.getMaximum();
            final double max1 = range1.getMaximum();
            final double max = max0 * max1;
            final double min = min0 * min1;
            return NumberRange.create(min, max);
        }
        return null;
View Full Code Here

Examples of org.geotools.util.NumberRange

     * Derives the quantitative category for a band in the destination image.
     * 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:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.