public static final String FEATURE_COUNT="FEATURE_COUNT";
public static final String FILTER = "Filter";
/** Create a map request given the web request. */
public MapRequest getMapRequest(Request inRequest) throws Exception{
MapRequest tempRequest = new MapRequest();
// the request
tempRequest.setRequest(getRequest(inRequest.getParameter(REQUEST)));
if (tempRequest.getRequest() == MapRequest.REQUEST_GET_MAP){
// the layers
String tempString = inRequest.getParameter(LAYERS);
if (tempString == null) throw new Exception("The parameter "+LAYERS+" is required, it is a comma delimited list of layer names.");
tempRequest.setLayers(getListFromString(tempString));
// the Styles
tempRequest.setStyles(getListFromString(inRequest.getParameter(STYLES)));
// the SRS
setSRS(tempRequest, inRequest.getParameter(SRS));
// the Bounding Box
tempString = inRequest.getParameter(BBOX);
if (tempString == null) throw new Exception("Error Parsing "+BBOX+" minx,miny,maxx,maxy is required for request type "+inRequest.getParameter(REQUEST));
setBoundingBox(tempRequest, inRequest.getParameter(BBOX));
// the width
tempString = inRequest.getParameter(WIDTH);
if (tempString == null) throw new Exception("A value is required for "+WIDTH);
try{
tempRequest.setWidth(Integer.parseInt(tempString));
}
catch (Exception e){throw new Exception ("Error Parsing "+WIDTH+" Value="+tempString);}
// the Height
tempString = inRequest.getParameter(HEIGHT);
if (tempString == null) throw new Exception("A value is required for "+HEIGHT);
try{
tempRequest.setHeight(Integer.parseInt(tempString));
}
catch (Exception e){throw new Exception ("Error Parsing "+HEIGHT+" Value="+tempString);}
// the Format
tempRequest.setFormat(getFormat(inRequest.getParameter(FORMAT)));
// the transparency of the background.
tempString = inRequest.getParameter(TRANSPARENT);
if (tempString != null){
tempRequest.setTransparent(Boolean.getBoolean(tempString));
}
else tempRequest.setTransparent(false);
// the Background Color
tempString = inRequest.getParameter(BGCOLOR);
if (tempString != null){
try{
Color tempColor = new Color(Integer.parseInt(tempString));
tempRequest.setBackgroundColor(tempColor);
}
catch (Exception e){ throw new Exception("Error Parsing "+BGCOLOR+" Value="+tempString);}
}
else tempRequest.setBackgroundColor(Color.white);
// and filters that may be present. (Proprietary Parameter)
String tempFilters = inRequest.getParameter(FILTER);
if (tempFilters != null){
tempRequest.setFilters(getFilters(tempFilters));
}
}
// parse a capabilities request.
if (tempRequest.getRequest() == MapRequest.REQUEST_GET_CAPABILITIES){
// service parameter.
String tempString = inRequest.getParameter(SERVICE);
if (tempString == null) throw new Exception("Error Parsing "+SERVICE+" This parameter must be present and set to the value \"WMS\"");
if (!tempString.equals("WMS")) throw new Exception("Error "+SERVICE+" parameter must equal WMS");
}
// parse a feature info request.
if (tempRequest.getRequest() == MapRequest.REQUEST_GET_FEATURE_INFO){
// the layers
String tempString = inRequest.getParameter(QUERY_LAYERS);
if (tempString == null) throw new Exception("The parameter "+QUERY_LAYERS+" is required, it is a comma delimited list of layer names.");
tempRequest.setLayers(getListFromString(tempString));
// the SRS
setSRS(tempRequest, inRequest.getParameter(SRS));
// the Bounding Box
tempString = inRequest.getParameter(BBOX);
if (tempString == null) throw new Exception("Error Parsing "+BBOX+" minx,miny,maxx,maxy is required for request type "+inRequest.getParameter(REQUEST));
setBoundingBox(tempRequest, inRequest.getParameter(BBOX));
// the width
tempString = inRequest.getParameter(WIDTH);
if (tempString == null) throw new Exception("A value is required for "+WIDTH);
try{
tempRequest.setWidth(Integer.parseInt(tempString));
}
catch (Exception e){throw new Exception ("Error Parsing "+WIDTH+" Value="+tempString);}
// the Height
tempString = inRequest.getParameter(HEIGHT);
if (tempString == null) throw new Exception("A value is required for "+HEIGHT);
try{
tempRequest.setHeight(Integer.parseInt(tempString));
}
catch (Exception e){throw new Exception ("Error Parsing "+HEIGHT+" Value="+tempString);}
// The Info Format.
tempString = inRequest.getParameter(INFO_FORMAT);
tempRequest.setFormat(tempString);
// The Number of features to return information about, default is 1.
tempString = inRequest.getParameter(FEATURE_COUNT);
if (tempString != null){
try{
tempRequest.setFeatureCount(Integer.parseInt(tempString));
}
catch(Exception e){
throw new Exception("Error Parsing "+FEATURE_COUNT+" Must be an integer, value = "+tempString);
}
}
// The X coordinate
tempString = inRequest.getParameter(X_POINT);
if (tempString == null) throw new Exception("Error Parsing "+X_POINT+" A value is required.");
int tempXPoint = 0;
try{tempXPoint = Integer.parseInt(tempString);}catch (Exception e){throw new Exception("Error parsing "+X_POINT+" Not a valid integer Value="+tempString);}
tempRequest.setXPoint(tempXPoint);
// the Y coordinate
tempString = inRequest.getParameter(Y_POINT);
if (tempString == null) throw new Exception("Error Parsing "+Y_POINT+" A value is required.");
int tempYPoint = 0;
try{tempYPoint = Integer.parseInt(tempString);}catch (Exception e){throw new Exception("Error parsing "+Y_POINT+" Not a valid integer Value="+tempString);}
tempRequest.setYPoint(tempYPoint);
}
return tempRequest;
}