Displaying differences for changeset
 
display as  

src/java/m/wqm/rfactor/V1_0.java

@@ -17,6 +17,7 @@
 import java.sql.ResultSet;
 import java.sql.Statement;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Map;
 import javax.ws.rs.Path;
 import javax.xml.parsers.DocumentBuilder;
@@ -65,6 +66,7 @@
    JSONArray aoaArr;
    ArrayList<AoA> list;
    ArrayList<String> rfactorList;
+   ArrayList<Double> temp;
     @Override
     public void preProcess() throws ServiceException, JSONException
     {
@@ -111,7 +113,7 @@
           for(int i=0;i<list.size();i++)
           {
               String points= list.get(i).getCoordinates();
-          String gisQuery="SELECT m.co_fips, r2_path, r2_name, m.ei_rang, st_area(st_intersection(ST_PolygonFromText('POLYGON(("+points+"))'), geometry)) / st_area(ST_PolygonFromText('POLYGON(("+points+"))'))*100 as percentAoi,st_area(st_intersection(ST_PolygonFromText('POLYGON(("+points+"))'), geometry))/43560 as sizeAoi FROM cli_geom AS g, map_climates AS m WHERE ST_Intersects(ST_PolygonFromText('POLYGON(("+points+"))'), g.geometry) AND g.co_fips = m.co_fips and g.ei_rang = m.ei_rang and st_isvalid(geometry)='t' and st_isvalid(ST_PolygonFromText('POLYGON(("+points+"))'))='t';";
+          String gisQuery="SELECT m.co_fips, r2_path, r2_name, m.ei_rang, st_area(st_intersection(ST_PolygonFromText('POLYGON(("+points+"))'), geometry)) / st_area(ST_PolygonFromText('POLYGON(("+points+"))'))*100 as percentAoi,st_area(st_intersection(ST_PolygonFromText('POLYGON(("+points+"))'), geometry))/43560 as sizeAoi FROM cli_geom AS g, map_climates AS m WHERE ST_Intersects(ST_PolygonFromText('POLYGON(("+points+"))'), g.geometry) AND g.co_fips = m.co_fips and st_isvalid(geometry)='t' and st_isvalid(ST_PolygonFromText('POLYGON(("+points+"))'))='t';";
            //stmt.execute(gisQuery);
          //statement.execute(query1);
          
@@ -151,8 +153,13 @@
     JSONArray finalArr= new JSONArray();
     for(int i=0;i<list.size();i++){
     JSONArray resultArr = new JSONArray();
+    temp=new ArrayList<Double>();
+    for(int j=0;j<list.get(i).getRFactor().size();j++)
+      temp.add(Double.parseDouble(list.get(i).getRFactor().get(j)));
+    
+    Collections.sort(temp);
     resultArr.put(JSONUtils.dataDesc("AoAId",list.get(i).getAoAId(),"Area of Analysis Identifier"));
-    resultArr.put(JSONUtils.dataDesc("RFactor",list.get(i).getRFactor(),"R Factor"));
+    resultArr.put(JSONUtils.dataDesc("RFactor",temp.get(temp.size()-1),"R Factor"));
     
     finalArr.put(resultArr);
     }