response.setEntity(format.toRepresentation(getContext(namespace, layer, request)));
}
SimpleHash getContext(String namespace, String layer, Request request){
FeatureTypeInfo info = lookupType(namespace, layer);
if (!(Boolean)info.getMetadata().get("indexingEnabled")) {
throw new RestletException(
"Layer indexing disabled",
Status.CLIENT_ERROR_FORBIDDEN
);
}
SimpleHash map = new SimpleHash();
//basic
map.put("title", info.getTitle());
map.put("abstract", info.getAbstract());
//Metadata
map.put("keywords", info.getKeywords());
map.put("declaredCRS", info.getCRS());
map.put("metadataLinks", info.getMetadataLinks());
try {
Object o = info.getNativeCRS();
if (o != null) {
map.put("nativeCRS", info.getNativeCRS());
} else {
map.put("nativeCRS", "No native CRS configured for layer");
}
} catch (Exception e) {
LOGGER.log(Level.WARNING,
"Error trying to get nativeCRS from "
+ info.getName()
+ "FeatureTypeInfo",
e
);
}
String baseUrl = RESTUtils.getBaseURL(request);
map.put("base", baseUrl);
//general parameters for data requests
map.put("name", info.getPrefixedName());
map.put("srs", info.getSRS());
ReferencedEnvelope bbox = getBBOX(info);
String bboxString = bbox.getMinX() + "," + bbox.getMinY() + "," + bbox.getMaxX() + ","
+ bbox.getMaxY();
map.put("bbox", bboxString);
map.put("tilesOrigin", bbox.getMinX()+","+bbox.getMinY());
int[] imageBox = getMapWidthHeight(bbox);
map.put("width", imageBox[0]);
map.put("height", imageBox[1]);
map.put("maxResolution", getMaxResolution(bbox));
try{
map.put("boundingBox", info.boundingBox());
map.put("lonLatBoundingBox", info.getLatLonBoundingBox());
} catch(Exception e) {
LOGGER.log(Level.WARNING, "Error trying to access bounding box or lonLatBoundingBox for " + info.getName() + "FeatureTypeInfo", e);
}
//Fields of Access
map.put("gwc", isGWCAround() + "");
String gwcLink = baseUrl.substring(0,baseUrl.length()-4) + "gwc/";
map.put("gwcLink", gwcLink);
map.put("attributes", info.getAttributes());
return map;
}