Source:
<code>private TileMatrixSet selectMatrixSet() throws ServiceException, RuntimeException { TileMatrixSet retMatrixSet = null; Map<String, TileMatrixSetLink> links = layer.getTileMatrixLinks(); CoordinateReferenceSystem requestCRS = getCrs(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("request CRS " + (requestCRS == null ? "NULL" : requestCRS.getName())); } if (requestCRS == null) { try { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("request CRS decoding" + srs); } requestCRS = CRS.decode(srs); } catch (FactoryException e) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.log(Level.FINER, e.getMessage(), e); } throw new RuntimeException(e); } } for (TileMatrixSet matrixSet : capabilities.getMatrixSets()) { CoordinateReferenceSystem matrixCRS = matrixSet.getCoordinateReferenceSystem(); <START> String requestSRS = CRS.toSRS(requestCRS); <END> String matrixSRS = CRS.toSRS(matrixCRS); if (requestSRS.equals(matrixSRS)) { if (links.containsKey((matrixSet.getIdentifier()))) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("selected matrix set:" + matrixSet.getIdentifier()); } setProperty(TILEMATRIXSET, matrixSet.getIdentifier()); retMatrixSet = matrixSet; break; } } } if (retMatrixSet == null) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info( "Failed to match the requested CRS (" + requestCRS.getName() + ") with any of the tile matrices!"); } for (TileMatrixSet matrix : capabilities.getMatrixSets()) { if (links.containsKey((matrix.getIdentifier()))) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("defaulting matrix set:" + matrix.getIdentifier()); } setProperty(TILEMATRIXSET, matrix.getIdentifier()); retMatrixSet = matrix; break; } } } if (retMatrixSet == null) { throw new ServiceException( "Unable to find a matching TileMatrixSet for layer " + layer.getName() + " and SRS: " + requestCRS.getName()); } return retMatrixSet; }</code><technical_language>need convert in loop, done outside</technical_language>

Target:
private TileMatrixSet selectMatrixSet() throws ServiceException, RuntimeException { TileMatrixSet retMatrixSet = null; Map<String, TileMatrixSetLink> links = layer.getTileMatrixLinks(); CoordinateReferenceSystem requestCRS = getCrs(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("request CRS " + (requestCRS == null ? "NULL" : requestCRS.getName())); } if (requestCRS == null) { try { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("request CRS decoding" + srs); } requestCRS = CRS.decode(srs); } catch (FactoryException e) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.log(Level.FINER, e.getMessage(), e); } throw new RuntimeException(e); } } String requestSRS = CRS.toSRS(requestCRS); for (TileMatrixSet matrixSet : capabilities.getMatrixSets()) { CoordinateReferenceSystem matrixCRS = matrixSet.getCoordinateReferenceSystem(); String matrixSRS = CRS.toSRS(matrixCRS); if (requestSRS.equals(matrixSRS)) { if (links.containsKey((matrixSet.getIdentifier()))) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("selected matrix set:" + matrixSet.getIdentifier()); } setProperty(TILEMATRIXSET, matrixSet.getIdentifier()); retMatrixSet = matrixSet; break; } } } if (retMatrixSet == null) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info( "Failed to match the requested CRS (" + requestCRS.getName() + ") with any of the tile matrices!"); } for (TileMatrixSet matrix : capabilities.getMatrixSets()) { if (links.containsKey((matrix.getIdentifier()))) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("defaulting matrix set:" + matrix.getIdentifier()); } setProperty(TILEMATRIXSET, matrix.getIdentifier()); retMatrixSet = matrix; break; } } } if (retMatrixSet == null) { throw new ServiceException( "Unable to find a matching TileMatrixSet for layer " + layer.getName() + " and SRS: " + requestCRS.getName()); } return retMatrixSet; }