Skip to content
Snippets Groups Projects
Commit 45b65219 authored by R0slyn's avatar R0slyn
Browse files

protected area (Mha) setters and getters and alteration to getSuitable to...

protected area (Mha) setters and getters and alteration to getSuitable to ensure protected land is not passed to GAMS
parent 519b7515
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,18 @@ public class LandUseItem implements InterpolatingRasterItem<LandUseItem> {
private Map<CropType, Intensity> intensityMap = new HashMap<CropType, Intensity>();
private Map<CropType, Double> cropFractions = new HashMap<CropType, Double>();
private Map<LandCoverType, Double> landCoverAreas = new HashMap<LandCoverType, Double>();
private double protectedArea; //protected area in Mha
public void setProtectedArea(LandCoverItem landCover){
if (landCover != null) {
double areaTotal = this.getTotalLandCoverArea();
this.protectedArea = landCover.getProtectedArea()*areaTotal;
}
}
public double getProtectedArea(){
return this.protectedArea;
}
public Intensity getIntensity(CropType crop) {
return intensityMap.get(crop);
......@@ -189,11 +200,28 @@ public class LandUseItem implements InterpolatingRasterItem<LandUseItem> {
public double getSuitableLand() {
double d = 0;
double protectedTotal = protectedArea;
double forestArea = getLandCoverArea(LandCoverType.FOREST);
double naturalArea = getLandCoverArea(LandCoverType.OTHER_NATURAL);
double totalNatural = forestArea+naturalArea;
if (totalNatural >= protectedTotal){
double unavailableNatural = naturalArea/totalNatural*protectedTotal;
unavailableNatural = (Double.isNaN(unavailableNatural) || Double.isInfinite(unavailableNatural)) ? 0.0 : unavailableNatural;
double unavailableForest = forestArea/totalNatural*protectedTotal;
unavailableForest = (Double.isNaN(unavailableForest) || Double.isInfinite(unavailableForest)) ? 0.0 : unavailableForest;
d += naturalArea - unavailableNatural + forestArea - unavailableForest;
}
for (LandCoverType l : LandCoverType.values()) {
if (!LandCoverType.BARREN.equals(l)) // barren land is not suitable
if (LandCoverType.PASTURE.equals(l)|| LandCoverType.CROPLAND.equals(l) ) // barren land is not suitable
d += getLandCoverArea(l);
}
return d;
}
......
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