Пример #1
0
  private void seedTiles(StorageBroker storageBroker, TileRange tr, final WMSLayer tl)
      throws Exception {
    final String layerName = tl.getName();
    // define the meta tile size to 1,1 so we hit all the tiles
    final TileRangeIterator trIter = new TileRangeIterator(tr, tl.getMetaTilingFactors());

    long[] gridLoc = trIter.nextMetaGridLocation(new long[3]);

    while (gridLoc != null) {
      Map<String, String> fullParameters = tr.getParameters();

      final ConveyorTile tile =
          new ConveyorTile(
              storageBroker,
              layerName,
              tr.getGridSetId(),
              gridLoc,
              tr.getMimeType(),
              fullParameters,
              null,
              null);
      tile.setTileLayer(tl);

      tl.seedTile(tile, false);

      gridLoc = trIter.nextMetaGridLocation(gridLoc);
    }
  }
Пример #2
0
  private List<ConveyorTile> getTiles(StorageBroker storageBroker, TileRange tr, final WMSLayer tl)
      throws Exception {
    final String layerName = tl.getName();
    // define the meta tile size to 1,1 so we hit all the tiles
    final TileRangeIterator trIter = new TileRangeIterator(tr, new int[] {1, 1});

    long[] gridLoc = trIter.nextMetaGridLocation(new long[3]);

    // six concurrent requests max
    ExecutorService requests = Executors.newFixedThreadPool(6);
    ExecutorCompletionService completer = new ExecutorCompletionService(requests);

    List<Future<ConveyorTile>> futures = new ArrayList<Future<ConveyorTile>>();
    while (gridLoc != null) {
      Map<String, String> fullParameters = tr.getParameters();

      final ConveyorTile tile =
          new ConveyorTile(
              storageBroker,
              layerName,
              tr.getGridSetId(),
              gridLoc,
              tr.getMimeType(),
              fullParameters,
              null,
              null);
      futures.add(
          completer.submit(
              new Callable<ConveyorTile>() {

                public ConveyorTile call() throws Exception {
                  try {
                    return tl.getTile(tile);
                  } catch (OutsideCoverageException oce) {
                    return null;
                  }
                }
              }));

      gridLoc = trIter.nextMetaGridLocation(gridLoc);
    }

    // these assertions could be externalized
    List<ConveyorTile> results = new ArrayList<ConveyorTile>();
    for (int i = 0; i < futures.size(); i++) {
      ConveyorTile get = futures.get(i).get();
      if (get != null) {
        results.add(get);
      }
    }

    requests.shutdown();

    return results;
  }
Пример #3
0
  public boolean delete(BlobStore blobStore, TileRange trObj) throws StorageException {
    long layerId = idCache.getLayerId(trObj.getLayerName());
    long formatId = idCache.getFormatId(trObj.getMimeType().getFormat());
    // FRD Set the parameters ID
    long parametersId = -1;
    if (trObj.getParametersId() != null) {
      parametersId = trObj.getParametersId();
    } else if (trObj.getParameters() != null) {
      parametersId = idCache.getParametersId(trObj.getParameters());
      if (-1L != parametersId) {
        trObj.setParametersId(parametersId);
      }
    }
    long gridSetIdId = idCache.getGridSetsId(trObj.getGridSetId());

    for (int zoomLevel = trObj.getZoomStart(); zoomLevel <= trObj.getZoomStop(); zoomLevel++) {
      wrpr.deleteRange(blobStore, trObj, zoomLevel, layerId, formatId, parametersId, gridSetIdId);
    }

    return true;
  }
Пример #4
0
  public boolean expire(TileRange trObj) throws StorageException {
    long layerId = idCache.getLayerId(trObj.getLayerName());
    long formatId = idCache.getFormatId(trObj.getMimeType().getFormat());
    long parametersId = idCache.getParametersId(trObj.getParameters());
    if (-1L != parametersId) {
      trObj.setParametersId(parametersId);
    }
    long gridSetIdId = idCache.getGridSetsId(trObj.getGridSetId());

    for (int zoomLevel = trObj.getZoomStart(); zoomLevel <= trObj.getZoomStop(); zoomLevel++) {
      try {
        wrpr.expireRange(trObj, zoomLevel, layerId, formatId, parametersId, gridSetIdId);

      } catch (SQLException se) {
        log.error(se.getMessage());
      }
    }

    return true;
  }