コード例 #1
0
  protected DataRaster[] doRead(Object source, AVList params) throws java.io.IOException {
    java.nio.ByteBuffer byteBuffer = this.readElevations(source);

    // If the parameter list is null, or doesn't already have all the necessary metadata, then we
    // copy the parameter
    // list and attempt to populate the copy with any missing metadata.
    if (this.validateMetadata(source, params) != null) {
      // Copy the parameter list to insulate changes from the caller.
      params = (params != null) ? params.copy() : new AVListImpl();
      params.setValue(AVKey.FILE_SIZE, byteBuffer.capacity());
      this.readWorldFiles(source, params);
    }

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

    // Translate the property PIXEL_TYPE to the property DATA_TYPE.
    if (params.getValue(AVKey.DATA_TYPE) == null)
      params.setValue(AVKey.DATA_TYPE, params.getValue(AVKey.PIXEL_TYPE));

    ByteBufferRaster raster = new ByteBufferRaster(width, height, sector, byteBuffer, params);

    // This code expects the string "gov.nasa.worldwind.avkey.MissingDataValue", which now
    // corresponds to the
    // key MISSING_DATA_REPLACEMENT.
    Double missingDataValue = (Double) params.getValue(AVKey.MISSING_DATA_REPLACEMENT);
    if (missingDataValue != null) raster.setTransparentValue(missingDataValue);

    return new DataRaster[] {raster};
  }
コード例 #2
0
    private void convertFeetToMeters(ByteBufferRaster raster) {
      if (null == raster) {
        return;
      }

      int width = raster.getWidth();
      int height = raster.getHeight();

      for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
          raster.setDoubleAtPosition(
              y, x, raster.getDoubleAtPosition(y, x) / WWMath.METERS_TO_FEET);
        }
      }
    }