diff --git a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java index 5cb364badbfc3b6ebb5d32f17c356306e2f3cc1b..7387bf3a0e1b57122808d0357b7f3528501edc2e 100644 --- a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java @@ -66,12 +66,10 @@ public class GamsRasterOptimiser { RasterSet<LandUseItem> theCopy = new RasterSet<LandUseItem>(toCopy.getHeaderDetails()); for (Entry<RasterKey, LandUseItem> entry : toCopy.entrySet()) { - LandUseItem newAreasItem = new LandUseItem(); - if (entry.getValue() == null) { - continue; + if (entry.getValue() != null) { + LandUseItem newAreasItem = new LandUseItem(entry.getValue()); + theCopy.put(entry.getKey(), newAreasItem); } - newAreasItem.setLandCoverAreas(entry.getValue()); - theCopy.put(entry.getKey(), newAreasItem); } return theCopy; diff --git a/src/ac/ed/lurg/landuse/LandUseItem.java b/src/ac/ed/lurg/landuse/LandUseItem.java index b772a067b87501d2a8ea2b38f71aeec75f0233fa..f22063e485c6f3266423f9bb18228b03bb85f680 100644 --- a/src/ac/ed/lurg/landuse/LandUseItem.java +++ b/src/ac/ed/lurg/landuse/LandUseItem.java @@ -4,7 +4,6 @@ import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import ac.ed.lurg.ModelConfig; import ac.ed.lurg.types.CropToDouble; @@ -20,6 +19,16 @@ public class LandUseItem implements InterpolatingRasterItem<LandUseItem>, Serial 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 LandUseItem() {} + + public LandUseItem(LandUseItem luItemToCopy) { + this(); + intensityMap.putAll(luItemToCopy.intensityMap); + cropFractions.putAll(luItemToCopy.cropFractions); + landCoverAreas.putAll(luItemToCopy.landCoverAreas); + protectedArea = (luItemToCopy.protectedArea); + } public void setProtectedArea(double protectedArea){ this.protectedArea = protectedArea; @@ -134,12 +143,6 @@ public class LandUseItem implements InterpolatingRasterItem<LandUseItem>, Serial landCoverAreas.put(lcType, landCover.getLandCoverArea(lcType)); } } - - public void setLandCoverAreas(LandUseItem otherAreasItem) { - for (Entry<LandCoverType, Double> entry : otherAreasItem.landCoverAreas.entrySet()) { - landCoverAreas.put(entry.getKey(), entry.getValue()); - } - } /** move areas from one land cover to another, return an residual not possible */ public double moveAreas(LandCoverType toType, LandCoverType fromType, double changeReq) {