public boolean isAscending() { loadValuesIfNeeded(); switch (spacing) { case regularInterval: case regularPoint: return getResolution() > 0; case irregularPoint: return values[0] <= values[ncoords - 1]; case contiguousInterval: return values[0] <= values[ncoords]; case discontiguousInterval: return values[0] <= values[2 * ncoords - 1]; } throw new IllegalStateException("unknown spacing" + spacing); }
public double getCoordEdge2(int index) { if (index < 0 || index >= getNcoords()) throw new IllegalArgumentException("Index out of range=" + index); loadValuesIfNeeded(); switch (spacing) { case regularPoint: if (index < 0 || index >= ncoords) throw new IllegalArgumentException("Index out of range " + index); return startValue + (index + .5) * getResolution(); case regularInterval: return startValue + (index+1) * getResolution(); case irregularPoint: if (index < ncoords - 1) return (values[index] + values[index + 1]) / 2; else return values[index] + (values[index] - values[index - 1]) / 2; case contiguousInterval: return values[index + 1]; case discontiguousInterval: return values[2 * index + 1]; } throw new IllegalStateException("Unknown spacing=" + spacing); }
public double getCoordEdge1(int index) { if (index < 0 || index >= getNcoords()) throw new IllegalArgumentException("Index out of range=" + index); loadValuesIfNeeded(); switch (spacing) { case regularPoint: return startValue + (index - .5) * getResolution(); case regularInterval: return startValue + index * getResolution(); case irregularPoint: if (index > 0) return (values[index - 1] + values[index]) / 2; else return values[0] - (values[1] - values[0]) / 2; case contiguousInterval: return values[index]; case discontiguousInterval: return values[2 * index]; } throw new IllegalStateException("Unknown spacing=" + spacing); }
public double getCoordMidpoint(int index) { if (index < 0 || index >= getNcoords()) throw new IllegalArgumentException("Index out of range=" + index); loadValuesIfNeeded(); switch (spacing) { case regularPoint: return startValue + index * getResolution(); case irregularPoint: return values[index]; case regularInterval: return startValue + (index + .5) * getResolution(); case contiguousInterval: case discontiguousInterval: return (getCoordEdge1(index) + getCoordEdge2(index)) / 2; } throw new IllegalStateException("Unknown spacing=" + spacing); }
public List<NamedObject> getCoordValueNames() { loadValuesIfNeeded(); if (timeHelper != null) return timeHelper.getCoordValueNames(this); List<NamedObject> result = new ArrayList<>(); for (int i = 0; i < ncoords; i++) { Object value = null; switch (spacing) { case regularPoint: case irregularPoint: value = Format.d(getCoordMidpoint(i), 3); break; case regularInterval: case contiguousInterval: case discontiguousInterval: value = new CoordInterval(getCoordEdge1(i), getCoordEdge2(i), 3); break; } result.add(new NamedAnything(value, value + " " + getUnits())); } return result; }
public List<NamedObject> getCoordValueNames(CoverageCoordAxis1D axis) { axis.loadValuesIfNeeded(); List<NamedObject> result = new ArrayList<>(); for (int i = 0; i < axis.getNcoords(); i++) { double value; switch (axis.getSpacing()) { case regularPoint: case irregularPoint: value = axis.getCoordMidpoint(i); result.add(new NamedAnything(makeDate(value), axis.getAxisType().toString())); break; case regularInterval: case contiguousInterval: case discontiguousInterval: CoordInterval coord = new CoordInterval(axis.getCoordEdge1(i), axis.getCoordEdge2(i), 3); result.add(new NamedAnything(coord, coord + " " + axis.getUnits())); break; } } return result; }