No announcement yet.

Update raster tiles when already in cache

  • Filter
  • Time
  • Show
Clear All
new posts

  • Update raster tiles when already in cache


    I implement my own raster tile layer by extending the BasicTiledImageLayer. The server's data changes periodically and so do the tiled images. The server is able to tell the WorldWind client when which tiled image has changed.

    I don't get it to run to update this changed image tiles, when they are already loaded in cache. I tried to remove the corresponding tiled image in the cache directory and call retrieveRemoteImage manually. The new tiled image is fetched from the server but this will not be updated on the globe of the WorldWindow client. When I restart the client the newly generated tiled images will be displayed correctly.

    I also tried to set the expiration time of the given TextureTile object and called updateMemoryCache but nothing worked for me.

  • #2
    Just a shot in the dark, but in your layer code, you might need to fire an event to force the layer redraw. Add the following to your raster layer after updating the cache:
    There is another more heavy-handed call
    that would force all layers to redraw, but the property change call is the recommended approach.


    • #3
      Unfortunately this does not work either.

      Maybe I should add some more code:
          protected boolean isTileVisible(final DrawContext dc, final TextureTile tile) {
              var visible = super.isTileVisible(dc, tile);
              // convert WW internal format to mercator projection format
              var tileToFetch = new MyTile( tile.getColumn(),                                      // x
                                           (1 << (tile.getLevelNumber() + 3)) - 1 - tile.getRow(), // y
                                            tile.getLevelNumber() + 3);                            // z
              if (visible) {
                  subscribeIfNotDoneYet(tileToFetch.getX(), tileToFetch.getY(), tileToFetch.getZ(), tile);
                  return true;
              unsubscribeIfExists(tileToFetch.getX(), tileToFetch.getY(), tileToFetch.getZ());
              return false;
      I overwrite isTileVisible() to check which tile is currently visible. Next i convert from WW internal xyz format to the mercator xyz format. If the tile is visible I will subscribe for it on the server and put the TextureTile in a map corresponding to the xyz values. If the tile is not visible the subscription will be stopped, if exists.

      Next is the code where I want to do the redrawing of the tiles:
          TextureTile tile = // get tile by x, y and z;
          File f = new File("file:<The hardcoded path to the layers corresponding cache directory>/MyTiles/" +
                                     tile.getColumn() + "/" + tile.getRow() + "/" + tile.getLevelNumber());
          retrieveRemoteImage(tile, "image/png", 1000);
          // what to do here?
          firePropertyChange(AVKey.LAYER, null, this);
      First, I load the TextureTile by the xyz values followed by the deletion of the corresponding image in the cache directory and retrieving the new image from the server. Next, I have no idea what to use. In the code above you can see what I tried last. I add the tile to the cache (I don't know if needed), I update the memory cache of the tile (changed the signature from protected to public, just to try) and the suggested firePropertyChange. I also tried the redraw() of the WW panel. Didn't work either.

      If there are more details needed, I looking forward for questions.


      • #4
        The software development team offers you an opportunity to expand your business and gain huge profits. With the help of custom designed android application you can give an impressive look to your company's website. It is very useful for marketing your products or services. Android software design gives a real life feel to your applications. You can develop various advanced apps according to your own requirements with the help of these software and design tools.
        Last edited by ToryJay; 11-16-2021, 01:46 PM.