Skip to content
Snippets Groups Projects
Commit 4aa3993d authored by Peter Alexander's avatar Peter Alexander
Browse files

Fix NPE in debug / output code

parent 9736907d
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,8 @@ public class GamsRasterOptimiser { ...@@ -69,7 +69,8 @@ public class GamsRasterOptimiser {
for (LandCoverType l : LandCoverType.values()) { for (LandCoverType l : LandCoverType.values()) {
double total = 0; double total = 0;
for (LandUseItem a : areaRaster.values()) { for (LandUseItem a : areaRaster.values()) {
total += a.getLandCoverArea(l); if (a != null)
total += a.getLandCoverArea(l);
} }
LogWriter.printlnError("Total Area " + comment + ": " + l.getName() + ": " + total); LogWriter.printlnError("Total Area " + comment + ": " + l.getName() + ": " + total);
...@@ -77,10 +78,12 @@ public class GamsRasterOptimiser { ...@@ -77,10 +78,12 @@ public class GamsRasterOptimiser {
double protectedAreaIncMinNatural=0, suitableArea=0, protectedArea=0, unprotectedArea=0; double protectedAreaIncMinNatural=0, suitableArea=0, protectedArea=0, unprotectedArea=0;
for (LandUseItem a : areaRaster.values()) { for (LandUseItem a : areaRaster.values()) {
protectedArea += a.getProtectedArea(); if (a != null) {
unprotectedArea += a.getUnprotectedArea(); protectedArea += a.getProtectedArea();
protectedAreaIncMinNatural += a.getProtectedAreaIncMinNatural(); unprotectedArea += a.getUnprotectedArea();
suitableArea += a.getSuitableLand(); protectedAreaIncMinNatural += a.getProtectedAreaIncMinNatural();
suitableArea += a.getSuitableLand();
}
} }
LogWriter.println("Total protectedArea " + comment + ": " + protectedArea); LogWriter.println("Total protectedArea " + comment + ": " + protectedArea);
LogWriter.println("Total unprotectedArea " + comment + ": " + unprotectedArea); LogWriter.println("Total unprotectedArea " + comment + ": " + unprotectedArea);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment