Unverified Commit 454721da authored by Steve Ikeoka's avatar Steve Ikeoka Committed by GitHub
Browse files

Merge pull request #3420 from sikeoka/GEOS-9141-15

[GEOS-9141][2.15.x] Fixed invalid WCS 2.0.1 DescribeCoverage with elevation and custom dimensions.
parents 240c352f 11aeca60
......@@ -320,11 +320,13 @@ class GMLTransformer extends TransformerBase {
helper.getAdditionalDimensions();
final Set<String> dimensionsName = additionalDimensions.keySet();
final Iterator<String> dimensionsIterator = dimensionsName.iterator();
int index = 0;
while (dimensionsIterator.hasNext()) {
final String dimensionName = dimensionsIterator.next();
final DimensionInfo customDimension = additionalDimensions.get(dimensionName);
if (customDimension != null) {
setAdditionalDimensionMetadata(dimensionName, customDimension, helper);
setAdditionalDimensionMetadata(dimensionName, customDimension, index, helper);
index++;
}
}
}
......@@ -334,11 +336,15 @@ class GMLTransformer extends TransformerBase {
*
* @param name the custom dimension name
* @param dimension the custom dimension related {@link DimensionInfo} instance
* @param index the custom dimension index to ensure unique GML ids
* @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)
final String name,
final DimensionInfo dimension,
int index,
WCSDimensionsHelper helper)
throws IOException {
Utilities.ensureNonNull("helper", helper);
final String startTag =
......@@ -350,11 +356,11 @@ class GMLTransformer extends TransformerBase {
// 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) {
for (int i = 0; i < domain.size(); i++) {
String item = domain.get(i);
Date date = WCSDimensionsValueParser.parseAsDate(item);
if (date != null) {
final String dimensionId = helper.getCoverageId() + "_dd_" + i;
final String dimensionId = helper.getCoverageId() + "_dd_" + index + "_" + i;
encodeDate(date, helper, dimensionId);
continue;
}
......@@ -386,7 +392,6 @@ class GMLTransformer extends TransformerBase {
// }
// TODO: Add more cases
i++;
}
end(TAG.ADDITIONAL_DIMENSION);
}
......@@ -691,18 +696,13 @@ class GMLTransformer extends TransformerBase {
envelopeAttrs.addAttribute(
"", "srsDimension", "srsDimension", "", String.valueOf(srsDimension));
start("gml:boundedBy");
String envelopeName;
if (dimensionHelper != null && (hasTime || hasElevation)) {
envelopeName = "gml:EnvelopeWithTimePeriod";
} else {
envelopeName = "gml:Envelope";
}
String envelopeName = hasTime ? "gml:EnvelopeWithTimePeriod" : "gml:Envelope";
start(envelopeName, envelopeAttrs);
element("gml:lowerCorner", lower);
element("gml:upperCorner", upper);
if (dimensionHelper != null && hasTime) {
if (hasTime) {
element("gml:beginPosition", dimensionHelper.getBeginTime());
element("gml:endPosition", dimensionHelper.getEndTime());
}
......
......@@ -30,4 +30,69 @@
</sequence>
<attribute name="default"/>
</complexType>
<element name="ElevationDomain" type="wcsgs:ElevationDomainType">
<annotation>
<documentation>A description of the elevation domain for this coverage
</documentation>
</annotation>
</element>
<complexType name="ElevationDomainType">
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="wcsgs:SingleValue" />
<element ref="wcsgs:Range" />
</choice>
<attribute name="uom" />
<attribute name="default" />
</complexType>
<element name="DimensionDomain" type="wcsgs:DimensionDomainType">
<annotation>
<documentation>A description of a custom domain for this coverage
</documentation>
</annotation>
</element>
<complexType name="DimensionDomainType">
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="gml:AbstractTimeObject" />
<element ref="wcsgs:SingleValue" />
<element ref="wcsgs:Range" />
</choice>
<attribute name="name" />
<attribute name="uom" />
<attribute name="default" />
</complexType>
<element name="SingleValue" type="string">
<annotation>
<documentation>A non-temporal dimension value
</documentation>
</annotation>
</element>
<element name="Range" type="wcsgs:RangeType">
<annotation>
<documentation>A non-temporal dimension range
</documentation>
</annotation>
</element>
<complexType name="RangeType">
<sequence>
<element name="start" type="string" />
<element name="end" type="string" />
<element ref="wcsgs:Interval" minOccurs="0" />
</sequence>
</complexType>
<element name="Interval" type="wcsgs:IntervalType">
<annotation>
<documentation>The discrete interval of a non-temporal dimension range
</documentation>
</annotation>
</element>
<complexType name="IntervalType">
<simpleContent>
<extension base="string">
<attribute name="unit" />
</extension>
</simpleContent>
</complexType>
</schema>
......@@ -575,6 +575,7 @@ public class DescribeCoverageTest extends WCSTestSupport {
"m");
Document dom = getAsDOM(DESCRIBE_URL + "&coverageId=sf__timeranges");
// print(dom);
checkValidationErrors(dom, getWcs20Schema());
checkElevationRangesEnvelope(dom);
......@@ -610,6 +611,7 @@ public class DescribeCoverageTest extends WCSTestSupport {
null);
Document dom = getAsDOM(DESCRIBE_URL + "&coverageId=sf__timeranges");
// print(dom);
checkValidationErrors(dom, getWcs20Schema());
checkElevationRangesEnvelope(dom);
......@@ -634,6 +636,7 @@ public class DescribeCoverageTest extends WCSTestSupport {
getLayerId(WATTEMP), ResourceInfo.ELEVATION, DimensionPresentation.LIST, null);
Document dom = getAsDOM(DESCRIBE_URL + "&coverageId=sf__watertemp");
// print(dom);
checkValidationErrors(dom, getWcs20Schema());
checkWaterTempElevationEnvelope(dom);
......@@ -658,6 +661,7 @@ public class DescribeCoverageTest extends WCSTestSupport {
getLayerId(TIMERANGES), ResourceInfo.ELEVATION, DimensionPresentation.LIST, null);
Document dom = getAsDOM(DESCRIBE_URL + "&coverageId=sf__timeranges");
// print(dom);
checkValidationErrors(dom, getWcs20Schema());
checkElevationRangesEnvelope(dom);
......@@ -751,6 +755,7 @@ public class DescribeCoverageTest extends WCSTestSupport {
null);
Document dom = getAsDOM(DESCRIBE_URL + "&coverageId=sf__multidim");
// print(dom);
checkValidationErrors(dom, getWcs20Schema());
checkTimeElevationRangesEnvelope(dom);
......@@ -911,43 +916,35 @@ public class DescribeCoverageTest extends WCSTestSupport {
private void checkWaterTempElevationEnvelope(Document dom) throws XpathException {
// check the envelope with time
assertXpathEvaluatesTo("1", "count(//gml:boundedBy/gml:EnvelopeWithTimePeriod)", dom);
assertXpathEvaluatesTo("1", "count(//gml:boundedBy/gml:Envelope)", dom);
assertXpathEvaluatesTo(
"Lat Long elevation",
"//gml:boundedBy/gml:EnvelopeWithTimePeriod/@axisLabels",
dom);
assertXpathEvaluatesTo(
"Deg Deg m", "//gml:boundedBy/gml:EnvelopeWithTimePeriod/@uomLabels", dom);
assertXpathEvaluatesTo(
"3", "//gml:boundedBy/gml:EnvelopeWithTimePeriod/@srsDimension", dom);
"Lat Long elevation", "//gml:boundedBy/gml:Envelope/@axisLabels", dom);
assertXpathEvaluatesTo("Deg Deg m", "//gml:boundedBy/gml:Envelope/@uomLabels", dom);
assertXpathEvaluatesTo("3", "//gml:boundedBy/gml:Envelope/@srsDimension", dom);
assertXpathEvaluatesTo(
"40.562080748421806 0.23722068851276978 0.0",
"//gml:boundedBy/gml:EnvelopeWithTimePeriod/gml:lowerCorner",
"//gml:boundedBy/gml:Envelope/gml:lowerCorner",
dom);
assertXpathEvaluatesTo(
"44.55808294568743 14.592757149389236 100.0",
"//gml:boundedBy/gml:EnvelopeWithTimePeriod/gml:upperCorner",
"//gml:boundedBy/gml:Envelope/gml:upperCorner",
dom);
}
private void checkElevationRangesEnvelope(Document dom) throws XpathException {
// check the envelope with time
assertXpathEvaluatesTo("1", "count(//gml:boundedBy/gml:EnvelopeWithTimePeriod)", dom);
assertXpathEvaluatesTo(
"Lat Long elevation",
"//gml:boundedBy/gml:EnvelopeWithTimePeriod/@axisLabels",
dom);
assertXpathEvaluatesTo("1", "count(//gml:boundedBy/gml:Envelope)", dom);
assertXpathEvaluatesTo(
"Deg Deg m", "//gml:boundedBy/gml:EnvelopeWithTimePeriod/@uomLabels", dom);
assertXpathEvaluatesTo(
"3", "//gml:boundedBy/gml:EnvelopeWithTimePeriod/@srsDimension", dom);
"Lat Long elevation", "//gml:boundedBy/gml:Envelope/@axisLabels", dom);
assertXpathEvaluatesTo("Deg Deg m", "//gml:boundedBy/gml:Envelope/@uomLabels", dom);
assertXpathEvaluatesTo("3", "//gml:boundedBy/gml:Envelope/@srsDimension", dom);
assertXpathEvaluatesTo(
"40.562080748421806 0.23722068851276978 20.0",
"//gml:boundedBy/gml:EnvelopeWithTimePeriod/gml:lowerCorner",
"//gml:boundedBy/gml:Envelope/gml:lowerCorner",
dom);
assertXpathEvaluatesTo(
"44.55808294568743 14.592757149389236 150.0",
"//gml:boundedBy/gml:EnvelopeWithTimePeriod/gml:upperCorner",
"//gml:boundedBy/gml:Envelope/gml:upperCorner",
dom);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment