public CrustLayer(AVList params) {
    URL url = null;
    try {
      URL context = (URL) params.getValue(AVKeyMore.CONTEXT_URL);
      url = new URL(context, params.getStringValue(AVKey.URL));
    } catch (MalformedURLException e) {
      throw new IllegalArgumentException(e);
    }
    this.url = url;

    this.width = (Integer) params.getValue(AVKey.WIDTH);
    this.height = (Integer) params.getValue(AVKey.HEIGHT);
    this.sector = (Sector) params.getValue(AVKey.SECTOR);

    if (width <= 1 || height <= 1) {
      throw new IllegalArgumentException("Illegal width or height");
    }

    double scale = 1;
    if (params.getValue(AVKeyMore.SCALE) != null) {
      scale = (Double) params.getValue(AVKeyMore.SCALE);
    }
    this.scale = scale;

    boolean wrap = false;
    if (params.getValue(AVKeyMore.WRAP) != null) {
      wrap = (Boolean) params.getValue(AVKeyMore.WRAP);
    }

    indices = generateTriStripIndices(width, height, wrap);
    vertices = Buffers.newDirectDoubleBuffer(width * height * 3);
    colors = Buffers.newDirectDoubleBuffer(width * height * 4);
  }
  protected void loadData(String s) {
    try {
      double[] doubles = parseDoubles(s);

      if (doubles.length != width * height) {
        throw new IOException(
            "File doesn't contain width x height (" + (width * height) + ") values");
      }

      DoubleBuffer buffer = Buffers.newDirectDoubleBuffer(width * height);
      buffer.put(doubles);
      buffer.rewind();

      for (int i = 0; i < width * height; i++) {
        double elev = buffer.get();
        minElevation = Math.min(minElevation, elev);
        maxElevation = Math.max(maxElevation, elev);
      }

      synchronized (elevationLock) {
        this.elevations = buffer;
      }
      // force a recalculate
      lastGlobe = null;
      firePropertyChange(AVKey.LAYER, null, this);
    } catch (IOException e) {
      if (loadAttempts < MAX_DOWNLOAD_ATTEMPTS) {
        loaded = false;
        Downloader.removeCache(url);
        Logging.logger().warning("Deleted corrupt cached data file for " + url);
      } else {
        e.printStackTrace();
      }
    }
  }