/** * Encode the interval range * * @param range */ private boolean setRange(NumberRange<? extends Number> range) { if (range != null && !Double.isInfinite(range.getMaximum()) && !Double.isInfinite(range.getMinimum())) { start("swe:interval"); chars(range.getMinValue() + " " + range.getMaxValue()); end("swe:interval"); return true; } return false; }
/** * Set additional dimension metadata to the DescribeCoverage element * * @param name the custom dimension name * @param dimension the custom dimension related {@link DimensionInfo} instance * @param helper the {@link WCSDimensionsHelper} instance to be used to parse domains * @throws IOException */ private void setAdditionalDimensionMetadata( final String name, final DimensionInfo dimension, WCSDimensionsHelper helper) throws IOException { Utilities.ensureNonNull("helper", helper); final String startTag = initStartMetadataTag(TAG.ADDITIONAL_DIMENSION, name, dimension, helper); start(startTag); // Custom dimension only supports List presentation final List<String> domain = helper.getDomain(name); // TODO: check if we are in the list of instants case, or in the list of periods case // list case int i = 0; for (String item : domain) { Date date = WCSDimensionsValueParser.parseAsDate(item); if (date != null) { final String dimensionId = helper.getCoverageId() + "_dd_" + i; encodeDate(date, helper, dimensionId); continue; } Double number = WCSDimensionsValueParser.parseAsDouble(item); if (number != null) { element(TAG.SINGLE_VALUE, item.toString()); continue; } NumberRange<Double> range = WCSDimensionsValueParser.parseAsDoubleRange(item); if (range != null) { encodeInterval( range.getMinValue().toString(), range.getMaxValue().toString(), null, null); continue; } // TODO: Add support for date Ranges if (item instanceof String) { element(TAG.SINGLE_VALUE, item.toString()); } // else if (item instanceof DateRange) { // final String dimensionId = helper.getCoverageId() + "_dd_" + i; // encodeDateRange((DateRange) item, helper, dimensionId); // } // TODO: Add more cases i++; } end(TAG.ADDITIONAL_DIMENSION); }
/** * Set the elevationDomain metadata in case the dimensionsHelper instance has an * elevationDimension * * @param helper * @throws IOException */ private void handleElevationMetadata(WCSDimensionsHelper helper) throws IOException { // Null check has been performed in advance final DimensionInfo elevationDimension = helper.getElevationDimension(); if (elevationDimension != null) { start(initStartMetadataTag(TAG.ELEVATION_DOMAIN, null, elevationDimension, helper)); final DimensionPresentation presentation = elevationDimension.getPresentation(); switch (presentation) { // Where _er_ means elevation range case CONTINUOUS_INTERVAL: encodeInterval(helper.getBeginElevation(), helper.getEndElevation(), null, null); break; case DISCRETE_INTERVAL: encodeInterval( helper.getBeginElevation(), helper.getEndElevation(), helper.getElevationResolutionUnit(), helper.getElevationResolutionValue()); break; default: // TODO: check if we are in the list of instants case, or in the list of periods case // list case final TreeSet<Object> domain = helper.getElevationDomain(); for (Object item : domain) { if (item instanceof Number) { element(TAG.SINGLE_VALUE, item.toString()); } else if (item instanceof NumberRange) { NumberRange range = (NumberRange) item; encodeInterval( range.getMinValue().toString(), range.getMaxValue().toString(), null, null); } } break; } end(TAG.ELEVATION_DOMAIN); } }