"xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation", "http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd"
}));
WMSMapContext mapContext = (WMSMapContext) o;
GetMapRequest request = mapContext.getRequest();
MapLayer[] layers = mapContext.getLayers();
//calculate scale denominator
scaleDenominator = 1;
try {
scaleDenominator =
RendererUtilities.calculateScale(mapContext.getAreaOfInterest(), mapContext.getMapWidth(), mapContext.getMapHeight(), null);
}
catch( Exception e ) {
LOGGER.log(Level.WARNING, "Error calculating scale denominator", e);
}
LOGGER.log(Level.FINE, "scale denominator = " + scaleDenominator);
//if we have more than one layer ( or a legend was requested ),
//use the name "GeoServer" to group them
boolean group = (layers.length > 1) || request.getLegend();
if (group) {
StringBuffer sb = new StringBuffer();
for ( int i = 0; i < layers.length; i++ ) {
sb.append( layers[i].getTitle() + "," );
}
sb.setLength(sb.length()-1);
start("Document");
element("name", sb.toString() );
}
//for every layer specified in the request
for (int i = 0; i < layers.length; i++) {
//layer and info
MapLayer layer = layers[i];
MapLayerInfo layerInfo = mapContext.getRequest().getLayers()[i];
//was a super overlay requested?
Boolean superoverlay = (Boolean)mapContext.getRequest().getFormatOptions().get("superoverlay");
superoverlay = (superoverlay == null ? Boolean.FALSE : superoverlay);
if (superoverlay) {
//encode as super overlay
encodeSuperOverlayLayer(mapContext, layer);
} else {
//figure out which type of layer this is, raster or vector
if (layerInfo.getType() != MapLayerInfo.TYPE_RASTER) {
//vector
encodeVectorLayer(mapContext, layer);
} else {
//encode as normal ground overlay
encodeRasterLayer(mapContext, layer);
}
}
}
//legend suppoer
if (request.getLegend()) {
//for every layer specified in the request
for (int i = 0; i < layers.length; i++) {
//layer and info
MapLayer layer = layers[i];
encodeLegend(mapContext, layer);