@@ -68,17 +68,18 @@ |
File dataDir = new File(Config.getString("csip.data.dir")); |
|
double difference; |
+ double area_stats[]; |
|
String total_time; |
String stats[]; |
|
- List<Integer> polyCount = new ArrayList<>(); |
+ List<Double> polyCount = new ArrayList<>(); |
+ List<Double> areaChunk = new ArrayList<>(); |
|
int multi_run = -1; |
int chunks; |
boolean custom = false; |
|
- |
@Override |
protected void doProcess() throws Exception { |
String file = getStringParam(KEY_GEOM); |
@@ -120,7 +121,6 @@ |
run(file, getWorkspaceDir(), dataDir, getWorkspaceDir(), delta, start_year, end_year, ages_files, geotiffs, multi_run, custom); |
} |
|
- |
/** |
* run lamps. |
* |
@@ -318,7 +318,7 @@ |
URL geomUrl = new File(workspace, geometry).toURI().toURL(); |
|
LOG.info("===> Reading AOI"); |
- chunks = CSIP_Read_AND_SPLIT.URL_Read_Geometry_File_new(geomUrl, workspace, multi_run, polyCount, LOG); |
+ chunks = CSIP_Read_AND_SPLIT.URL_Read_Geometry_File_new(geomUrl, workspace, multi_run, polyCount, areaChunk, LOG); |
|
LOG.info("slice file into " + chunks + " chunks"); |
List<Long> cpu_time = Collections.synchronizedList(new ArrayList<>(chunks)); |
@@ -369,7 +369,8 @@ |
}); |
long timeend = System.currentTimeMillis(); |
total_time = Duration.ofMillis(timeend - timestart).toString(); |
- stats = stats(cpu_time); |
+ stats = statsTime(cpu_time); |
+ area_stats = stats(areaChunk); |
} |
|
LOG.info("Finished."); |
@@ -380,7 +381,6 @@ |
LOG.info("===> Total LAMPS application time : " + difference + " s"); |
} |
|
- |
@Override |
protected void postProcess() throws IOException { |
putResult("application time", " " + difference + " s"); |
@@ -401,8 +401,13 @@ |
putResult("max_time", stats[1]); |
putResult("avg_time", stats[2]); |
putResult("total_time", stats[3]); |
+ putResult("min_area", area_stats[0]); |
+ putResult("max_area", area_stats[1]); |
+ putResult("total_area", area_stats[3]); |
for (int i = 0; i < polyCount.size(); i++) { |
putResult("#ofPoly" + i, polyCount.get(i)); |
+ putResult("avgChunkArea" + i, (areaChunk.get(i) / polyCount.get(i))); |
+ putResult("ChunkArea" + i, areaChunk.get(i)); |
} |
} |
putResult(new File(getWorkspaceDir(), CSIP_Const.AOI_NASS_dominant_result), "output file1"); |
@@ -414,8 +419,7 @@ |
putResult(new File(getWorkspaceDir(), CSIP_Const.AOI_LAMPS_CONF_result), "output file5"); |
} |
|
- |
- private String[] stats(List<Long> list) { |
+ private String[] statsTime(List<Long> list) { |
if (list.isEmpty()) { |
return new String[]{ |
Duration.ofMillis(0).toString(), |
@@ -444,6 +448,24 @@ |
}; |
} |
|
+ private double[] stats(List<Double> list) { |
+ if (list.isEmpty()) { |
+ |
+ } |
+ double max = Double.MIN_VALUE; |
+ double min = Double.MAX_VALUE; |
+ double sum = 0; |
+ for (double l : list) { |
+ sum += l; |
+ if (l > max) { |
+ max = l; |
+ } |
+ if (l < min) { |
+ min = l; |
+ } |
+ } |
+ return new double[]{min, max, (sum / list.size()), sum}; |
+ } |
|
private static void combineFiles(File out, int chunks) throws IOException { |
for (int i = 0; i < chunks; i++) { |
@@ -92,7 +92,7 @@ |
* @return |
* @throws Exception |
*/ |
- public static Integer URL_Read_Geometry_File_new(URL hru_url, File outputDir, Integer partitionSize, List<Integer> Count_Polys, SessionLogger LOG) throws Exception { |
+ public static Integer URL_Read_Geometry_File_new(URL hru_url, File outputDir, Integer partitionSize, List Count_Polys, List avg_Area, SessionLogger LOG) throws Exception { |
|
List<Geometry> Input_Geometries = new ArrayList<>(); |
|
@@ -209,7 +209,6 @@ |
NodeList PlacemarkList = doc.getElementsByTagName("Placemark"); |
|
for (int i = 0; i < PlacemarkList.getLength(); i++) { |
- LOG.info(" PlacemarkList.getLength() " + PlacemarkList.getLength()); |
Node n = PlacemarkList.item(i); |
if (n.getNodeType() == Node.ELEMENT_NODE) { |
Element eElement = (Element) n.getChildNodes(); |
@@ -247,6 +246,18 @@ |
all = all.convexHull(); |
} |
|
+ Geometry kmlGeometry = all; |
+ MathTransform kmltransform = CRS.findMathTransform(targetCRS, kmlCRS, true); |
+ kmlGeometry = JTS.transform(all, kmltransform); |
+ |
+ //TYPE = createFeatureType(feature.getProperties(), kmlGeometry, "" + o, CRS.parseWKT(CSIP_Const.WKT_KML)); |
+ TYPE = createFeatureType(kmlGeometry, "" + i, CRS.parseWKT(CSIP_Const.WKT_KML)); |
+ //SimpleFeature simpfeat = createFeature("" + o, kmlGeometry, TYPE, feature.getProperties()); |
+ SimpleFeature simpfeat = createFeature("" + i, kmlGeometry, TYPE); |
+ list.add(simpfeat); |
+ list2.add(simpfeat); |
+ list3.add((all.getArea() / 1000000)); |
+ |
Input_Geometries.add(all); |
|
} else { |
@@ -273,6 +284,17 @@ |
if (!targetGeometry.getCoordinates()[0].equals(targetGeometry.getCoordinates()[last])) { |
targetGeometry = targetGeometry.convexHull(); |
} |
+ Geometry kmlGeometry = targetGeometry; |
+ MathTransform kmltransform = CRS.findMathTransform(targetCRS, kmlCRS, true); |
+ kmlGeometry = JTS.transform(targetGeometry, kmltransform); |
+ |
+ //TYPE = createFeatureType(feature.getProperties(), kmlGeometry, "" + o, CRS.parseWKT(CSIP_Const.WKT_KML)); |
+ TYPE = createFeatureType(kmlGeometry, "" + i, CRS.parseWKT(CSIP_Const.WKT_KML)); |
+ //SimpleFeature simpfeat = createFeature("" + o, kmlGeometry, TYPE, feature.getProperties()); |
+ SimpleFeature simpfeat = createFeature("" + i, kmlGeometry, TYPE); |
+ list.add(simpfeat); |
+ list2.add(simpfeat); |
+ list3.add((targetGeometry.getArea() / 1000000)); |
|
Input_Geometries.add(targetGeometry); |
} |
@@ -353,10 +375,14 @@ |
|
count_number_of_poly++; |
|
- if (part_tot_area > partitionSize || i == list.size() - 1) { |
+ if (part_tot_area >= partitionSize || i == list.size() - 1) { |
partitions_simpfeatures.add(area_simpfeatures); |
partitions_features.add(area_features); |
- Count_Polys.add(count_number_of_poly); |
+ Count_Polys.add(new Double(count_number_of_poly)); |
+ avg_Area.add(part_tot_area); |
+ LOG.info(" ============== "+i+" Total Area in km2: " + part_tot_area); |
+ LOG.info(" ============== "+i+" Number of Parts : " + count_number_of_poly); |
+ |
number_of_parts++; |
|
part_tot_area = 0; |