*/
static AbstractCS shiftAxisRange(final AbstractCS cs) {
boolean changed = false;
final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[cs.getDimension()];
for (int i=0; i<axes.length; i++) {
CoordinateSystemAxis axis = cs.getAxis(i);
final RangeMeaning rangeMeaning = axis.getRangeMeaning();
if (RangeMeaning.WRAPAROUND.equals(rangeMeaning)) {
double min = axis.getMinimumValue();
if (min < 0) {
double max = axis.getMaximumValue();
double offset = (max - min) / 2;
offset *= Math.floor(min/offset + 1E-10);
min -= offset;
max -= offset;
if (min < max) { // Paranoiac check, but also a way to filter NaN values when offset is infinite.
final Map<String,Object> properties = new HashMap<String,Object>();
properties.putAll(IdentifiedObjects.getProperties(axis, EXCLUDES));
properties.put(DefaultCoordinateSystemAxis.MINIMUM_VALUE_KEY, min);
properties.put(DefaultCoordinateSystemAxis.MAXIMUM_VALUE_KEY, max);
properties.put(DefaultCoordinateSystemAxis.RANGE_MEANING_KEY, rangeMeaning);
axis = new DefaultCoordinateSystemAxis(properties,
axis.getAbbreviation(), axis.getDirection(), axis.getUnit());
changed = true;
}
}
}
axes[i] = axis;