Skip to content

Commit

Permalink
Merge pull request OSGeo#11435 from rouault/fix_gdalvrt_xsd
Browse files Browse the repository at this point in the history
gdalvrt.xsd: fix schema to reflect that <Array> can be a child of <ArraySource>
  • Loading branch information
rouault authored Dec 4, 2024
2 parents 964add6 + 46f390c commit b7a6c51
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 24 deletions.
13 changes: 13 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_array_constant.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<PixelFunctionType>real</PixelFunctionType>
<ArraySource>
<Array name="test">
<DataType>Float64</DataType>
<Dimension name="Y" size="20"/>
<Dimension name="X" size="20"/>
<ConstantValue>10</ConstantValue>
</Array>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
6 changes: 6 additions & 0 deletions autotest/gdrivers/vrtmultidim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,12 @@ def test_vrtmultidim_arraysource_array():
assert ds.GetRasterBand(1).Checksum() == 4855


def test_vrtmultidim_arraysource_array_constant():

ds = gdal.Open("data/vrt/arraysource_array_constant.vrt")
assert ds.GetRasterBand(1).ComputeRasterMinMax() == (10, 10)


@pytest.mark.require_driver("netCDF")
def test_vrtmultidim_arraysource_derivedarray_view():

Expand Down
54 changes: 30 additions & 24 deletions frmts/vrt/data/gdalvrt.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -636,35 +636,41 @@
</xs:complexType>

<xs:complexType name="ArrayType">
<xs:sequence>
<xs:element name="DataType" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Dimension" type="DimensionType"/>
<xs:element name="DimensionRef" type="DimensionRefType"/>
</xs:choice>
</xs:sequence>
<xs:element name="SRS" type="SRSType" minOccurs="0" maxOccurs="1"/>
<xs:element name="Unit" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="NoDataValue" type="DoubleOrNanType" minOccurs="0" maxOccurs="1"/>
<xs:element name="Offset" type="xs:double" minOccurs="0" maxOccurs="1"/>
<xs:element name="Scale" type="xs:double" minOccurs="0" maxOccurs="1"/>
<xs:choice>
<xs:element name="RegularlySpacedValues" type="RegularlySpacedValuesType" minOccurs="0" maxOccurs="1"/>
<xs:complexContent>
<xs:extension base="AbstractArrayType">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="ConstantValue" type="ConstantValueType"/>
<xs:element name="InlineValues" type="InlineValuesType"/>
<xs:element name="InlineValuesWithValueElement" type="InlineValuesWithValueElementType"/>
<xs:element name="Source" type="SourceType"/>
<xs:element name="DataType" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Dimension" type="DimensionType"/>
<xs:element name="DimensionRef" type="DimensionRefType"/>
</xs:choice>
</xs:sequence>
<xs:element name="SRS" type="SRSType" minOccurs="0" maxOccurs="1"/>
<xs:element name="Unit" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="NoDataValue" type="DoubleOrNanType" minOccurs="0" maxOccurs="1"/>
<xs:element name="Offset" type="xs:double" minOccurs="0" maxOccurs="1"/>
<xs:element name="Scale" type="xs:double" minOccurs="0" maxOccurs="1"/>
<xs:choice>
<xs:element name="RegularlySpacedValues" type="RegularlySpacedValuesType" minOccurs="0" maxOccurs="1"/>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="ConstantValue" type="ConstantValueType"/>
<xs:element name="InlineValues" type="InlineValuesType"/>
<xs:element name="InlineValuesWithValueElement" type="InlineValuesWithValueElementType"/>
<xs:element name="Source" type="SourceType"/>
</xs:choice>
</xs:sequence>
</xs:choice>
<xs:element name="Attribute" type="AttributeType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:choice>
<xs:element name="Attribute" type="AttributeType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="Array" substitutionGroup="AbstractArray" type="ArrayType"/>

<xs:complexType name="RegularlySpacedValuesType">
<xs:attribute name="start" type="xs:double" use="required"/>
<xs:attribute name="increment" type="xs:double" use="required"/>
Expand Down

0 comments on commit b7a6c51

Please sign in to comment.