@Override public String getSummary() { if (axisType != AxisType.RunTime) return super.getSummary(); if (ncoords < 7) { Formatter f = new Formatter(); for (int i = 0; i < ncoords; i++) { CalendarDate cd = makeDate(getCoordMidpoint(i)); if (i > 0) f.format(", "); f.format("%s", cd); } return f.toString(); } Formatter f = new Formatter(); CalendarDate start = makeDate(getStartValue()); f.format("start=%s", start); CalendarDate end = makeDate(getEndValue()); f.format(", end=%s", end); f.format(" (npts=%d spacing=%s)", getNcoords(), getSpacing()); return f.toString(); }
private Optional<CoverageCoordAxis> subsetLon(LatLonRect llbb, int stride) throws InvalidRangeException { double wantMin = LatLonPointImpl.lonNormalFrom(llbb.getLonMin(), lonAxis.getStartValue()); double wantMax = LatLonPointImpl.lonNormalFrom(llbb.getLonMax(), lonAxis.getStartValue()); double start = lonAxis.getStartValue(); double end = lonAxis.getEndValue(); // use MAMath.MinMax as a container for two values, min and max List<MAMath.MinMax> lonIntvs = subsetLonIntervals(wantMin, wantMax, start, end); if (lonIntvs.size() == 0) return Optional.empty(String.format( "longitude want [%f,%f] does not intersect lon axis [%f,%f]", wantMin, wantMax, start, end)); if (lonIntvs.size() == 1) { MAMath.MinMax lonIntv = lonIntvs.get(0); return lonAxis.subset(lonIntv.min, lonIntv.max, stride); } // this is the seam crossing case return lonAxis.subsetByIntervals(lonIntvs, stride); }
public Optional<RangeIterator> makeRange(double minValue, double maxValue, int stride) { //if (axis.getSpacing() == CoverageCoordAxis.Spacing.discontiguousInterval) // return subsetValuesDiscontinuous(minValue, maxValue, stride); double lower = axis.isAscending() ? Math.min(minValue, maxValue) : Math.max(minValue, maxValue); double upper = axis.isAscending() ? Math.max(minValue, maxValue) : Math.min(minValue, maxValue); int minIndex = findCoordElement(lower, false); int maxIndex = findCoordElement(upper, false); if (minIndex >= axis.getNcoords()) return Optional.empty(String.format("no points in subset: lower %f > end %f", lower, axis.getEndValue())); if (maxIndex < 0) return Optional.empty(String.format("no points in subset: upper %f < start %f", upper, axis.getStartValue())); if (minIndex < 0) minIndex = 0; if (maxIndex >= axis.getNcoords()) maxIndex = axis.getNcoords() - 1; int count = maxIndex - minIndex + 1; if (count <= 0) return Optional.empty("no points in subset"); try { return Optional.of(new Range(minIndex, maxIndex, stride)); } catch (InvalidRangeException e) { return Optional.empty(e.getMessage()); } }
private Optional<CoverageCoordAxisBuilder> subsetValues(double minValue, double maxValue, int stride) { if (axis.getSpacing() == CoverageCoordAxis.Spacing.discontiguousInterval) return subsetValuesDiscontinuous(minValue, maxValue, stride); double lower = axis.isAscending() ? Math.min(minValue, maxValue) : Math.max(minValue, maxValue); double upper = axis.isAscending() ? Math.max(minValue, maxValue) : Math.min(minValue, maxValue); int minIndex = findCoordElement(lower, false); int maxIndex = findCoordElement(upper, false); if (minIndex >= axis.getNcoords()) return Optional.empty(String.format("no points in subset: lower %f > end %f", lower, axis.getEndValue())); if (maxIndex < 0) return Optional.empty(String.format("no points in subset: upper %f < start %f", upper, axis.getStartValue())); if (minIndex < 0) minIndex = 0; if (maxIndex >= axis.getNcoords()) maxIndex = axis.getNcoords() - 1; int count = maxIndex - minIndex + 1; if (count <= 0) throw new IllegalArgumentException("no points in subset"); try { return Optional.of(subsetByIndex(new Range(minIndex, maxIndex, stride))); } catch (InvalidRangeException e) { return Optional.empty(e.getMessage()); } }
Assert.assertEquals(291, xaxis.getNcoords()); Assert2.assertNearlyEquals(10.5, xaxis.getCoordMidpoint(0)); Assert2.assertNearlyEquals(300.5, xaxis.getEndValue()); // LOOK is that ok? BB = 10-300: its just catching the edge Assert2.assertNearlyEquals(1.0, xaxis.getResolution()); Assert.assertEquals(81, yaxis.getNcoords()); Assert2.assertNearlyEquals(79.5, yaxis.getCoordMidpoint(0)); Assert2.assertNearlyEquals(-.5, yaxis.getEndValue()); // LOOK is that ok? BB = 0-80: its just catching the edge Assert2.assertNearlyEquals(-1.0, yaxis.getResolution());
case regularPoint: builder.startValue = timeAxisSubset.getStartValue() + offset; builder.endValue = timeAxisSubset.getEndValue() + offset; break;
case regularPoint: builder.startValue = timeAxisSubset.getStartValue() + offset; builder.endValue = timeAxisSubset.getEndValue() + offset; break;
Assert.assertEquals(CoverageCoordAxis.Spacing.discontiguousInterval, timeAxis.getSpacing()); Assert2.assertNearlyEquals(0.0, timeAxis.getStartValue()); Assert2.assertNearlyEquals(384.0, timeAxis.getEndValue());