protected static AVList wmsGetParamsFromCapsDoc(Capabilities caps, AVList params) {
    if (caps == null) {
      String message = Logging.getMessage("nullValue.WMSCapabilities");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (params == null) {
      String message = Logging.getMessage("nullValue.LayerConfigParams");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    try {
      DataConfigurationUtils.getWMSLayerParams(caps, formatOrderPreference, params);
    } catch (IllegalArgumentException e) {
      String message = Logging.getMessage("WMS.MissingLayerParameters");
      Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
      throw new IllegalArgumentException(message, e);
    } catch (WWRuntimeException e) {
      String message = Logging.getMessage("WMS.MissingCapabilityValues");
      Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
      throw new IllegalArgumentException(message, e);
    }

    setFallbacks(params);

    // Setup WMS URL builder.
    params.setValue(AVKey.WMS_VERSION, caps.getVersion());
    params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(params));
    // Setup default WMS tiled image layer behaviors.
    params.setValue(AVKey.USE_TRANSPARENT_TEXTURES, true);

    return params;
  }
  protected boolean loadTile(Tile tile, java.net.URL url) {
    if (WWIO.isFileOutOfDate(url, this.placeNameServiceSet.getExpiryTime())) {
      // The file has expired. Delete it then request download of newer.
      this.getDataFileStore().removeFile(url);
      String message = Logging.getMessage("generic.DataFileExpired", url);
      Logging.logger().fine(message);
      return false;
    }

    PlaceNameChunk tileData;
    synchronized (this.fileLock) {
      tileData = readTileData(tile, url);
    }

    if (tileData == null) {
      // Assume that something's wrong with the file and delete it.
      this.getDataFileStore().removeFile(url);
      tile.getPlaceNameService()
          .markResourceAbsent(tile.getPlaceNameService().getTileNumber(tile.row, tile.column));
      String message = Logging.getMessage("generic.DeletedCorruptDataFile", url);
      Logging.logger().fine(message);
      return false;
    }

    tile.setDataChunk(tileData);
    WorldWind.getMemoryCache(Tile.class.getName()).add(tile.getFileCachePath(), tile);
    return true;
  }
  public void write(DataRaster raster) throws IOException, IllegalArgumentException {
    if (null == raster) {
      String msg = Logging.getMessage("nullValue.RasterIsNull");
      Logging.logger().finest(msg);
      throw new IllegalArgumentException(msg);
    }

    if (!(raster.getWidth() > 0)) {
      String msg = Logging.getMessage("generic.InvalidWidth", raster.getWidth());
      Logging.logger().finest(msg);
      throw new IllegalArgumentException(msg);
    }

    if (!(raster.getHeight() > 0)) {
      String msg = Logging.getMessage("generic.InvalidHeight", raster.getHeight());
      Logging.logger().finest(msg);
      throw new IllegalArgumentException(msg);
    }

    if (raster instanceof BufferedImageRaster) {
      this.write(((BufferedImageRaster) raster).getBufferedImage(), raster);
    } else if (raster instanceof BufferWrapperRaster) {
      this.writeRaster((BufferWrapperRaster) raster);
    }
  }
예제 #4
0
  @Override
  protected Layer doCreateFromCapabilities(OGCCapabilities caps, AVList params) {
    String serviceName = caps.getServiceInformation().getServiceName();
    if (serviceName == null
        || !(serviceName.equalsIgnoreCase(OGCConstants.WMS_SERVICE_NAME)
            || serviceName.equalsIgnoreCase("WMS"))) {
      String message =
          Logging.getMessage("WMS.NotWMSService", serviceName != null ? serviceName : "null");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (params == null) params = new AVListImpl();

    if (params.getStringValue(AVKey.LAYER_NAMES) == null) {
      // Use the first named layer since no other guidance given
      List<WMSLayerCapabilities> namedLayers = ((WMSCapabilities) caps).getNamedLayers();

      if (namedLayers == null || namedLayers.size() == 0 || namedLayers.get(0) == null) {
        String message = Logging.getMessage("WMS.NoLayersFound");
        Logging.logger().severe(message);
        throw new IllegalStateException(message);
      }

      params.setValue(AVKey.LAYER_NAMES, namedLayers.get(0).getName());
    }

    return new WMSTiledImageLayer((WMSCapabilities) caps, params);
  }
  /**
   * Appends elevation model parameters as elements to a specified context. If a parameter key
   * exists, that parameter is appended to the context. Supported key and element paths are:
   *
   * <table> <th><td>Key</td><td>Name</td><td>Type</td></th>
   * <tr><td>{@link AVKey#DISPLAY_NAME}</td><td>DisplayName</td><td>String</td></tr> <tr><td>{@link
   * AVKey#NETWORK_RETRIEVAL_ENABLED}</td><td>NetworkRetrievalEnabled</td><td>Boolean</td></tr> <tr><td>{@link
   * AVKey#MISSING_DATA_SIGNAL}</td><td>MissingData/@signal</td><td>Double</td></tr> <tr><td>{@link
   * AVKey#MISSING_DATA_REPLACEMENT}</td><td>MissingData/@replacement</td><td>Double</td></tr> <tr><td>{@link
   * AVKey#DETAIL_HINT}</td><td>DataDetailHint</td><td>Double</td></tr> </table>
   *
   * @param params the key-value pairs which define the elevation model parameters.
   * @param context the XML document root on which to append parameter elements.
   * @return a reference to context.
   * @throws IllegalArgumentException if either the parameters or the context are null.
   */
  public static Element createElevationModelElements(AVList params, Element context) {
    if (params == null) {
      String message = Logging.getMessage("nullValue.ParametersIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (context == null) {
      String message = Logging.getMessage("nullValue.ContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    WWXML.checkAndAppendTextElement(params, AVKey.DISPLAY_NAME, context, "DisplayName");
    WWXML.checkAndAppendBooleanElement(
        params, AVKey.NETWORK_RETRIEVAL_ENABLED, context, "NetworkRetrievalEnabled");

    if (params.getValue(AVKey.MISSING_DATA_SIGNAL) != null
        || params.getValue(AVKey.MISSING_DATA_REPLACEMENT) != null) {
      Element el = WWXML.getElement(context, "MissingData", null);
      if (el == null) el = WWXML.appendElementPath(context, "MissingData");

      Double d = AVListImpl.getDoubleValue(params, AVKey.MISSING_DATA_SIGNAL);
      if (d != null) el.setAttribute("signal", Double.toString(d));

      d = AVListImpl.getDoubleValue(params, AVKey.MISSING_DATA_REPLACEMENT);
      if (d != null) el.setAttribute("replacement", Double.toString(d));
    }

    WWXML.checkAndAppendDoubleElement(params, AVKey.DETAIL_HINT, context, "DataDetailHint");

    return context;
  }
  /**
   * @param url the "file:" URL of the file to remove from the file store. Only files in the
   *     writable World Wind disk cache or temp file directory are removed by this method.
   * @throws IllegalArgumentException if <code>url</code> is null
   */
  @SuppressWarnings({"ResultOfMethodCallIgnored"})
  public void removeFile(java.net.URL url) {
    if (url == null) {
      String msg = Logging.getMessage("nullValue.URLIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    try {
      java.io.File file = new java.io.File(url.toURI());

      // This block of code must be synchronized for proper operation. A thread may check that the
      // file exists,
      // and become immediately suspended. A second thread may then delete that file. When the first
      // thread
      // wakes up, file.delete() fails.
      synchronized (this.fileLock) {
        if (file.exists()) {
          // Don't remove files outside the cache or temp directory.
          String parent = file.getParent();
          if (!(parent.startsWith(this.getWriteLocation().getPath())
              || parent.startsWith(Configuration.getSystemTempDirectory()))) return;

          file.delete();
        }
      }
    } catch (java.net.URISyntaxException e) {
      Logging.logger()
          .log(
              Level.SEVERE,
              Logging.getMessage("FileStore.ExceptionRemovingFile", url.toString()),
              e);
    }
  }
  /**
   * @param fileName the name to give the newly created file
   * @return a handle to the newly created file if it could be created and added to the file store,
   *     otherwise null
   * @throws IllegalArgumentException if <code>fileName</code> is null
   */
  public java.io.File newFile(String fileName) {
    if (fileName == null) {
      String message = Logging.getMessage("nullValue.FilePathIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (this.writeLocation != null) {
      String fullPath = makeAbsolutePath(this.writeLocation.getFile(), fileName);
      java.io.File file = new java.io.File(fullPath);
      boolean canCreateFile = false;

      // This block of code must be synchronized for proper operation. A thread may check that
      // file.getParentFile() does not exist, and become immediately suspended. A second thread may
      // then create
      // the parent and ancestor directories. When the first thread wakes up,
      // file.getParentFile().mkdirs()
      // fails, resulting in an erroneous log message: The log reports that the file cannot be
      // created.
      synchronized (this.fileLock) {
        if (file.getParentFile().exists()) canCreateFile = true;
        else if (file.getParentFile().mkdirs()) canCreateFile = true;
      }

      if (canCreateFile) return file;
      else {
        String msg = Logging.getMessage("generic.CannotCreateFile", fullPath);
        Logging.logger().severe(msg);
      }
    }

    return null;
  }
  protected static String determineSingleUserLocation() {
    String home = getUserHomeDir();
    if (home == null) {
      Logging.logger().warning("generic.UsersHomeDirectoryNotKnown");
      return null;
    }

    String path = null;

    if (gov.nasa.worldwind.Configuration.isMacOS()) {
      path = "/Library/Caches";
    } else if (gov.nasa.worldwind.Configuration.isWindowsOS()) {
      // This produces an incorrect path with duplicate parts,
      // like "C:\Users\PatC:\Users\Pat\Application Data".
      // path = System.getenv("USERPROFILE");
      // if (path == null)
      // {
      //    Logging.logger().fine("generic.UsersWindowsProfileNotKnown");
      //    return null;
      // }
      // path += "\\Application Data";

      path = "\\Application Data";
    } else if (gov.nasa.worldwind.Configuration.isLinuxOS()
        || gov.nasa.worldwind.Configuration.isUnixOS()
        || gov.nasa.worldwind.Configuration.isSolarisOS()) {
      path = "/var/cache/";
    } else {
      Logging.logger().fine("generic.UnknownOperatingSystem");
    }

    if (path == null) return null;

    return home + path;
  }
  @SuppressWarnings({"ResultOfMethodCallIgnored"})
  protected void buildWritePaths(org.w3c.dom.Node dataFileCacheNode) {
    javax.xml.xpath.XPathFactory pathFactory = javax.xml.xpath.XPathFactory.newInstance();
    javax.xml.xpath.XPath pathFinder = pathFactory.newXPath();

    try {
      org.w3c.dom.NodeList locationNodes =
          (org.w3c.dom.NodeList)
              pathFinder.evaluate(
                  "/dataFileStore/writeLocations/location",
                  dataFileCacheNode.getFirstChild(),
                  javax.xml.xpath.XPathConstants.NODESET);
      for (int i = 0; i < locationNodes.getLength(); i++) {
        org.w3c.dom.Node location = locationNodes.item(i);
        String prop = pathFinder.evaluate("@property", location);
        String wwDir = pathFinder.evaluate("@wwDir", location);
        String append = pathFinder.evaluate("@append", location);
        String create = pathFinder.evaluate("@create", location);

        String path = buildLocationPath(prop, append, wwDir);
        if (path == null) {
          Logging.logger()
              .log(
                  Level.WARNING,
                  "FileStore.LocationInvalid",
                  prop != null ? prop : Logging.getMessage("generic.Unknown"));
          continue;
        }

        Logging.logger().log(Level.FINER, "FileStore.AttemptingWriteDir", path);
        java.io.File pathFile = new java.io.File(path);
        if (!pathFile.exists()
            && create != null
            && (create.contains("t") || create.contains("T"))) {
          Logging.logger().log(Level.FINER, "FileStore.MakingDirsFor", path);
          pathFile.mkdirs();
        }

        if (pathFile.isDirectory() && pathFile.canWrite() && pathFile.canRead()) {
          Logging.logger().log(Level.FINER, "FileStore.WriteLocationSuccessful", path);
          this.writeLocation = new StoreLocation(pathFile);

          // Remove the writable location from search path if it already exists.
          StoreLocation oldLocation = this.storeLocationFor(path);
          if (oldLocation != null) this.readLocations.remove(oldLocation);

          // Writable location is always first in search path.
          this.readLocations.add(0, this.writeLocation);

          break; // only need one
        }
      }
    } catch (javax.xml.xpath.XPathExpressionException e) {
      String message = Logging.getMessage("FileStore.ExceptionReadingConfigurationFile");
      Logging.logger().severe(message);
      throw new IllegalStateException(message, e);
    }
  }
예제 #10
0
  public void drawOnTo(DataRaster canvas) {
    if (canvas == null) {
      String message = Logging.getMessage("nullValue.DestinationIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
    if (!(canvas instanceof BufferedImageRaster)) {
      String message = Logging.getMessage("DataRaster.IncompatibleRaster", canvas);
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.doDrawOnTo((BufferedImageRaster) canvas);
  }
예제 #11
0
  /**
   * Set the format of a specified value type. See {@link #setDefaultFormats()} for a description
   * and examples of formats.
   *
   * @param formatName a key identifying the value type that is to have the specified format.
   *     Available types are those indicated by the "FORMAT_" constants defined by this class or by
   *     its subclasses
   * @param format the label to use for the specified value type.
   * @throws IllegalArgumentException if either the format or format name are null.
   */
  public void setFormat(String formatName, String format) {
    if (formatName == null) {
      String msg = Logging.getMessage("nullValue.FormatKey");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    if (format == null) {
      String msg = Logging.getMessage("nullValue.Format");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    this.setValue(formatName, format);
  }
예제 #12
0
  /**
   * Set the label of a specified value type. See {@link #setDefaultLabels()} for a description and
   * examples of labels.
   *
   * @param labelName a key identifying the label type. Available names are those indicated by the
   *     "LABEL_" constants defined by this class or by its subclasses
   * @param label the label to use for the specified value type.
   * @throws IllegalArgumentException if either the label or label name is null.
   */
  public void setLabel(String labelName, String label) {
    if (labelName == null) {
      String msg = Logging.getMessage("nullValue.LabelKey");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    if (label == null) {
      String msg = Logging.getMessage("nullValue.Label");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    this.setValue(labelName, label);
  }
예제 #13
0
  /**
   * Create a collection of layer lists and their included layers described by an array of XML
   * layer-list description elements.
   *
   * <p>Any exceptions occurring during creation of the layer lists or their included layers are
   * logged and not re-thrown. The layers associated with the exceptions are not included in the
   * returned layer list.
   *
   * @param elements the XML elements describing the layer lists to create.
   * @param params any parameters to apply when creating the included layers.
   * @return an array containing the specified layer lists.
   */
  protected LayerList[] createLayerLists(Element[] elements, AVList params) {
    ArrayList<LayerList> layerLists = new ArrayList<LayerList>();

    for (Element element : elements) {
      try {
        String href = WWXML.getText(element, "@href");
        if (href != null && href.length() > 0) {
          Object o = this.createFromConfigSource(href, params);
          if (o == null) continue;

          if (o instanceof Layer) {
            LayerList ll = new LayerList();
            ll.add((Layer) o);
            o = ll;
          }

          if (o instanceof LayerList) {
            LayerList list = (LayerList) o;
            if (list != null && list.size() > 0) layerLists.add(list);
          } else if (o instanceof LayerList[]) {
            LayerList[] lists = (LayerList[]) o;
            if (lists != null && lists.length > 0) layerLists.addAll(Arrays.asList(lists));
          } else {
            String msg =
                Logging.getMessage("LayerFactory.UnexpectedTypeForLayer", o.getClass().getName());
            Logging.logger().log(java.util.logging.Level.WARNING, msg);
          }

          continue;
        }

        String title = WWXML.getText(element, "@title");
        Element[] children = WWXML.getElements(element, "./Layer", null);
        if (children != null && children.length > 0) {
          LayerList list = this.createLayerList(children, params);
          if (list != null && list.size() > 0) {
            layerLists.add(list);
            if (title != null && title.length() > 0) list.setValue(AVKey.DISPLAY_NAME, title);
          }
        }
      } catch (Exception e) {
        Logging.logger().log(java.util.logging.Level.WARNING, e.getMessage(), e);
        // keep going to create other layers
      }
    }

    return layerLists.toArray(new LayerList[layerLists.size()]);
  }
예제 #14
0
  /**
   * Specifies the units in which to display area values. Units subsequently formatted by the
   * instance are converted from square meters to the desired units prior to formatting.
   *
   * @param areaUnits the desired length units. See {@link #UnitsFormat(String, String, boolean)}
   *     for the list of those available.
   * @throws IllegalArgumentException if <code>areaUnits</code> is null.
   */
  public void setAreaUnits(String areaUnits) {
    if (areaUnits == null) {
      String msg = Logging.getMessage("nullValue.AreaUnit");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    this.areaUnits = areaUnits;

    if (areaUnits.equals(UnitsFormat.SQUARE_KILOMETERS)) {
      this.areaUnitsMultiplier = WWMath.SQUARE_METERS_TO_SQUARE_KILOMETERS;
      this.areaUnitsSymbol = UnitsFormat.SYMBOL_SQUARE_KILOMETERS;
    } else if (areaUnits.equals(UnitsFormat.SQUARE_MILES)) {
      this.areaUnitsMultiplier = WWMath.SQUARE_METERS_TO_SQUARE_MILES;
      this.areaUnitsSymbol = UnitsFormat.SYMBOL_SQUARE_MILES;
    } else if (areaUnits.equals(UnitsFormat.HECTARE)) {
      this.areaUnitsMultiplier = WWMath.SQUARE_METERS_TO_HECTARES;
      this.areaUnitsSymbol = UnitsFormat.SYMBOL_HECTARE;
    } else if (areaUnits.equals(UnitsFormat.ACRE)) {
      this.areaUnitsMultiplier = WWMath.SQUARE_METERS_TO_ACRES;
      this.areaUnitsSymbol = UnitsFormat.SYMBOL_ACRE;
    } else if (areaUnits.equals(UnitsFormat.SQUARE_YARDS)) {
      this.areaUnitsMultiplier = WWMath.SQUARE_METERS_TO_SQUARE_YARDS;
      this.areaUnitsSymbol = UnitsFormat.SYMBOL_SQUARE_YARDS;
    } else if (areaUnits.equals(UnitsFormat.SQUARE_FEET)) {
      this.areaUnitsMultiplier = WWMath.SQUARE_METERS_TO_SQUARE_FEET;
      this.areaUnitsSymbol = UnitsFormat.SYMBOL_SQUARE_FEET;
    } else {
      this.areaUnitsMultiplier = 1d;
      this.areaUnitsSymbol = UnitsFormat.SYMBOL_SQUARE_METERS;
    }
  }
  private java.nio.ByteBuffer readElevations(Object source) throws java.io.IOException {
    if (!(source instanceof java.io.File) && !(source instanceof java.net.URL)) {
      String message = Logging.getMessage("DataRaster.CannotRead", source);
      Logging.logger().severe(message);
      throw new java.io.IOException(message);
    }

    if (source instanceof java.io.File) {
      java.io.File file = (java.io.File) source;

      // handle .bil.zip, .bil16.zip, and .bil32.gz files
      if (file.getName().toLowerCase().endsWith(".zip")) {
        return WWIO.readZipEntryToBuffer(file, null);
      }
      // handle bil.gz, bil16.gz, and bil32.gz files
      else if (file.getName().toLowerCase().endsWith(".gz")) {
        return WWIO.readGZipFileToBuffer(file);
      } else if (!this.isMapLargeFiles() || (this.getLargeFileThreshold() > file.length())) {
        return WWIO.readFileToBuffer(file);
      } else {
        return WWIO.mapFile(file);
      }
    } else // (source instanceof java.net.URL)
    {
      java.net.URL url = (java.net.URL) source;
      return WWIO.readURLContentToBuffer(url);
    }
  }
예제 #16
0
  /**
   * Specifies the units in which to display length values. Units subsequently formatted by the
   * instance are converted from meters to the desired units prior to formatting.
   *
   * @param lengthUnits the desired length units. See {@link #UnitsFormat(String, String, boolean)}
   *     for the list of those available.
   * @throws IllegalArgumentException if <code>lengthUnits</code> is null.
   */
  public void setLengthUnits(String lengthUnits) {
    if (lengthUnits == null) {
      String msg = Logging.getMessage("nullValue.LengthUnit");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    this.lengthUnits = lengthUnits;

    if (lengthUnits.equals(UnitsFormat.KILOMETERS)) {
      this.lengthUnitsMultiplier = WWMath.METERS_TO_KILOMETERS;
      this.lengthUnitsSymbol = UnitsFormat.SYMBOL_KILOMETERS;
    } else if (lengthUnits.equals(UnitsFormat.MILES)) {
      this.lengthUnitsMultiplier = WWMath.METERS_TO_MILES;
      this.lengthUnitsSymbol = UnitsFormat.SYMBOL_MILES;
    } else if (lengthUnits.equals(UnitsFormat.NAUTICAL_MILES)) {
      this.lengthUnitsMultiplier = WWMath.METERS_TO_NAUTICAL_MILES;
      this.lengthUnitsSymbol = UnitsFormat.SYMBOL_NAUTICAL_MILES;
    } else if (lengthUnits.equals(UnitsFormat.YARDS)) {
      this.lengthUnitsMultiplier = WWMath.METERS_TO_YARDS;
      this.lengthUnitsSymbol = UnitsFormat.SYMBOL_YARDS;
    } else if (lengthUnits.equals(UnitsFormat.FEET)) {
      this.lengthUnitsMultiplier = WWMath.METERS_TO_FEET;
      this.lengthUnitsSymbol = UnitsFormat.SYMBOL_FEET;
    } else {
      this.lengthUnitsMultiplier = 1d;
      this.lengthUnitsSymbol = UnitsFormat.SYMBOL_METERS;
    }
  }
예제 #17
0
  public BufferedImageRaster(int width, int height, int transparency, Sector sector) {
    super(width, height, sector);

    if (width < 1) {
      String message = Logging.getMessage("generic.InvalidWidth", width);
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
    if (height < 1) {
      String message = Logging.getMessage("generic.InvalidHeight", height);
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.bufferedImage = ImageUtil.createCompatibleImage(width, height, transparency);
  }
예제 #18
0
  /**
   * @param placeNameServiceSet the set of PlaceNameService objects that PlaceNameLayer will render.
   * @throws IllegalArgumentException if {@link
   *     gov.nasa.worldwind.layers.placename.PlaceNameServiceSet} is null
   */
  public PlaceNameLayer(PlaceNameServiceSet placeNameServiceSet) {
    if (placeNameServiceSet == null) {
      String message = Logging.getMessage("nullValue.PlaceNameServiceSetIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    //
    this.placeNameServiceSet = placeNameServiceSet.deepCopy();
    for (int i = 0; i < this.placeNameServiceSet.getServiceCount(); i++) {
      // todo do this for long as well and pick min
      int calc1 =
          (int)
              (PlaceNameService.TILING_SECTOR.getDeltaLatDegrees()
                  / this.placeNameServiceSet
                      .getService(i)
                      .getTileDelta()
                      .getLatitude()
                      .getDegrees());
      int numLevels = (int) Math.log(calc1);
      navTiles.add(
          new NavigationTile(
              this.placeNameServiceSet.getService(i),
              PlaceNameService.TILING_SECTOR,
              numLevels,
              "top"));
    }

    if (!WorldWind.getMemoryCacheSet().containsCache(Tile.class.getName())) {
      long size = Configuration.getLongValue(AVKey.PLACENAME_LAYER_CACHE_SIZE, 2000000L);
      MemoryCache cache = new BasicMemoryCache((long) (0.85 * size), size);
      cache.setName("Placename Tiles");
      WorldWind.getMemoryCacheSet().addCache(Tile.class.getName(), cache);
    }
  }
예제 #19
0
  public static DataRaster wrap(BufferedImage image, AVList params) {
    if (null == image) {
      String message = Logging.getMessage("nullValue.ImageIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (null == params) {
      String msg = Logging.getMessage("nullValue.AVListIsNull");
      Logging.logger().finest(msg);
      throw new IllegalArgumentException(msg);
    }

    if (params.hasKey(AVKey.WIDTH)) {
      int width = (Integer) params.getValue(AVKey.WIDTH);
      if (width != image.getWidth()) {
        String msg =
            Logging.getMessage("generic.InvalidWidth", "" + width + "!=" + image.getWidth());
        Logging.logger().finest(msg);
        throw new IllegalArgumentException(msg);
      }
    } else {
      params.setValue(AVKey.WIDTH, image.getWidth());
    }

    if (params.hasKey(AVKey.HEIGHT)) {
      int height = (Integer) params.getValue(AVKey.HEIGHT);
      if (height != image.getHeight()) {
        String msg =
            Logging.getMessage("generic.InvalidHeight", "" + height + "!=" + image.getHeight());
        Logging.logger().finest(msg);
        throw new IllegalArgumentException(msg);
      }
    } else {
      params.setValue(AVKey.HEIGHT, image.getHeight());
    }

    Sector sector = null;
    if (params.hasKey(AVKey.SECTOR)) {
      Object o = params.getValue(AVKey.SECTOR);
      if (o instanceof Sector) {
        sector = (Sector) o;
      }
    }

    return new BufferedImageRaster(sector, image, params);
  }
예제 #20
0
 static int computeColumn(Angle delta, Angle longitude) {
   if (delta == null || longitude == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return (int) ((longitude.getDegrees() + 180d) / delta.getDegrees());
 }
  @Override
  public BufferedImage composeImageForSector(
      Sector sector,
      int canvasWidth,
      int canvasHeight,
      double aspectRatio,
      int levelNumber,
      String mimeType,
      boolean abortOnError,
      BufferedImage image,
      int timeout)
      throws Exception {
    if (sector == null) {
      String message = Logging.getMessage("nullValue.SectorIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    ComposeImageTile tile =
        new ComposeImageTile(
            sector, mimeType, this.getLevels().getLastLevel(), canvasWidth, canvasHeight);
    try {
      if (image == null)
        image = new BufferedImage(canvasWidth, canvasHeight, BufferedImage.TYPE_INT_RGB);

      downloadImage(tile, mimeType, timeout);
      Thread.sleep(1); // generates InterruptedException if thread has been interupted

      BufferedImage tileImage = ImageIO.read(tile.getFile());
      Thread.sleep(1); // generates InterruptedException if thread has been interupted

      ImageUtil.mergeImage(sector, tile.getSector(), aspectRatio, tileImage, image);
      Thread.sleep(1); // generates InterruptedException if thread has been interupted

      this.firePropertyChange(AVKey.PROGRESS, 0d, 1d);
    } catch (InterruptedIOException e) {
      throw e;
    } catch (Exception e) {
      if (abortOnError) throw e;

      String message = Logging.getMessage("generic.ExceptionWhileRequestingImage", tile.getPath());
      Logging.logger().log(java.util.logging.Level.WARNING, message, e);
    }

    return image;
  }
예제 #22
0
 static Angle computeRowLatitude(int row, Angle delta) {
   if (delta == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return Angle.fromDegrees(-90d + delta.getDegrees() * row);
 }
예제 #23
0
 static Angle computeColumnLongitude(int column, Angle delta) {
   if (delta == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return Angle.fromDegrees(-180 + delta.getDegrees() * column);
 }
예제 #24
0
  /**
   * Format angles of latitude and longitude according to the current angle format, and append a
   * new-line character.
   *
   * <p>The values are formatted using the current {@link #LABEL_LATLON_LAT}, {@link
   * #LABEL_LATLON_LON} and angle format.
   *
   * @param latlon the angles to format.
   * @return a string containing the formatted angles and ending with the new-line character.
   * @throws IllegalArgumentException if <code>latlon</code> is null.
   */
  public String latLonNL(LatLon latlon) {
    if (latlon == null) {
      String msg = Logging.getMessage("nullValue.LatLonIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    return this.latLon(latlon) + NL;
  }
예제 #25
0
  /**
   * Format an angle according to the current angle format. Prepend a specified label and append a
   * new-line character.
   *
   * @param label a label to prepend to the formatted angle. May be null to indicate no label.
   * @param angle the angle to format.
   * @return a string containing the formatted angle prepended with the specified label and ending
   *     with the new-line character.
   * @throws IllegalArgumentException if the angle is null.
   */
  public String angleNL(String label, Angle angle) {
    if (angle == null) {
      String msg = Logging.getMessage("nullValue.AngleIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    return this.angle(label, angle) + NL;
  }
예제 #26
0
  /**
   * Format an angle of heading according to the current angle format.
   *
   * <p>The value is formatted using the current {@link #LABEL_HEADING} and angle format.
   *
   * @param angle the heading angle to format.
   * @return a string containing the formatted angle.
   * @throws IllegalArgumentException if the angle is null.
   */
  public String heading(Angle angle) {
    if (angle == null) {
      String msg = Logging.getMessage("nullValue.AngleIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    return this.angle(this.getLabel(LABEL_HEADING), angle);
  }
예제 #27
0
  /**
   * Format an angle of longitude and append a new-line character.
   *
   * <p>The value is formatted using the current {@link #LABEL_LONGITUDE} and angle format.
   *
   * @param angle the angle to format.
   * @return a string containing the formatted angle and ending with the new-line character.
   */
  public String longitudeNL(Angle angle) {
    if (angle == null) {
      String msg = Logging.getMessage("nullValue.AngleIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    return this.angleNL(this.getLabel(LABEL_LONGITUDE), angle);
  }
  public GeotiffWriter(File file) throws IOException {
    if (null == file) {
      String msg = Logging.getMessage("nullValue.FileIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    commonInitializer(file);
  }
예제 #29
0
  /**
   * Returns the label for a spcified label name.
   *
   * @param labelName the name of the label to return.
   * @return the label, or null if the label does not exist.
   * @throws IllegalArgumentException if the label name is null.
   */
  public String getLabel(String labelName) {
    if (labelName == null) {
      String msg = Logging.getMessage("nullValue.LabelKey");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    return this.getStringValue(labelName);
  }
예제 #30
0
  /**
   * Returns the format for a spcified value type.
   *
   * @param formatName the name of the value type whose format is desired.
   * @return the format, or null if the format does not exist.
   * @throws IllegalArgumentException if the format name is null.
   */
  public String getFormat(String formatName) {
    if (formatName == null) {
      String msg = Logging.getMessage("nullValue.FormatKey");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    return this.getStringValue(formatName);
  }