private void exportTileMatrixSet( TileMatrixSet tms ) throws XMLStreamException { writer.writeStartElement( WMTSNS, "TileMatrixSet" ); exportMetadata( null, true, tms.getIdentifier(), null ); ICRS cs = tms.getSpatialMetadata().getCoordinateSystems().get( 0 ); writeElement( writer, OWS110_NS, "SupportedCRS", cs.getAlias() ); String wknScaleSet = tms.getWellKnownScaleSet(); if ( wknScaleSet != null ) { writeElement( writer, WMTSNS, "WellKnownScaleSet", wknScaleSet ); } for ( TileMatrix tm : tms.getTileMatrices() ) { writer.writeStartElement( WMTSNS, "TileMatrix" ); double scale; if ( cs.getUnits()[0].equals( Unit.DEGREE ) && wknScaleSet == null ) { scale = MapUtils.calcScaleFromDegrees( tm.getResolution() ); } else { scale = tm.getResolution() / DEFAULT_PIXEL_SIZE; } writeElement( writer, OWS110_NS, "Identifier", tm.getIdentifier() ); writeElement( writer, WMTSNS, "ScaleDenominator", scale + "" ); Envelope env = tm.getSpatialMetadata().getEnvelope(); writeElement( writer, WMTSNS, "TopLeftCorner", env.getMin().get0() + " " + env.getMax().get1() ); writeElement( writer, WMTSNS, "TileWidth", "" + tm.getTilePixelsX() ); writeElement( writer, WMTSNS, "TileHeight", "" + tm.getTilePixelsY() ); writeElement( writer, WMTSNS, "MatrixWidth", "" + tm.getNumTilesX() ); writeElement( writer, WMTSNS, "MatrixHeight", "" + tm.getNumTilesY() ); writer.writeEndElement(); } writer.writeEndElement(); }