WMTSCapabilitiesAdapter extends OWSCommon110CapabilitiesAdapter { TileMatrixSet parseTileMatrixSet( XMLStreamReader xmlStream ) throws XMLStreamException { nextElement( xmlStream ); skipToRequiredElementOnSameLevel( xmlStream, IDENTIFIER ); String identifier = xmlStream.getElementText().trim(); nextElement( xmlStream ); Envelope boundingBox = null; if ( BOUNDING_BOX.equals( xmlStream.getName() ) ) { skipElement( xmlStream ); boundingBox = parseBoundingBoxType( xmlStream, null ); nextElement( xmlStream ); } requireStartElement( xmlStream, singletonList( SUPPORTED_CRS ) ); String supportedCrs = xmlStream.getElementText().trim(); nextElement( xmlStream ); String wellKnownScaleSet = null; if ( WELL_KNOWN_SCALE_SET.equals( xmlStream.getName() ) ) { wellKnownScaleSet = xmlStream.getElementText().trim(); nextElement( xmlStream ); } skipToRequiredElementOnSameLevel( xmlStream, TILE_MATRIX ); List<TileMatrix> matrices = new ArrayList<TileMatrix>(); ICRS crs = CRSManager.getCRSRef( supportedCrs ); while ( xmlStream.isStartElement() && TILE_MATRIX.equals( xmlStream.getName() ) ) { matrices.add( parseTileMatrix( xmlStream, crs ) ); nextElement( xmlStream ); } if ( boundingBox != null ) { enforceCrs( crs, boundingBox ); } SpatialMetadata spatialMetadata = createSpatialMetadata( crs, boundingBox, matrices ); return new TileMatrixSet( identifier, wellKnownScaleSet, matrices, spatialMetadata, null ); } WMTSCapabilitiesAdapter(); List<Layer> parseLayers(); List<TileMatrixSet> parseTileMatrixSets();  }
@Test public void testParseTileMatrixSetWithoutTopLevelEnvelope() throws Exception { XMLStreamReader xmlStream = getResourceXmlStreamReader( "wmts100_tilematrixset.xml" ); assertEquals( START_ELEMENT, xmlStream.getEventType() ); assertEquals( new QName( WMTS_100_NS, "TileMatrixSet" ), xmlStream.getName() ); TileMatrixSet tileMatrixSet = adapter.parseTileMatrixSet( xmlStream ); assertEquals( END_ELEMENT, xmlStream.getEventType() ); assertEquals( new QName( WMTS_100_NS, "TileMatrixSet" ), xmlStream.getName() ); assertEquals( "Satellite_Provo", tileMatrixSet.getIdentifier() ); SpatialMetadata spatialMetadata = tileMatrixSet.getSpatialMetadata(); assertEquals( "EPSG:26912", spatialMetadata.getCoordinateSystems().get( 0 ).getAlias() ); assertEquals( 441174.0, spatialMetadata.getEnvelope().getMin().get0(), 0.0001 ); assertEquals( 4448359.0, spatialMetadata.getEnvelope().getMin().get1(), 0.0001 ); assertEquals( 447830.0, spatialMetadata.getEnvelope().getMax().get0(), 0.0001 ); assertEquals( 4456039.0, spatialMetadata.getEnvelope().getMax().get1(), 0.0001 ); assertEquals( 4, tileMatrixSet.getTileMatrices().size() ); }