/** * Build the resource map from the KML Model's <i>ResourceMap</i> element. * * @param model Model from which to create the resource map. * @return Map that relates relative paths in the COLLADA document to paths relative to the KML * document. */ protected Map<String, String> createResourceMap(KMLModel model) { Map<String, String> map = new HashMap<String, String>(); KMLResourceMap resourceMap = model.getResourceMap(); if (resourceMap == null) return Collections.emptyMap(); for (KMLAlias alias : resourceMap.getAliases()) { if (alias != null && !WWUtil.isEmpty(alias.getSourceRef()) && !WWUtil.isEmpty(alias.getTargetHref())) { map.put(alias.getSourceRef(), alias.getTargetHref()); } } return map.size() > 0 ? map : Collections.<String, String>emptyMap(); }
public WMSLayerCapabilities getLayerByName(String name) { if (WWUtil.isEmpty(name)) return null; List<WMSLayerCapabilities> namedLayers = this.getNamedLayers(); for (WMSLayerCapabilities layer : namedLayers) { if (layer.getName().equals(name)) return layer; } return null; }
/** * 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)); }
/** * Create a layer described by an XML layer description. * * @param domElement the XML element describing the layer to create. * @param params any parameters to apply when creating the layer. * @return a new layer * @throws WWUnrecognizedException if the layer type or service type given in the describing * element is unrecognized. * @see #createTiledImageLayer(org.w3c.dom.Element, gov.nasa.worldwind.avlist.AVList). */ protected Layer createFromLayerDocument(Element domElement, AVList params) { String className = WWXML.getText(domElement, "@className"); if (className != null && className.length() > 0) { Layer layer = (Layer) WorldWind.createComponent(className); String actuate = WWXML.getText(domElement, "@actuate"); layer.setEnabled(WWUtil.isEmpty(actuate) || actuate.equals("onLoad")); WWXML.invokePropertySetters(layer, domElement); return layer; } AVList props = WWXML.copyProperties(domElement, null); if (props != null) { // Copy params and add any properties for this layer to the copy if (params != null) props.setValues(params); params = props; } Layer layer; String href = WWXML.getText(domElement, "@href"); if (href != null && href.length() > 0) { Object o = this.createFromConfigSource(href, params); if (o == null) return null; if (!(o instanceof Layer)) { String msg = Logging.getMessage("LayerFactory.UnexpectedTypeForLayer", o.getClass().getName()); throw new WWRuntimeException(msg); } layer = (Layer) o; } else { String layerType = WWXML.getText(domElement, "@layerType"); if (layerType != null && layerType.equals("TiledImageLayer")) { layer = this.createTiledImageLayer(domElement, params); } else { String msg = Logging.getMessage("generic.UnrecognizedLayerType", layerType); throw new WWUnrecognizedException(msg); } } if (layer != null) { String actuate = WWXML.getText(domElement, "@actuate"); layer.setEnabled(actuate != null && actuate.equals("onLoad")); WWXML.invokePropertySetters(layer, domElement); } return layer; }
/** * Determines and stores the network sites to test for public network connectivity. The sites are * drawn from the JVM's gov.nasa.worldwind.avkey.NetworkStatusTestSites property ({@link * AVKey#NETWORK_STATUS_TEST_SITES}). If that property is not defined, the sites are drawn from * the same property in the World Wind or application configuration file. If the sites are not * specified there, the set of sites specified in {@link #DEFAULT_NETWORK_TEST_SITES} are used. To * indicate an empty list in the JVM property or configuration file property, specify an empty * site list, "". */ protected void establishNetworkTestSites() { String testSites = System.getProperty(AVKey.NETWORK_STATUS_TEST_SITES); if (testSites == null) testSites = Configuration.getStringValue(AVKey.NETWORK_STATUS_TEST_SITES); if (testSites == null) { this.networkTestSites.addAll(Arrays.asList(DEFAULT_NETWORK_TEST_SITES)); } else { String[] sites = testSites.split(","); List<String> actualSites = new ArrayList<String>(sites.length); for (String site : sites) { site = WWUtil.removeWhiteSpace(site); if (!WWUtil.isEmpty(site)) actualSites.add(site); } this.setNetworkTestSites(actualSites); } }