コード例 #1
0
  /**
   * Resolve COLLADA references relative to the COLLADA document. If the reference is relative then
   * it will resolved relative to the .dae file, not the kml file. If the COLLADA document may be
   * contained in a KMZ archive the resources will be resolved relative to the .dae file within the
   * archive. Normally references in a KMZ are resolved relative to the root of the archive, but
   * Model references are an exception. See
   * https://developers.google.com/kml/documentation/kmzarchives and
   * https://developers.google.com/kml/documentation/kmlreference#model
   *
   * <p>{@inheritDoc}.
   */
  public String resolveFilePath(String path) throws IOException {
    KMLLink link = this.model.getLink();

    // Check the resource map to see if an alias is defined for this resource.
    String alias = this.resourceMap.get(path);
    if (alias != null) path = alias;

    // If the path is relative then resolve it relative to the COLLADA file.
    File f = new File(path);
    if (!f.isAbsolute() && link != null && link.getHref() != null) {
      try {
        URI base = new URI(null, link.getHref(), null);
        URI ref = new URI(null, path, null);

        path = base.resolve(ref).getPath();
      } catch (URISyntaxException ignored) {
        // Ignored
      }
    }

    Object o = this.parent.getRoot().resolveReference(path);
    if (o instanceof URL || o instanceof String) return o.toString();

    return null;
  }
コード例 #2
0
  /**
   * Returns whether this placemark must retrieve its model resource. This always returns <code>
   * false</code> if this placemark has no <code>KMLLink</code>.
   *
   * @return <code>true</code> if this placemark must retrieve its model resource, otherwise <code>
   *     false</code>.
   */
  protected boolean mustRetrieveResource() {
    KMLLink link = this.model.getLink();
    if (link == null) return false;

    // The resource must be retrieved if the link has been updated since the resource was
    // last retrieved, or if the resource has never been retrieved.
    return this.getColladaRoot() == null || link.getUpdateTime() > this.resourceRetrievalTime.get();
  }
コード例 #3
0
  /**
   * Thread's off a task to determine whether the resource is local or remote and then retrieves it
   * either from disk cache or a remote server.
   *
   * @param dc the current draw context.
   */
  protected void requestResource(DrawContext dc) {
    if (WorldWind.getTaskService().isFull()) return;

    KMLLink link = this.model.getLink();
    if (link == null) return;

    String address = link.getAddress(dc);
    if (address != null) address = address.trim();

    if (WWUtil.isEmpty(address)) return;

    WorldWind.getTaskService().addTask(new RequestTask(this, address));
  }