// Throw an exception if there's no GET_MAP_URL property, or no getMapRequest URL in the WMS Capabilities.
if (mapRequestURIString == null)
{
Logging.logger().severe("WMS.RequestMapURLMissing");
throw new WWRuntimeException(Logging.getMessage("WMS.RequestMapURLMissing"));
}
// ATTN: added by bantchao, worldWInd's code too sensitive
mapRequestURIString = mapRequestURIString.trim(); // should not be needed anymore!
if (mapRequestURIString.length() == 0)
{
Logging.logger().severe("WMS.RequestMapURLMissing");
throw new WWRuntimeException(Logging.getMessage("WMS.RequestMapURLMissing"));
}
// Get the GET_CAPABILITIES_URL from the WMS getCapabilitiesRequest URL.
String capsRequestURIString = caps.getRequestURL("GetCapabilities", "http", "get");
if (params.getValue(AVKey.GET_CAPABILITIES_URL) == null)
{
params.setValue(AVKey.GET_CAPABILITIES_URL, capsRequestURIString);
}
// Define the SERVICE from the GET_MAP_URL property.
params.setValue(AVKey.SERVICE, params.getValue(AVKey.GET_MAP_URL));
String serviceURL = params.getStringValue(AVKey.SERVICE);
if (serviceURL != null)
{
params.setValue(AVKey.SERVICE, WWXML.fixGetMapString(serviceURL));
}
// Define the SERVICE_NAME as the standard OGC WMS service string.
if (params.getValue(AVKey.SERVICE_NAME) == null)
{
params.setValue(AVKey.SERVICE_NAME, OGCConstants.WMS_SERVICE_NAME);
}
// Define the WMS VERSION as the version fetched from the Capabilities document.
String versionString = caps.getVersion();
if (params.getValue(AVKey.WMS_VERSION) == null)
{
params.setValue(AVKey.WMS_VERSION, versionString);
}
// Form the cache path DATA_CACHE_NAME from a set of unique WMS parameters.
if (params.getValue(AVKey.DATA_CACHE_NAME) == null)
{
try
{
URI mapRequestURI = new URI(mapRequestURIString);
String cacheName = WWIO.formPath(mapRequestURI.getAuthority(), mapRequestURI.getPath(), layerNames,
styleNames);
params.setValue(AVKey.DATA_CACHE_NAME, cacheName);
}
catch (URISyntaxException e)
{
String strError = "mapRequestURIString=\"" + mapRequestURIString + "\"\n";
strError += e.getMessage();
GfrDataConfigurationUtils._LOGGER_.warning(strError);
String message = Logging.getMessage("WMS.RequestMapURLBad", mapRequestURIString);
Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
throw new WWRuntimeException(message);
}
}
// Determine image format to request.
if (params.getStringValue(AVKey.IMAGE_FORMAT) == null)
{
String imageFormat = chooseImageFormat(caps.getImageFormats().toArray(), formatOrderPreference);
params.setValue(AVKey.IMAGE_FORMAT, imageFormat);
}
// Throw an exception if we cannot determine an image format to request.
if (params.getStringValue(AVKey.IMAGE_FORMAT) == null)
{
Logging.logger().severe("WMS.NoImageFormats");
throw new WWRuntimeException(Logging.getMessage("WMS.NoImageFormats"));
}
// Determine bounding sector.
Sector sector = (Sector) params.getValue(AVKey.SECTOR);
if (sector == null)
{
for (String name : names)
{
Sector layerSector = caps.getLayerByName(name).getGeographicBoundingBox();
if (layerSector == null)
{
Logging.logger().log(java.util.logging.Level.SEVERE, "WMS.NoGeographicBoundingBoxForLayer", name);
continue;
}
sector = Sector.union(sector, layerSector);
}
if (sector == null)
{
Logging.logger().severe("WMS.NoGeographicBoundingBox");
throw new WWRuntimeException(Logging.getMessage("WMS.NoGeographicBoundingBox"));
}
params.setValue(AVKey.SECTOR, sector);
}