WMTSCapabilitiesAdapter extends OWSCommon110CapabilitiesAdapter { TileMatrix parseTileMatrix( XMLStreamReader xmlStream, ICRS crs ) throws XMLStreamException { nextElement( xmlStream ); skipToRequiredElementOnSameLevel( xmlStream, IDENTIFIER ); String identifier = xmlStream.getElementText().trim(); nextElement( xmlStream ); requireStartElement( xmlStream, singletonList( SCALE_DENOMINATOR ) ); double scaleDenominator = getElementTextAsDouble( xmlStream ); nextElement( xmlStream ); requireStartElement( xmlStream, singletonList( TOP_LEFT_CORNER ) ); double[] topLeftCorner = parsePositionType( xmlStream ); skipElement( xmlStream ); nextElement( xmlStream ); requireStartElement( xmlStream, singletonList( TILE_WIDTH ) ); BigInteger tileSizeX = getElementTextAsBigInteger( xmlStream ); nextElement( xmlStream ); requireStartElement( xmlStream, singletonList( TILE_HEIGHT ) ); BigInteger tileSizeY = getElementTextAsBigInteger( xmlStream ); nextElement( xmlStream ); requireStartElement( xmlStream, singletonList( MATRIX_WIDTH ) ); BigInteger numTilesX = getElementTextAsBigInteger( xmlStream ); nextElement( xmlStream ); requireStartElement( xmlStream, singletonList( MATRIX_HEIGHT ) ); BigInteger numTilesY = getElementTextAsBigInteger( xmlStream ); nextElement( xmlStream ); double resolution = calcResolution( scaleDenominator, crs ); SpatialMetadata spatialMetadata = createSpatialMetadata( crs, resolution, topLeftCorner, tileSizeX, tileSizeY, numTilesX, numTilesY ); return new TileMatrix( identifier, spatialMetadata, tileSizeX, tileSizeY, resolution, numTilesX, numTilesY ); } WMTSCapabilitiesAdapter(); List<Layer> parseLayers(); List<TileMatrixSet> parseTileMatrixSets();  }
@Test public void testParseTileMatrix() throws Exception { XMLStreamReader xmlStream = getResourceXmlStreamReader( "wmts100_tilematrix.xml" ); ICRS crs = CRSManager.getCRSRef( "EPSG:26912" ); assertEquals( START_ELEMENT, xmlStream.getEventType() ); assertEquals( new QName( WMTS_100_NS, "TileMatrix" ), xmlStream.getName() ); TileMatrix tileMatrix = adapter.parseTileMatrix( xmlStream, crs ); assertEquals( END_ELEMENT, xmlStream.getEventType() ); assertEquals( new QName( WMTS_100_NS, "TileMatrix" ), xmlStream.getName() ); assertEquals( "tilematrix1", tileMatrix.getIdentifier() ); assertEquals( 2.0, tileMatrix.getResolution(), 0.000000001 ); assertEquals( 512, tileMatrix.getTilePixelsX() ); assertEquals( 256, tileMatrix.getTilePixelsY() ); assertEquals( 3, tileMatrix.getNumTilesX() ); assertEquals( 4, tileMatrix.getNumTilesY() ); SpatialMetadata spatialMetadata = tileMatrix.getSpatialMetadata(); assertEquals( crs, spatialMetadata.getCoordinateSystems().get( 0 ) ); assertEquals( 441174.0, spatialMetadata.getEnvelope().getMin().get0(), 0.0001 ); assertEquals( 4453991.0, spatialMetadata.getEnvelope().getMin().get1(), 0.0001 ); assertEquals( 444246.0, spatialMetadata.getEnvelope().getMax().get0(), 0.0001 ); assertEquals( 4456039.0, spatialMetadata.getEnvelope().getMax().get1(), 0.0001 ); }