@Override
  protected boolean handleElevations(
      Globe globe, TextureTile tile, Sector sector, BufferWrapper[] elevations) {
    int width = tile.getLevel().getTileWidth();
    int height = tile.getLevel().getTileHeight();

    double[] minmax = getMinMax(elevations[4], elevationModel.getMissingDataSignal());
    byte[][] bytes =
        elevationsToTexture(width, height, globe, sector, elevations, minmax[0], minmax[1]);

    File file = WorldWind.getDataFileStore().newFile(tile.getPath());
    return saveTexture(file, bytes, width, height, minmax[0], minmax[1]);
  }
  @Override
  protected Texture createTexture(TextureTile tile) {
    if (!(tile instanceof MinMaxTextureTile)) {
      String message = "Tile is not instance of " + MinMaxTextureTile.class;
      Logging.logger().severe(message);
      throw new IllegalStateException(message);
    }

    MinMaxTextureTile mmtt = (MinMaxTextureTile) tile;
    return new ElevationTexture(
        tile.getTextureData(), mmtt.getMinElevation(), mmtt.getMaxElevation());
  }
  @Override
  protected boolean loadTexture(TextureTile tile, URL textureURL) {
    if (!(tile instanceof MinMaxTextureTile)) {
      Logging.logger().severe("Tile is not instance of " + MinMaxTextureTile.class);
      getLevels().markResourceAbsent(tile);
      return false;
    }

    synchronized (fileLock) {
      InputStream is = null;
      try {
        is = textureURL.openStream();
        DataInputStream dis = new DataInputStream(is);

        int width = dis.readInt();
        int height = dis.readInt();
        int bands = dis.readInt();
        double minElevation = dis.readDouble();
        double maxElevation = dis.readDouble();
        byte[][] bytes = new byte[bands][];
        for (int i = 0; i < bands; i++) {
          bytes[i] = new byte[width * height];
          is.read(bytes[i]);
        }

        DataBuffer db = new DataBufferByte(bytes, width * height);
        SampleModel sm = new BandedSampleModel(DataBuffer.TYPE_BYTE, width, height, bands);
        Raster raster = Raster.createRaster(sm, db, null);
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
        image.setData(raster);

        TextureData textureData = TextureIO.newTextureData(image, isUseMipMaps());
        if (textureData == null) {
          throw new Exception("Could not create texture data for " + textureURL);
        }

        ((MinMaxTextureTile) tile).setMinElevation(minElevation);
        ((MinMaxTextureTile) tile).setMaxElevation(maxElevation);
        tile.setTextureData(textureData);

        // if (tile.getLevelNumber() != 0 || !this.isRetainLevelZeroTiles())
        addTileToCache(tile);

        getLevels().unmarkResourceAbsent(tile);
        firePropertyChange(AVKey.LAYER, null, this);
        return true;
      } catch (Exception e) {
        // Assume that something's wrong with the file and delete it.
        gov.nasa.worldwind.WorldWind.getDataFileStore().removeFile(textureURL);
        getLevels().markResourceAbsent(tile);
        String message = Logging.getMessage("generic.DeletedCorruptDataFile", textureURL);
        Logging.logger().info(message + ":" + e.getLocalizedMessage());
        return false;
      } finally {
        if (is != null) {
          try {
            is.close();
          } catch (IOException e) {
          }
        }
      }
    }
  }