|
  • Code Snippets
Last Published: 2010-12-27

WPS Code Snippet Section

In this section you can find some useful code snippets.

Extract Parameter in your algorithm

The

        public Map<String, IData>   run(Map<String, List<IData>> inputData){

method has one parameter containing all input parameters as key value pairs. The key is the identifier defined in ProcessDescription Document, the value a list of IData objects. In case the ProcessDescription allows multiple input parameters with the same identifier, then the list will contain more then one element. The IData Interface has implementations for specific datastructures. The implementation we are using in this example comes from Geotools as the internal datastructure (GTVectorDataBinding).

        if(inputData==null || !inputData.containsKey("FEATURES")){
                                throw new RuntimeException("Error while allocating input parameters");
                        }
                        
        List<IData> dataList = inputData.get("FEATURES");
        
        if(dataList == null || dataList.size() != 1){
        
                throw new RuntimeException("Error while allocating input parameters");
                
        }
                
        IData firstInputData = dataList.get(0);
        
        FeatureCollection featureCollection = ((GTVectorDataBinding) firstInputData).getPayload();
back top