Displaying differences for changeset
 
display as  

src/java/m/rse/wepot/V1_1.java

@@ -98,8 +98,8 @@
             LOG.info("THE POLYGON AS WE KNOW IT IS=" + this.polygonData.toWKT());
             String cfactor_polygon = "geometry::STPolyFromText(" + this.polygonData.toWKT() + ",4326)";
             PGTools.Centroid centroid = PGTools.getCentroid(cfactor_polygon);
-            this.aoa_cfactor = PGTools.getCFactorRaster(centroid.lat, centroid.lon, getWorkspaceDir());
-            //this.aoa_cfactor = Const.UNKNOWN_CFACTOR;  //  Change to the result of the function call to be written
+            //this.aoa_cfactor = PGTools.getCFactorRaster(centroid.lat, centroid.lon, getWorkspaceDir());
+            this.aoa_cfactor = Const.UNKNOWN_CFACTOR;  //  Change to the result of the function call to be written
 
             //Call SSURGO gemoetry intersect code here ( ssurgo.soilmu_a table )
             //Call SSURGO component lookups here ( ssurgo.component table )            
@@ -116,9 +116,9 @@
         this.error_msg += "SQL exception getting cfactor:  " + se.getMessage();
     } catch (ServiceException sx) {
         this.error_msg += "Service exception getting cfactor:  " + sx.getMessage();
-    } catch (IOException ioe) {
-        this.error_msg += "IO Exception getting cFactor value from raster geotiff layer:  " + ioe.getMessage();
-    }
+    } //catch (IOException ioe) {
+      //  this.error_msg += "IO Exception getting cFactor value from raster geotiff layer:  " + ioe.getMessage();
+    //}
 
     return (this.error_msg.isEmpty() ? EXEC_OK : this.error_msg);
     }
@@ -234,7 +234,8 @@
 //            + " WHERE ST_Intersects(" + polygonText + ", m.the_geom ) "
 //            + " AND st_isvalid( m.the_geom) AND st_isvalid(" + polygonText + ");";
 // sql server spatial sql                
-        query = "SELECT areasymbol, musym, mukey, geography::STPolyFromText(" + WKTPolygon + ",4326).MakeValid().ReorientObject().STIntersection(soilpoly).STArea() / 4046.86 as sizeIntersectionAcres "
+        query = 
+/*      "SELECT areasymbol, musym, mukey, geography::STPolyFromText(" + WKTPolygon + ",4326).MakeValid().ReorientObject().STIntersection(soilpoly).STArea() / 4046.86 as sizeIntersectionAcres "
             + "FROM "
             + "(SELECT m.areasymbol, m.musym, m.mukey, geography::STPolyFromText(m.the_geom.STAsText(),4326).MakeValid().ReorientObject() as soilpoly "
             + "FROM ssurgo.ssurgo.soilmu_a as m "
@@ -243,6 +244,17 @@
             + "AND m.the_geom.STIsValid()=1 "
             + "AND (geometry::STPolyFromText(" + WKTPolygon + ",0).STIsValid())=1) "
             + "as a;";
+*/      
+        "SELECT areasymbol, musym, mukey, geography::STGeomFromText(intersectPoly.STAsText(), 4326).MakeValid().STArea() / 4046.86 as sizeIntersectionAcres"
+            + " FROM"
+            + " (SELECT m.areasymbol, m.musym, m.mukey, "
+            + " m.the_geom.STIntersection(geometry:: STGeomFromText (" + WKTPolygon + ",0)).MakeValid() as intersectPoly"
+            + " FROM ssurgo.ssurgo.soilmu_a as m "
+            + " WITH (index(geom_sidx))"
+            + " WHERE m.the_geom.STIntersects(geometry:: STGeomFromText (" + WKTPolygon + ",0)) = 1"
+            + " AND m.the_geom.STIsValid()=1"
+            + " AND (geometry:: STGeomFromText (" + WKTPolygon + ",0).STIsValid())=1)"
+            + " as a;";        
 
         LOG.info("ssurgo query=" + query);
         try (
@@ -285,7 +297,7 @@
         } else {
             this.error_msg += "No results from the intersect query for this geometry. ";
         }
-        } catch (SQLException ex) {
+        } catch (SQLException | csip.ServiceException ex) {
         this.error_msg += "Cannot continue processing this request in the intersect procedure:  " + ex.getMessage();
         StackTraceElement ste[] = ex.getStackTrace();
         LOG.severe(ex.toString());
@@ -356,7 +368,7 @@
         } else {
             this.error_msg += "Could not find a matching cokey for this intersected mapunit.";
         }
-        } catch (SQLException ex) {
+        } catch (SQLException | csip.ServiceException ex) {
         this.error_msg += "Could not continue processing the component lookups for this mapunit intersect:  " + ex.getMessage();
         }
     }