org.geotools.util.Range.getMinValue()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中org.geotools.util.Range.getMinValue方法的一些代码示例,展示了Range.getMinValue的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.getMinValue方法的具体详情如下:
包路径:org.geotools.util.Range
类名称:Range
方法名:getMinValue

Range.getMinValue介绍

[英]Returns the minimal value, or null if unbounded. If #isMinIncluded is true, then the value is considered included in the set. Otherwise it is considered excluded.
[中]返回最小值,如果是无界值,则返回null。如果#IsMinInclude为真,则该值被视为包含在集合中。否则将被视为排除在外。

代码示例

代码示例来源:origin: geoserver/geoserver

public Range getSearchRange(Object value) {
  if (value instanceof Range) {
    Range range = (Range) value;
    Range before = getSearchRangeOnSingleValue(range.getMinValue());
    Range after = getSearchRangeOnSingleValue(range.getMaxValue());
    return before.union(after);
  } else {
    return getSearchRangeOnSingleValue(value);
  }
}

代码示例来源:origin: geotools/geotools

@Override
  public int compare(Range<T> o1, Range<T> o2) {
    if (o1 == null) {
      return o2 != null ? -1 : 0;
    } else if (o2 == null) {
      return 1;
    } else if (o1.getMinValue() == null) {
      return o2.getMinValue() == null ? 0 : -1;
    } else if (o2.getMinValue() == null) {
      return 1;
    } else {
      return o1.getMinValue().compareTo(o2.getMinValue());
    }
  }
}

代码示例来源:origin: geoserver/geoserver

FF.between(
        attribute,
        FF.literal(range.getMinValue()),
        FF.literal(range.getMaxValue()));
query.setFilter(rangeFilter);

代码示例来源:origin: geotools/geotools

/** Returns the start time. */
@Override
public Date getMinValue() {
  return clone(super.getMinValue());
}

代码示例来源:origin: geotools/geotools

public SymbolizerKey(Symbolizer symbolizer, Range scaleRange) {
  this.symbolizer = symbolizer;
  if (scaleRange == null) {
    minScale = 0;
    maxScale = Double.POSITIVE_INFINITY;
  } else {
    minScale = ((Number) scaleRange.getMinValue()).doubleValue();
    maxScale = ((Number) scaleRange.getMaxValue()).doubleValue();
  }
}

代码示例来源:origin: geotools/geotools

/** Populate the set of minimal ranges as a set of Strings */
protected void populateRange() {
  Iterator<Range> iterator = set.iterator();
  while (iterator.hasNext()) {
    Range range = iterator.next();
    minimalRanges.add((range.getMinValue() + "/" + range.getMaxValue()));
  }
}

代码示例来源:origin: geotools/geotools

void setScaleRange(Style style, Range scaleRange) {
  if (scaleRange != null) {
    double min = ((Number) scaleRange.getMinValue()).doubleValue();
    double max = ((Number) scaleRange.getMaxValue()).doubleValue();
    style.setMinMaxScale(min, max);
  }
}

代码示例来源:origin: geotools/geotools

private LookupTable createLookupTableByte(List<Range<Integer>> exclusionValues, int dataType) {
  final byte[] b = new byte[256];
  Arrays.fill(b, (byte) 0);
  for (Range<Integer> exclusionValue : exclusionValues) {
    final int minValue = exclusionValue.getMinValue();
    final int maxValue = exclusionValue.getMaxValue();
    for (int i = minValue; i <= maxValue; i++) {
      b[i] = (byte) INVALID_PIXEL_I;
    }
  }
  return LookupTableFactory.create(b, dataType);
}

代码示例来源:origin: geotools/geotools

private LookupTable createLookupTableUShort(
      List<Range<Integer>> exclusionValues, int dataType) {
    final byte[] bUShort = new byte[65536];
    Arrays.fill(bUShort, (byte) 0);
    for (Range<Integer> exclusionValue : exclusionValues) {
      final int minValue = exclusionValue.getMinValue();
      final int maxValue = exclusionValue.getMaxValue();
      for (int i = minValue; i <= maxValue; i++) {
        bUShort[i] = (byte) INVALID_PIXEL_I;
      }
    }
    return LookupTableFactory.create(bUShort, dataType);
  }
}

代码示例来源:origin: geotools/geotools

private boolean contiguous(Range r1, Range<T> r2) {
  if (r1.getMinValue() != null
      && r2.getMaxValue() != null
      && (r1.isMinIncluded() || r2.isMaxIncluded())) {
    return r1.getMinValue().equals(r2.getMaxValue());
  } else if (r1.getMaxValue() != null
      && r2.getMinValue() != null
      && (r1.isMaxIncluded() || r2.isMinIncluded())) {
    return r1.getMaxValue().equals(r2.getMinValue());
  } else {
    return false;
  }
}

代码示例来源:origin: geotools/geotools

@Override
public int compare(Range<? extends Number> firstRange, Range<? extends Number> secondRange) {
  Utilities.ensureNonNull("firstRange", firstRange);
  Utilities.ensureNonNull("secondRange", secondRange);
  final Number firstRangeMin = firstRange.getMinValue();
  final Number firstRangeMax = firstRange.getMaxValue();
  final Number secondRangeMin = secondRange.getMinValue();
  final Number secondRangeMax = secondRange.getMaxValue();
  return doubleCompare(
      firstRangeMin.doubleValue(),
      firstRangeMax.doubleValue(),
      secondRangeMin.doubleValue(),
      secondRangeMax.doubleValue());
}

代码示例来源:origin: geotools/geotools

@Override
public int compare(
    Range<? extends Number> firstRange, Range<? extends Number> secondRange) {
  Utilities.ensureNonNull("firstRange", firstRange);
  Utilities.ensureNonNull("secondRange", secondRange);
  final Number firstRangeMin = firstRange.getMinValue();
  final Number firstRangeMax = firstRange.getMaxValue();
  final Number secondRangeMin = secondRange.getMinValue();
  final Number secondRangeMax = secondRange.getMaxValue();
  return doubleCompare(
      firstRangeMin.doubleValue(),
      firstRangeMax.doubleValue(),
      secondRangeMin.doubleValue(),
      secondRangeMax.doubleValue());
}

代码示例来源:origin: geotools/geotools

private Filter toGreaterFilter(FilterFactory ff, Expression variable, Range<T> range) {
  if (range.isMinIncluded()) {
    return ff.greaterOrEqual(variable, ff.literal(range.getMinValue()));
  } else {
    return ff.greater(variable, ff.literal(range.getMinValue()));
  }
}

代码示例来源:origin: geotools/geotools

@SuppressWarnings("unchecked")
  public int compare(final Range r1, final Range r2) {
    int cmin = r1.getMinValue().compareTo(r2.getMinValue());
    int cmax = r1.getMaxValue().compareTo(r2.getMaxValue());
    if (cmin == 0)
      cmin = (r1.isMinIncluded() ? -1 : 0) - (r2.isMinIncluded() ? -1 : 0);
    if (cmax == 0)
      cmax = (r1.isMaxIncluded() ? +1 : 0) - (r2.isMaxIncluded() ? +1 : 0);
    if (cmin == cmax)
      return cmax; // Easy case: min and max are both greater, smaller or eq.
    if (cmin == 0) return cmax; // Easy case: only max value differ.
    if (cmax == 0) return cmin; // Easy case: only min value differ.
    // One range is included in the other.
    throw new IllegalArgumentException("Unordered ranges");
  }
};

代码示例来源:origin: geotools/geotools

/**
 * Returns the smallest sample dimension type capable to hold the specified range of values.
 *
 * @param range The range of values.
 * @return The smallest sample dimension type for the specified range.
 */
public static SampleDimensionType getSampleDimensionType(final Range<?> range) {
  final Class<?> type = range.getElementClass();
  if (Double.class.isAssignableFrom(type)) {
    return REAL_64BITS;
  }
  if (Float.class.isAssignableFrom(type)) {
    return REAL_32BITS;
  }
  long min = ((Number) range.getMinValue()).longValue();
  long max = ((Number) range.getMaxValue()).longValue();
  if (!range.isMinIncluded()) min++;
  if (!range.isMaxIncluded()) max--;
  return getSampleDimensionType(min, max);
}

代码示例来源:origin: geotools/geotools

/**
 * Add a range to this set. Range may be added in any order. If the specified range overlap an
 * existing range, the two range will be merged as of {@link Range#union}.
 *
 * <p>Note: current version do not support open interval (i.e. {@code
 * Range.is[Min/Max]Included()} must return {@code true}).
 *
 * @param range The range to add.
 * @return {@code true} if this set changed as a result of the call.
 * @todo support open intervals.
 */
@Override
public boolean add(final Range<T> range) {
  if (!range.isMinIncluded() || !range.isMaxIncluded()) {
    throw new UnsupportedOperationException("Open interval not yet supported");
  }
  return add((Comparable) range.getMinValue(), (Comparable) range.getMaxValue());
}

代码示例来源:origin: geotools/geotools

private Filter toFilter(FilterFactory ff, Expression variable, Range<T> range) {
  if (range.getMinValue() == null && range.getMaxValue() == null) {
    return Filter.INCLUDE;
  } else if (range.isMinIncluded() && range.isMaxIncluded()) {
    if (range.getMinValue().equals(range.getMaxValue())) {
      return ff.equals(variable, ff.literal(range.getMinValue()));
    }
    return ff.between(
        variable, ff.literal(range.getMinValue()), ff.literal(range.getMaxValue()));
  } else if (range.getMinValue() == null) {
    return toLessFilter(ff, variable, range);
  } else if (range.getMaxValue() == null) {
    return toGreaterFilter(ff, variable, range);
  } else {
    Filter less = toLessFilter(ff, variable, range);
    Filter greater = toGreaterFilter(ff, variable, range);
    return ff.and(greater, less);
  }
}

代码示例来源:origin: geotools/geotools

/**
 * Constructs a range with the same type and the same values than the specified range. This is a
 * copy constructor.
 *
 * @param range The range to copy. The elements must be {@link Number} instances.
 * @since 2.4
 */
public NumberRange(final Range<T> range) {
  super(
      range.getElementClass(),
      range.getMinValue(),
      range.isMinIncluded(),
      range.getMaxValue(),
      range.isMaxIncluded());
}

代码示例来源:origin: geotools/geotools

/**
 * Returns {@code true} if this set contains the specified element.
 *
 * @param object The object to compare to this set.
 * @return {@code true} if the given object is equals to this set.
 */
@Override
public boolean contains(final Object object) {
  @SuppressWarnings("unchecked") // We are going to check just the line after.
  final Range<T> range = (Range<T>) object;
  if (elementClass.equals(range.elementClass)) {
    if (range.isMinIncluded() && range.isMaxIncluded()) {
      final int index = binarySearch(toArrayElement(range.getMinValue()));
      if (index >= 0 && (index & 1) == 0) {
        @SuppressWarnings("unchecked")
        final int c = get(index + 1).compareTo(range.getMaxValue());
        return c == 0;
      }
    }
  }
  return false;
}

代码示例来源:origin: geotools/geotools

/**
 * Constructs a range with the same values than the specified range, casted to the specified
 * type.
 *
 * @param type The element class, usually one of {@link Byte}, {@link Short}, {@link Integer},
 *     {@link Long}, {@link Float} or {@link Double}.
 * @param range The range to copy. The elements must be {@link Number} instances.
 * @throws IllegalArgumentException if the values are not convertible to the specified class.
 */
NumberRange(final Class<T> type, final Range<? extends Number> range)
    throws IllegalArgumentException {
  // TODO: remove the (Number) casts when we will be allowed to compile for Java 6.
  this(
      type,
      ClassChanger.cast((Number) range.getMinValue(), type),
      range.isMinIncluded(),
      ClassChanger.cast((Number) range.getMaxValue(), type),
      range.isMaxIncluded());
}

相关文章