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

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

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

Range.isMaxIncluded介绍

[英]Whatever the minimal or maximum value is included.
[中]无论最小值或最大值是多少。

代码示例

代码示例来源: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 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

if (next.getMinValue().equals(curr.getMaxValue())) {
  if (!next.isMinIncluded() && !curr.isMaxIncluded()) {
    exclusions.add((T) curr.getMaxValue());
        range.isMinIncluded(),
        (T) curr.getMaxValue(),
        curr.isMaxIncluded());
Filter filter = toFilter(ff, variable, union);
if (exclusions.size() == 0) {

代码示例来源: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

private Filter toLessFilter(FilterFactory ff, Expression variable, Range<T> range) {
  if (range.isMaxIncluded()) {
    return ff.lessOrEqual(variable, ff.literal(range.getMaxValue()));
  } else {
    return ff.less(variable, ff.literal(range.getMaxValue()));
  }
}

代码示例来源: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());
}

代码示例来源: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: org.geotools/gt-metadata

@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: org.locationtech.geogig/geogig-core

/**
 * Show only commits that lie within the specified time range.
 * 
 * @param commitRange time range to show commits from
 * @return {@code this}
 */
public LogOp setTimeRange(final Range<Date> commitRange) {
  if (commitRange == null) {
    this.timeRange = ALWAYS;
  } else {
    this.timeRange = new Range<Long>(Long.class, commitRange.getMinValue().getTime(),
        commitRange.isMinIncluded(), commitRange.getMaxValue().getTime(),
        commitRange.isMaxIncluded());
  }
  return this;
}

代码示例来源:origin: org.geotools/gt-coverage

/**
 * 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: locationtech/geogig

/**
 * Show only commits that lie within the specified time range.
 * 
 * @param commitRange time range to show commits from
 * @return {@code this}
 */
public LogOp setTimeRange(final Range<Date> commitRange) {
  if (commitRange == null) {
    this.timeRange = ALWAYS;
  } else {
    this.timeRange = new Range<Long>(Long.class, commitRange.getMinValue().getTime(),
        commitRange.isMinIncluded(), commitRange.getMaxValue().getTime(),
        commitRange.isMaxIncluded());
  }
  return this;
}

代码示例来源:origin: org.geogit/geogit-core

/**
 * Show only commits that lie within the specified time range.
 * 
 * @param commitRange time range to show commits from
 * @return {@code this}
 */
public LogOp setTimeRange(final Range<Date> commitRange) {
  if (commitRange == null) {
    this.timeRange = ALWAYS;
  } else {
    this.timeRange = new Range<Long>(Long.class, commitRange.getMinValue().getTime(),
        commitRange.isMinIncluded(), commitRange.getMaxValue().getTime(),
        commitRange.isMaxIncluded());
  }
  return this;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * 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: org.geotools/gt-metadata

/**
 * 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: org.geotools/gt-metadata

/**
 * 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: org.geotools/gt-metadata

/**
 * 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());
}

相关文章