}
private static void setMapAttribute(final JSONObject attributes,
final PJsonObject oldRequest, final Template template) throws JSONException {
final CreateMapProcessor mapProcessor = getMapProcessor(template);
final PJsonObject oldMapPage = (PJsonObject) getOldMapPage(oldRequest);
if (mapProcessor == null) {
if (oldMapPage == null) {
// no map, no work
return;
} else {
LOGGER.warn("The request json data has attribute information for creating the map but config does not have a" +
"map attribute. Check that the request and the config.yaml are correct.");
return;
}
} else if (oldMapPage == null) {
LOGGER.warn("The request json data does not have attribute information for creating the map." +
" Check that the request and the config.yaml are correct.");
return;
}
String mapAttributeName = "map";
if (mapProcessor.getInputMapperBiMap().containsValue("map")) {
mapAttributeName = mapProcessor.getInputMapperBiMap().inverse().get("map");
}
final JSONObject map = new JSONObject();
attributes.put(mapAttributeName, map);
if (oldRequest.has("srs")) {
map.put("projection", oldRequest.getString("srs"));
}
if (oldRequest.has("dpi")) {
map.put("dpi", oldRequest.getInt("dpi"));
}
if (oldMapPage.has("rotation")) {
map.put("rotation", oldMapPage.getDouble("rotation"));
}
if (oldMapPage.has("bbox")) {
map.put("bbox", oldMapPage.getInternalObj().getJSONArray("bbox"));
} else if (oldMapPage.has("center") && oldMapPage.has("scale")) {
map.put("center", oldMapPage.getInternalObj().getJSONArray("center"));
map.put("scale", oldMapPage.getDouble("scale"));
}
setMapLayers(map, oldRequest);
}