Пример #1
0
 /**
  * Returns the specified {@link TileMatrixSet}.
  *
  * @param tileMatrixSetId identifier of the tile matrix set, must not be <code>null</code>
  * @return tile matrix set with the specified identifier or <code>null</code> if there is no such
  *     set
  * @throws XMLStreamException if parsing the <code>wmts:TileMatrixSet</code> elements in the
  *     capabilities document fails
  */
 public TileMatrixSet getTileMatrixSet(String tileMatrixSetId) throws XMLStreamException {
   List<TileMatrixSet> tileMatrixSets = getTileMatrixSets();
   for (TileMatrixSet tileMatrixSet : tileMatrixSets) {
     if (tileMatrixSet.getIdentifier().equals(tileMatrixSetId)) {
       return tileMatrixSet;
     }
   }
   return null;
 }
  @Override
  public TileStore build() {
    try {
      Map<String, TileDataSet> map = new HashMap<String, TileDataSet>();

      for (FileSystemTileStoreJAXB.TileDataSet tds : config.getTileDataSet()) {
        String id = tds.getIdentifier();
        String tmsId = tds.getTileMatrixSetId();
        org.deegree.tile.persistence.filesystem.jaxb.FileSystemTileStoreJAXB.TileDataSet
                .TileCacheDiskLayout
            lay = tds.getTileCacheDiskLayout();

        File baseDir = new File(lay.getLayerDirectory());
        if (!baseDir.isAbsolute()) {
          baseDir = metadata.getLocation().resolveToFile(lay.getLayerDirectory());
        }

        String baseStore = null;
        String baseDataSet = null;
        if (tds.getTileDataSetBase() != null) {
          baseStore = tds.getTileDataSetBase().getTileStoreId();
          baseDataSet = tds.getTileDataSetBase().getValue();
        }

        TileCacheDiskLayout layout = new TileCacheDiskLayout(baseDir, lay.getFileType());

        TileMatrixSet tms = workspace.getResource(TileMatrixSetProvider.class, tmsId);

        List<TileDataLevel> list = new ArrayList<TileDataLevel>(tms.getTileMatrices().size());

        for (TileMatrix tm : tms.getTileMatrices()) {
          list.add(
              new FileSystemTileDataLevel(
                  tm, layout, baseStore, baseDataSet, workspace, metadata, id));
        }

        String format = "image/" + layout.getFileType();

        DefaultTileDataSet dataset = new DefaultTileDataSet(list, tms, format);
        layout.setTileMatrixSet(dataset);
        map.put(id, dataset);
      }

      return new FileSystemTileStore(map, metadata);
    } catch (Exception e) {
      String msg = "Unable to create FileSystemTileStore: " + e.getMessage();
      LOG.error(msg);
      throw new ResourceInitException(msg, e);
    }
  }