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

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

本文整理了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

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

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

  1. /**
  2. * Returns the smallest sample dimension type capable to hold the specified range of values.
  3. *
  4. * @param range The range of values.
  5. * @return The smallest sample dimension type for the specified range.
  6. */
  7. public static SampleDimensionType getSampleDimensionType(final Range<?> range) {
  8. final Class<?> type = range.getElementClass();
  9. if (Double.class.isAssignableFrom(type)) {
  10. return REAL_64BITS;
  11. }
  12. if (Float.class.isAssignableFrom(type)) {
  13. return REAL_32BITS;
  14. }
  15. long min = ((Number) range.getMinValue()).longValue();
  16. long max = ((Number) range.getMaxValue()).longValue();
  17. if (!range.isMinIncluded()) min++;
  18. if (!range.isMaxIncluded()) max--;
  19. return getSampleDimensionType(min, max);
  20. }

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

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

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

  1. private boolean contiguous(Range r1, Range<T> r2) {
  2. if (r1.getMinValue() != null
  3. && r2.getMaxValue() != null
  4. && (r1.isMinIncluded() || r2.isMaxIncluded())) {
  5. return r1.getMinValue().equals(r2.getMaxValue());
  6. } else if (r1.getMaxValue() != null
  7. && r2.getMinValue() != null
  8. && (r1.isMaxIncluded() || r2.isMinIncluded())) {
  9. return r1.getMaxValue().equals(r2.getMinValue());
  10. } else {
  11. return false;
  12. }
  13. }

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

  1. if (next.getMinValue().equals(curr.getMaxValue())) {
  2. if (!next.isMinIncluded() && !curr.isMaxIncluded()) {
  3. exclusions.add((T) curr.getMaxValue());
  4. range.isMinIncluded(),
  5. (T) curr.getMaxValue(),
  6. curr.isMaxIncluded());
  7. Filter filter = toFilter(ff, variable, union);
  8. if (exclusions.size() == 0) {

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

  1. /**
  2. * Constructs a range with the same type and the same values than the specified range. This is a
  3. * copy constructor.
  4. *
  5. * @param range The range to copy. The elements must be {@link Number} instances.
  6. * @since 2.4
  7. */
  8. public NumberRange(final Range<T> range) {
  9. super(
  10. range.getElementClass(),
  11. range.getMinValue(),
  12. range.isMinIncluded(),
  13. range.getMaxValue(),
  14. range.isMaxIncluded());
  15. }

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

  1. /**
  2. * Returns {@code true} if this set contains the specified element.
  3. *
  4. * @param object The object to compare to this set.
  5. * @return {@code true} if the given object is equals to this set.
  6. */
  7. @Override
  8. public boolean contains(final Object object) {
  9. @SuppressWarnings("unchecked") // We are going to check just the line after.
  10. final Range<T> range = (Range<T>) object;
  11. if (elementClass.equals(range.elementClass)) {
  12. if (range.isMinIncluded() && range.isMaxIncluded()) {
  13. final int index = binarySearch(toArrayElement(range.getMinValue()));
  14. if (index >= 0 && (index & 1) == 0) {
  15. @SuppressWarnings("unchecked")
  16. final int c = get(index + 1).compareTo(range.getMaxValue());
  17. return c == 0;
  18. }
  19. }
  20. }
  21. return false;
  22. }

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

  1. private Filter toLessFilter(FilterFactory ff, Expression variable, Range<T> range) {
  2. if (range.isMaxIncluded()) {
  3. return ff.lessOrEqual(variable, ff.literal(range.getMaxValue()));
  4. } else {
  5. return ff.less(variable, ff.literal(range.getMaxValue()));
  6. }
  7. }

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

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

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

  1. private Filter toFilter(FilterFactory ff, Expression variable, Range<T> range) {
  2. if (range.getMinValue() == null && range.getMaxValue() == null) {
  3. return Filter.INCLUDE;
  4. } else if (range.isMinIncluded() && range.isMaxIncluded()) {
  5. if (range.getMinValue().equals(range.getMaxValue())) {
  6. return ff.equals(variable, ff.literal(range.getMinValue()));
  7. }
  8. return ff.between(
  9. variable, ff.literal(range.getMinValue()), ff.literal(range.getMaxValue()));
  10. } else if (range.getMinValue() == null) {
  11. return toLessFilter(ff, variable, range);
  12. } else if (range.getMaxValue() == null) {
  13. return toGreaterFilter(ff, variable, range);
  14. } else {
  15. Filter less = toLessFilter(ff, variable, range);
  16. Filter greater = toGreaterFilter(ff, variable, range);
  17. return ff.and(greater, less);
  18. }
  19. }

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

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

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

  1. /**
  2. * Show only commits that lie within the specified time range.
  3. *
  4. * @param commitRange time range to show commits from
  5. * @return {@code this}
  6. */
  7. public LogOp setTimeRange(final Range<Date> commitRange) {
  8. if (commitRange == null) {
  9. this.timeRange = ALWAYS;
  10. } else {
  11. this.timeRange = new Range<Long>(Long.class, commitRange.getMinValue().getTime(),
  12. commitRange.isMinIncluded(), commitRange.getMaxValue().getTime(),
  13. commitRange.isMaxIncluded());
  14. }
  15. return this;
  16. }

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

  1. /**
  2. * Returns the smallest sample dimension type capable to hold the specified range of values.
  3. *
  4. * @param range The range of values.
  5. * @return The smallest sample dimension type for the specified range.
  6. */
  7. public static SampleDimensionType getSampleDimensionType(final Range<?> range) {
  8. final Class<?> type = range.getElementClass();
  9. if (Double.class.isAssignableFrom(type)) {
  10. return REAL_64BITS;
  11. }
  12. if (Float.class.isAssignableFrom(type)) {
  13. return REAL_32BITS;
  14. }
  15. long min = ((Number) range.getMinValue()).longValue();
  16. long max = ((Number) range.getMaxValue()).longValue();
  17. if (!range.isMinIncluded()) min++;
  18. if (!range.isMaxIncluded()) max--;
  19. return getSampleDimensionType(min, max);
  20. }

代码示例来源:origin: locationtech/geogig

  1. /**
  2. * Show only commits that lie within the specified time range.
  3. *
  4. * @param commitRange time range to show commits from
  5. * @return {@code this}
  6. */
  7. public LogOp setTimeRange(final Range<Date> commitRange) {
  8. if (commitRange == null) {
  9. this.timeRange = ALWAYS;
  10. } else {
  11. this.timeRange = new Range<Long>(Long.class, commitRange.getMinValue().getTime(),
  12. commitRange.isMinIncluded(), commitRange.getMaxValue().getTime(),
  13. commitRange.isMaxIncluded());
  14. }
  15. return this;
  16. }

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

  1. /**
  2. * Show only commits that lie within the specified time range.
  3. *
  4. * @param commitRange time range to show commits from
  5. * @return {@code this}
  6. */
  7. public LogOp setTimeRange(final Range<Date> commitRange) {
  8. if (commitRange == null) {
  9. this.timeRange = ALWAYS;
  10. } else {
  11. this.timeRange = new Range<Long>(Long.class, commitRange.getMinValue().getTime(),
  12. commitRange.isMinIncluded(), commitRange.getMaxValue().getTime(),
  13. commitRange.isMaxIncluded());
  14. }
  15. return this;
  16. }

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

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

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

  1. /**
  2. * Constructs a range with the same type and the same values than the
  3. * specified range. This is a copy constructor.
  4. *
  5. * @param range The range to copy. The elements must be {@link Number} instances.
  6. *
  7. * @since 2.4
  8. */
  9. public NumberRange(final Range<T> range) {
  10. super(range.getElementClass(),
  11. range.getMinValue(), range.isMinIncluded(),
  12. range.getMaxValue(), range.isMaxIncluded());
  13. }

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

  1. /**
  2. * Returns {@code true} if this set contains the specified element.
  3. *
  4. * @param object The object to compare to this set.
  5. * @return {@code true} if the given object is equals to this set.
  6. */
  7. @Override
  8. public boolean contains(final Object object) {
  9. @SuppressWarnings("unchecked") // We are going to check just the line after.
  10. final Range<T> range = (Range<T>) object;
  11. if (elementClass.equals(range.elementClass)) {
  12. if (range.isMinIncluded() && range.isMaxIncluded()) {
  13. final int index = binarySearch(toArrayElement(range.getMinValue()));
  14. if (index >= 0 && (index & 1)==0) {
  15. @SuppressWarnings("unchecked")
  16. final int c = get(index+1).compareTo(range.getMaxValue());
  17. return c == 0;
  18. }
  19. }
  20. }
  21. return false;
  22. }

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

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

相关文章