Package gistoolkit.server

Examples of gistoolkit.server.MapRequest


    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;
    }
View Full Code Here


    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)));
       
        // parse a map 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(inRequest.getParameter(LAYERS)));

            // 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){
            // There are no other parameters for a 1.0.0 get capabilities request.
        }
        // 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);
            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);
            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;
    }
View Full Code Here

    public static MapRequest getMapRequest(Request inRequest) throws Exception{
        // find the version
        String tempVersion = inRequest.getParameter("VERSION");
        if (tempVersion == null) tempVersion = inRequest.getParameter("WMTVER");
       
        MapRequest tempRequest = null;
       
        // check for the 1.1.1 version
        if ((tempVersion == null) || (tempVersion.equalsIgnoreCase("1.1.1"))){
            OGCParser tempParser = new OGC1_1_1Parser();
            tempRequest = tempParser.getMapRequest(inRequest);
View Full Code Here

TOP

Related Classes of gistoolkit.server.MapRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.