/** * 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; }