Displaying differences for changeset
 
display as  

src/java/services/Region.java

@@ -33,16 +33,11 @@
     protected String regionObject = "        {\n"
             + "            \"name\": \"field_boundary\",\n"
             + "            \"value\": {\n"
-            + "                \"type\": \"FeatureCollection\",\n"
-            + "                \"crs\": {\n"
-            + "                    \"type\": \"name\",\n"
-            + "                    \"properties\": {\n"
-            + "                        \"name\": \"urn:ogc:def:crs:EPSG:7.9.8:4326\"\n"
-            + "                    }\n"
-            + "                },\n"
+            + "                \"type\": \"FeatureCollection\",\n"            
             + "                \"features\": [\n"
             + "                    {\n"
-            + "                        \"type\": \"Feature\",";
+            + "                        \"type\": \"Feature\","
+            + "                          \"geometry\":";
 
     protected String regionObjectFinish = ",\n"
             + "                        \"properties\": {}\n"
@@ -75,11 +70,10 @@
             request.put(KEY_METAINFO, requestMetainfoObject);
 
             if (null != feature) {
-                requestData.put("geometry", feature);
-                regionObject += requestData.toString() + regionObjectFinish;
+                regionObject += feature.toString() + regionObjectFinish;
                 requestData = new JSONObject(regionObject);
-                request.put(KEY_PARAMETER, requestData);
-
+                dataArray.put(requestData);
+                request.put(KEY_PARAMETER, dataArray);
             } else {
                 throwServiceCallException("No input shape was specified to the region service call object.");
             }

src/java/services/WEPP.java

@@ -16,8 +16,6 @@
 import csip.ServiceException;
 import csip.utils.JSONUtils;
 import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -67,8 +65,11 @@
         try {
             //  Get the climate file and store it.
             Map<String, JSONObject> resultMap = JSONUtils.getResults(results);
-
-
+            if ( resultMap.containsKey("SoilLoss")){
+                waterErosion = JSONUtils.getDoubleParam(resultMap, "SoilLoss",Double.NaN);                
+            }else{
+                throwServiceCallException("Cannot find the SoilLoss result.");
+            }
         } catch (JSONException ex) {
             throwServiceCallException("Error trying to find results section", ex);
         } 
@@ -85,7 +86,7 @@
         try {
             requestMetainfoObject.put("MultipartRequest", "Bundled Service Request From csip-crp MetaModeling CliWindSoil Service");
             requestMetainfoObject.put("CRPAssessment_Metainfo", metaInfo);
-            requestMetainfoObject.put("mode", "sync");            
+            requestMetainfoObject.put("mode", "sync");     
             request.put(KEY_METAINFO, requestMetainfoObject);
             
             //  Non-Changing values
@@ -100,7 +101,7 @@
             //  User or other service provided values            
             dataArray.put(JSONUtils.data("latitude", latitude));
             dataArray.put(JSONUtils.data("longitude", longitude));
-            dataArray.put(JSONUtils.data("soilPtr", "[" + cokey + "]"));
+            dataArray.put(JSONUtils.data("soilPtr", new JSONArray().put(cokey)));
             dataArray.put(JSONUtils.data("length", length));          
             dataArray.put(JSONUtils.data("slope_steepness", steepness));      
             
@@ -108,6 +109,7 @@
             dataArray.put(rotation);            
             
             request.put(KEY_PARAMETER, dataArray);
+            System.out.println(request.toString());
 
         } catch (JSONException ex) {
             throwServiceCallException("Cannot create the JSON request.", ex);

src/java/services/WEPS.java

@@ -16,8 +16,6 @@
 import csip.ServiceException;
 import csip.utils.JSONUtils;
 import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -35,12 +33,17 @@
     private JSONObject rotation;
     private double latitude, longitude, regionLength, regionWidth, regionOrientation;
     private String cokey;
+    private WEPSFallowRotation fallowRotation;
 
     public WEPS(JSONObject metaInfo, double _latitude, double _longitude, double _regionLength, double _regionWidth,
-            double _regionOrientation, String _cokey, JSONObject _rotation, String URI) {
+            double _regionOrientation, String _cokey, JSONObject _rotation, String URI) throws JSONException {
         super(URI);
         this.metaInfo = metaInfo;
-        rotation = _rotation;
+        if (null == _rotation) {
+            rotation = new WEPSFallowRotation(0).rotation();
+        } else {
+            rotation = _rotation;
+        }
         latitude = _latitude;
         longitude = _longitude;
         cokey = _cokey;
@@ -67,7 +70,11 @@
         try {
             //  Get the climate file and store it.
             Map<String, JSONObject> resultMap = JSONUtils.getResults(results);
-
+            if ( resultMap.containsKey("wind_eros")){
+                windErosion = JSONUtils.getDoubleParam(resultMap, "wind_eros",Double.NaN);                
+            }else{
+                throwServiceCallException("Cannot find the wind_eros result.");
+            }
         } catch (JSONException ex) {
             throwServiceCallException("Error trying to find results section", ex);
         }
@@ -85,7 +92,7 @@
             requestMetainfoObject.put("MultipartRequest", "Bundled Service Request From csip-crp MetaModeling CliWindSoil Service");
             requestMetainfoObject.put("CRPAssessment_Metainfo", metaInfo);
             requestMetainfoObject.put("mode", "sync");
-            
+
             request.put(KEY_METAINFO, requestMetainfoObject);
 
             JSONArray windBarriers = new JSONArray();
@@ -112,9 +119,9 @@
             dataArray.put(JSONUtils.data("field_length", regionLength));
             dataArray.put(JSONUtils.data("field_width", regionWidth));
             dataArray.put(JSONUtils.data("field_orientation", regionOrientation));
-            
+
             //  Rotation object retrieved from CRP Database
-            dataArray.put(rotation);            
+            dataArray.put(rotation);
 
             request.put(KEY_PARAMETER, dataArray);
 

src/java/services/WWESoilParams.java

@@ -15,9 +15,6 @@
 import static csip.ModelDataService.KEY_PARAMETER;
 import csip.ServiceException;
 import csip.utils.JSONUtils;
-import gisobjects.GISObject;
-import gisobjects.GISObjectException;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map;
@@ -27,7 +24,6 @@
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
-import soils.Component;
 import utils.ServiceCall;
 
 /**
@@ -93,7 +89,7 @@
                     JSONArray mapUnitData = mapUnitList.getJSONArray(i);
                     Map<String, JSONObject> mapUnitObject = JSONUtils.preprocess(mapUnitData);
                     if (mapUnitObject.containsKey("Components")) {
-                        JSONArray componentList = JSONUtils.getJSONArrayParam(resultMap, "Components");
+                        JSONArray componentList = JSONUtils.getJSONArrayParam(mapUnitObject, "Components");
 
                         for (int j = 0; j < componentList.length(); j++) {
                             JSONArray componentData = componentList.getJSONArray(j);
@@ -117,17 +113,28 @@
                                         if (Double.isNaN(length)) {
                                             throwServiceCallException("Returned component list does not contain the required result value for 'length_r' for a component.");
                                         }
-                                        SoilResult soilResult = new SoilResult();
-                                        soilResult.cokey = cokey;
-                                        soilResult.length = length;
-                                        soilResult.area = area;
-                                        
-                                        componentOrderList.put(area, soilResult);
+
+                                        if (componentObject.containsKey("slope_r")) {
+                                            double slope_r = JSONUtils.getDoubleParam(componentObject, "slope_r", Double.NaN);
+                                            if (Double.isNaN(slope_r)) {
+                                                throwServiceCallException("Returned component list does not contain the required result value for 'slope_r' for a component.");
+                                            }
+                                            SoilResult soilResult = new SoilResult();
+                                            soilResult.cokey = cokey;
+                                            soilResult.length = length;
+                                            soilResult.area = area;
+                                            soilResult.slope_r = slope_r;
+                                            soilResult.area_pct = JSONUtils.getDoubleParam(componentObject, "area_pct", Double.NaN);
+                                            soilResult.soilName = JSONUtils.getStringParam(componentObject, "compname", "NONE");
+                                            soilResult.soilLongName = JSONUtils.getStringParam(componentObject, "comp_long_name", "NONE");                                            
+
+                                            componentOrderList.put(area, soilResult);
+                                        }
                                     } else {
                                         throwServiceCallException("Returned component list does not contain the required result 'length_r' for a component.");
                                     }
                                 } else {
-                                   throwServiceCallException("Returned component list does not contain the required result 'cokey' for a component.");
+                                    throwServiceCallException("Returned component list does not contain the required result 'cokey' for a component.");
                                 }
 
                             } else {
@@ -169,9 +176,16 @@
         return ret_val;
     }
 
-    public class SoilResult {
+    public class SoilResult{
+
         public double area;
         public String cokey;
         public double length;
+        public double slope_r;
+        public double windErosion;
+        public double waterErosion;
+        public double area_pct;
+        public String soilName;
+        public String soilLongName;        
     }
 }