private Element genRectifiedGridElem( WcsCoverage coverage )
{
// ../spatialDomain/gml:RectifiedGrid
Element rectifiedGridElem = new Element( "RectifiedGrid", gmlNS);
CoordinateAxis1D xaxis = (CoordinateAxis1D) coverage.getCoordinateSystem().getXHorizAxis();
CoordinateAxis1D yaxis = (CoordinateAxis1D) coverage.getCoordinateSystem().getYHorizAxis();
CoordinateAxis1D zaxis = coverage.getCoordinateSystem().getVerticalAxis();
// ../spatialDomain/gml:RectifiedGrid@srsName [0..1] (URI)
rectifiedGridElem.setAttribute( "srsName", coverage.getNativeCrs() );
// ../spatialDomain/gml:RectifiedGrid@dimension [1] (positive integer)
int ndim = ( zaxis != null ) ? 3 : 2;
rectifiedGridElem.setAttribute( "dimension", Integer.toString( ndim ) );
// ../spatialDomain/gml:RectifiedGrid/gml:limits [1]
int[] minValues = new int[ndim];
int[] maxValues = new int[ndim];
maxValues[0] = (int) ( xaxis.getSize() - 1 );
maxValues[1] = (int) ( yaxis.getSize() - 1 );
if ( zaxis != null )
maxValues[2] = (int) ( zaxis.getSize() - 1 );
Element limitsElem = new Element( "limits", gmlNS);
// ../spatialDomain/gml:RectifiedGrid/gml:limits/gml:GridEnvelope [1]
// ../spatialDomain/gml:RectifiedGrid/gml:limits/gml:GridEnvelope/gml:low [1] (integer list)
// ../spatialDomain/gml:RectifiedGrid/gml:limits/gml:GridEnvelope/gml:high [1] (integer list)
limitsElem.addContent(
new Element( "GridEnvelope", gmlNS)
.addContent( new Element( "low", gmlNS ).addContent( genIntegerListString( minValues)))
.addContent( new Element( "high", gmlNS).addContent( genIntegerListString( maxValues))) );
rectifiedGridElem.addContent( limitsElem);
// ../spatialDomain/gml:RectifiedGrid/gml:axisName [1..*] (string)
rectifiedGridElem.addContent( new Element( "axisName", gmlNS).addContent( "x"));
rectifiedGridElem.addContent( new Element( "axisName", gmlNS).addContent( "y"));
if ( zaxis != null )
rectifiedGridElem.addContent( new Element( "axisName", gmlNS ).addContent( "z" ) );
// ../spatialDomain/gml:RectifiedGrid/gml:origin [1]
// ../spatialDomain/gml:RectifiedGrid/gml:origin/gml:pos [1] (space seperated list of double values)
// ../spatialDomain/gml:RectifiedGrid/gml:origin/gml:pos@dimension [0..1] (number of entries in list)
double[] origin = new double[ndim];
origin[0] = xaxis.getStart();
origin[1] = yaxis.getStart();
if ( zaxis != null )
origin[2] = zaxis.getStart();
rectifiedGridElem.addContent(
new Element( "origin", gmlNS).addContent(
new Element( "pos", gmlNS).addContent( genDoubleListString( origin))));
// ../spatialDomain/gml:RectifiedGrid/gml:offsetVector [1..*] (space seperated list of double values)
// ../spatialDomain/gml:RectifiedGrid/gml:offsetVector@dimension [0..1] (number of entries in list)
double[] xoffset = new double[ndim];
xoffset[0] = xaxis.getIncrement();
rectifiedGridElem.addContent(
new Element( "offsetVector", gmlNS)
.addContent( genDoubleListString( xoffset)));
double[] yoffset = new double[ndim];
yoffset[1] = yaxis.getIncrement();
rectifiedGridElem.addContent(
new Element( "offsetVector", gmlNS )
.addContent( genDoubleListString( yoffset ) ) );
if ( zaxis != null )
{
double[] zoffset = new double[ndim];
zoffset[2] = zaxis.getIncrement();
rectifiedGridElem.addContent(
new Element( "offsetVector", gmlNS )
.addContent( genDoubleListString( zoffset ) ) );
}