61 msgOut(
MSG_INFO,
"Creating the space...");
64 geoTopY = MTHREAD->MD->getDoubleSetting(
"geoNorthEdge");
65 geoBottomY = MTHREAD->MD->getDoubleSetting(
"geoSouthEdge");
66 geoLeftX = MTHREAD->MD->getDoubleSetting(
"geoWestEdge");
67 geoRightX = MTHREAD->MD->getDoubleSetting(
"geoEastEdge");
68 xNPixels = MTHREAD->MD->getIntSetting(
"nCols");
69 yNPixels = MTHREAD->MD->getIntSetting(
"nRows");
70 noValue = MTHREAD->MD->getDoubleSetting(
"noValue");
71 xyNPixels = xNPixels * yNPixels;
72 xMetersByPixel = (geoRightX - geoLeftX)/xNPixels;
73 yMetersByPixel = (geoTopY - geoBottomY)/yNPixels;
74 MTHREAD->treeViewerChangeGeneralPropertyValue(
"total plots", d2s(getXyNPixels()));
75 MTHREAD->treeViewerChangeGeneralPropertyValue(
"total land", d2s(xyNPixels*getHaByPixel()));
77 for (
int i=0;i<yNPixels;i++){
78 for (
int j=0;j<xNPixels;j++){
79 Pixel myPixel(i*xNPixels+j, MTHREAD);
81 pxVector.push_back(myPixel);
85 loadLayersDataFromFile();
88 vector <ModelRegion*>
regions = MTHREAD->MD->getAllRegions();
89 int nRegions = regions.size();
90 for(uint i=0;i<nRegions;i++){
91 regions[i]->setMyPixels();
94 applySpatialStochasticValues();
95 applyStochasticRiskAdversion();
109 MTHREAD->fitInWindow();
126 if(!MTHREAD->MD->getBoolSetting(
"usePixelData"))
return;
128 vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
133 for(uint i=0;i<regIds2.size();i++){
134 int regId = regIds2[i];
136 vector <Pixel*> rpx = MTHREAD->GIS->getAllPlotsByRegion(regId );
137 vector <string> fTypes = MTHREAD->MD->getForTypeIds();
140 if(MTHREAD->MD->getBoolSetting(
"useSpatialRegionalVariance")){
141 for(uint j=0; j<fTypes.size(); j++){
142 double sStDev = MTHREAD->MD->getForData(
"sStDev",regId ,fTypes[j],
"");
143 double agr = MTHREAD->MD->getForData(
"agr",regId ,fTypes[j],
"");
146 normal_distribution<double> d(1,sStDev/agr);
147 for (uint z=0;z<rpx.size();z++){
148 double c = d(*MTHREAD->gen);
149 double c2 = max(0.4,min(1.6,c));
154 rpx[z]->setSpModifier(c2,j);
162 double avgExpTypes = MTHREAD->MD->getDoubleSetting(
"expType",
DATA_NOW,regId);
163 double avgExpTypesPrices = MTHREAD->MD->getDoubleSetting(
"expTypePrices",
DATA_NOW,regId);
164 double expTypes_cv = MTHREAD->MD->getDoubleSetting(
"expType_cv",
DATA_NOW,regId);
165 double expTypesPrices_cv = MTHREAD->MD->getDoubleSetting(
"expTypePrices_cv",
DATA_NOW,regId);
166 if((avgExpTypes<0 || avgExpTypes>1) && avgExpTypes != -1){
167 msgOut(
MSG_CRITICAL_ERROR,
"expType parameter must be between 1 (expectations) and 0 (adaptative) or -1 (fixed).");
169 if(avgExpTypesPrices<0 || avgExpTypesPrices>1){
170 msgOut(
MSG_CRITICAL_ERROR,
"vgExpTypesPrices parameter must be between 1 (expectations) and 0 (adaptative).");
174 normal_distribution<double> exp_distr(avgExpTypes,expTypes_cv *avgExpTypes);
175 normal_distribution<double> expPrices_distr(avgExpTypesPrices,expTypesPrices_cv *avgExpTypesPrices);
177 for (uint z=0;z<rpx.size();z++){
178 if(avgExpTypes == -1){
179 rpx[z]->expType = -1;
183 double c3 = normSample(exp_distr,*MTHREAD->gen,0.0,1.0);
185 rpx[z]->expType = c3;
187 double cPrice = normSample(expPrices_distr,*MTHREAD->gen,0.0,1.0);
188 rpx[z]->expTypePrices = cPrice;
204 if(!MTHREAD->MD->getBoolSetting(
"usePixelData"))
return;
206 vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
207 bool raEnabled = MTHREAD->MD->getBoolSetting(
"heterogeneousRiskAversion");
208 for(uint i=0;i<regIds2.size();i++){
209 int regId = regIds2[i];
211 vector <Pixel*> rpx = MTHREAD->GIS->getAllPlotsByRegion(regId);
212 for (uint z=0;z<rpx.size();z++){
214 double raStDev = MTHREAD->MD->getDoubleSetting(
"riskAversionAgentSd",
DATA_NOW,regId);
215 double avg = MTHREAD->MD->getDoubleSetting(
"riskAversionAgentAverage",
DATA_NOW,regId);
216 normal_distribution<double> d(avg,raStDev);
217 double c = d(*MTHREAD->gen);
218 rpx[z]->setValue (
"ra", c);
220 rpx[z]->setValue (
"ra", 0.0);
231 if(!MTHREAD->MD->getBoolSetting("usePixelData")) return;
232 if(!MTHREAD->MD->getBoolSetting("applyAvalCoef")) return;
234 bool applyAvalCoef = MTHREAD->MD->getBoolSetting("applyAvalCoef");
236 vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
238 for(uint i=0;i<regIds2.size();i++){
239 ModelRegion* reg = MTHREAD->MD->getRegion(regIds2[i]);
240 vector <Pixel*> rpx = MTHREAD->GIS->getAllPlotsByRegion(regIds2[i]);
241 for (uint p=0;p<rpx.size();p++){
243 rpx[p]->avalCoef = rpx[p]->getDoubleValue("avalCoef", true);
262 string filename_complete = MTHREAD->getBaseDirectory()+MTHREAD->MD->getStringSetting(
"gisFilename");
266 if (!test){msgOut(
MSG_CRITICAL_ERROR,
"Error opening the gis file "+filename_complete+
".");}
267 vector<InputNode> layerNodes = gisDocument.
getNodesByName(
"layer");
268 vector<string> ftIds = MTHREAD->MD->getForTypeIds();
269 for (uint i=0; i<layerNodes.size();i++){
271 string nameOrig = layerNodes.at(i).getNodeByName(
"name").getStringContent();
272 string labelOrig = layerNodes.at(i).getNodeByName(
"label").getStringContent();
273 bool isInteger = layerNodes.at(i).getNodeByName(
"isInteger").getBoolContent();
274 bool dynamicContent = layerNodes.at(i).getNodeByName(
"dynamicContent").getBoolContent();
275 bool expandByFt = layerNodes.at(i).getNodeByName(
"expandByFt").getBoolContent();
276 string readAtStart = layerNodes.at(i).getNodeByName(
"readAtStart").getStringContent();
277 if (readAtStart !=
"true")
continue;
278 string dirName = layerNodes.at(i).getNodeByName(
"dirName").getStringContent();
279 string fileName = layerNodes.at(i).getNodeByName(
"fileName").getStringContent();
282 uint endingLoop = expandByFt ? ftIds.size(): 1;
283 for(uint z=0;z<endingLoop;z++){
284 string ftExtension= expandByFt ?
"_"+ftIds[z]:
"";
285 string labelFtExtension= expandByFt ?
" ("+ftIds[z]+
")":
"";
286 string name = nameOrig+ftExtension;
287 string label = labelOrig + labelFtExtension;
289 string fullFileName = ((dirName ==
"") || (fileName==
""))?
"":MTHREAD->MD->getBaseDirectory()+dirName+fileName+ftExtension;
290 addLayer(name,label,isInteger,dynamicContent,fullFileName);
292 vector<InputNode> legendItemsNodes = layerNodes.at(i).getNodesByName(
"legendItem");
293 for (uint j=0; j<legendItemsNodes.size();j++){
294 int lID = legendItemsNodes.at(j).getIntContent();
295 string llabel = legendItemsNodes.at(j).getStringAttributeByName(
"label");
296 int rColor = legendItemsNodes.at(j).getIntAttributeByName(
"rColor");
297 int gColor = legendItemsNodes.at(j).getIntAttributeByName(
"gColor");
298 int bColor = legendItemsNodes.at(j).getIntAttributeByName(
"bColor");
299 double minValue, maxValue;
301 minValue = ((double)lID);
302 maxValue = ((double)lID);
305 minValue = legendItemsNodes.at(j).getDoubleAttributeByName(
"minValue");
306 maxValue = legendItemsNodes.at(j).getDoubleAttributeByName(
"maxValue");
308 addLegendItem(name, lID, llabel, rColor, gColor, bColor, minValue, maxValue);
312 initLayersPixelData();
321 if (!MTHREAD->MD->getBoolSetting(
"usePixelData")){
return;}
322 string dir = MTHREAD->MD->getBaseDirectory()+MTHREAD->MD->getStringSetting(
"spatialDataSubfolder");
323 string fileExt = MTHREAD->MD->getStringSetting(
"spatialDataFileExtension");
324 vector<string> files = vector<string>();
325 string fullFilename, filename, fullPath;
329 MTHREAD->MD->getFilenamesByDir(dir,files, fileExt);
331 for (
unsigned int i = 0;i < files.size();i++) {
332 fullFilename = files[i];
333 fullPath = dir+
"/"+fullFilename;
334 filename = fullFilename.substr(0,fullFilename.find_last_of(
"."));
335 addLayer(filename,filename,
false,
false,fullPath,
false);
339 if(MTHREAD->MD->getBoolSetting(
"useSpExplicitForestTypes")){
340 string dir2 = MTHREAD->MD->getBaseDirectory()+MTHREAD->MD->getStringSetting(
"spExplicitForTypesInputDir");
341 string fileExt2 = MTHREAD->MD->getStringSetting(
"spExplicitForTypesFileExtension");
342 vector<string> files2 = vector<string>();
343 string fullFilename2, filename2, fullPath2;
344 MTHREAD->MD->getFilenamesByDir (dir2,files2, fileExt2);
345 for (
unsigned int i = 0;i < files2.size();i++) {
346 fullFilename2 = files2[i];
347 fullPath2 = dir2+
"/"+fullFilename2;
348 filename2 = fullFilename2.substr(0,fullFilename2.find_last_of(
"."));
349 addLayer(filename2,filename2,
false,
false,fullPath2,
false);
354 if(MTHREAD->MD->getBoolSetting(
"usePathogenModule")){
355 string dir2 = MTHREAD->MD->getBaseDirectory()+MTHREAD->MD->getStringSetting(
"pathogenExogenousSpreadModelFolder");
356 string fileExt2 = MTHREAD->MD->getStringSetting(
"pathogenExogenousSpreadModelFileExtension");
357 vector<string> files2 = vector<string>();
358 string fullFilename2, filename2, fullPath2;
359 MTHREAD->MD->getFilenamesByDir (dir2,files2, fileExt2);
360 for (
unsigned int i = 0;i < files2.size();i++) {
361 fullFilename2 = files2[i];
362 fullPath2 = dir2+
"/"+fullFilename2;
363 filename2 = fullFilename2.substr(0,fullFilename2.find_last_of(
"."));
364 addLayer(filename2,filename2,
false,
false,fullPath2,
false);
369 addLayer(
"pixelIds",
"Pixel IDs",
true,
false,
"",
true);
370 vector <Pixel*> allPx = getAllPlots(
false);
371 for (
unsigned int i = 0; i < allPx.size();i++) {
372 allPx[i]->changeValue(
"pixelIds", allPx[i]->getID());
430 for(uint i=0;i<layerVector.size();i++){
431 if(layerVector[i].getName() == layerName_h){
432 return &layerVector[i];
448 int nReclassRules = MTHREAD->MD->getNReclRules();
449 vector <reclRule*> RRs;
450 for(uint z=0;z<nReclassRules;z++){
451 RRs.push_back(MTHREAD->MD->getReclRule(z));
456 for (uint i=0;i< MTHREAD->MD->getNForTypes();i++){
457 forType* FT = MTHREAD->MD->getForType(i);
468 for (uint i=0;i< MTHREAD->MD->getNForTypes();i++){
469 forType* FT = MTHREAD->MD->getForType(i);
470 for(uint j=0;j<xyNPixels;j++){
471 Pixel* PX = getPixel(j);
475 for(uint z=0;z<nReclassRules;z++){
481 double reclassCoeff = RR->
coeff;
482 value += inputValue * reclassCoeff ;
515 Gis::addLayer(
string name_h,
string label_h,
bool isInteger_h,
bool dynamicContent_h,
string fullFileName_h,
bool display_h){
516 if(name_h ==
"forArea_ash"){
519 for(uint i=0; i<layerVector.size(); i++){
520 if (layerVector.at(i).getName() == name_h){
521 msgOut(
MSG_ERROR,
"Layer already exist with that name");
525 Layers LAYER (MTHREAD, name_h, label_h, isInteger_h, dynamicContent_h, fullFileName_h, display_h);
526 layerVector.push_back(LAYER);
528 for (uint i=0;i<xyNPixels; i++){
529 pxVector[i].setValue(name_h,noValue);
532 MTHREAD->addLayer(name_h,label_h);
540 for(uint i=0; i<layerVector.size(); i++){
541 if (layerVector.at(i).getName() == layerName_h){
542 for (uint i=0;i<xyNPixels; i++){
543 pxVector.at(i).changeValue(layerName_h,noValue);
548 msgOut(
MSG_ERROR,
"I could not reset layer "+layerName_h+
" as it doesn't exist!");
555 for(uint i=0; i<layerVector.size(); i++){
556 if (layerVector.at(i).getName() == layerName_h){
561 for(uint i=0; i<layerVector.size(); i++){
562 if (layerVector.at(i).getName().compare(0, layerName_h.size(),layerName_h )){
579 Gis::addLegendItem(
string name_h,
int ID_h,
string label_h,
int rColor_h,
int gColor_h,
int bColor_h,
double minValue_h,
double maxValue_h){
581 for(uint i=0; i<layerVector.size(); i++){
582 if (layerVector.at(i).getName() == name_h){
583 layerVector.at(i).addLegendItem(ID_h, label_h, rColor_h, gColor_h, bColor_h, minValue_h, maxValue_h);
587 msgOut(
MSG_ERROR,
"Trying to add a legend item to a layer that doesn't exist.");
601 for(uint i=0; i<layerVector.size(); i++){
602 if (layerVector.at(i).getName() == layerName_h){
603 layerVector.at(i).countMyPixels(debug);
607 msgOut(
MSG_ERROR,
"Trying to get statistics (count pixels) of a layer that doesn't exist.");
625 double localNoValue = noValue;
630 for(uint i=0;i<layerVector.size();i++){
631 string layerName =layerVector.at(i).getName();
632 string fileName=layerVector.at(i).getFilename();
633 if(fileName ==
"")
continue;
634 QFile file(fileName.c_str());
635 if (!file.open(QFile::ReadOnly)) {
636 cerr <<
"Cannot open file for reading: " 637 << qPrintable(file.errorString()) << endl;
638 msgOut(
MSG_ERROR,
"Cannot open map file "+fileName+
" for reading.");
641 QTextStream in(&file);
643 QImage image = QImage(xNPixels, yNPixels, QImage::Format_RGB32);
644 image.fill(qRgb(255, 255, 255));
645 while (!in.atEnd()) {
646 QString line = in.readLine();
647 QStringList fields = line.split(
' ');
649 (fields.at(0)==
"north:" && fields.at(1).toDouble() != geoTopY)
650 || ((fields.at(0)==
"south:" || fields.at(0) ==
"yllcorner" ) && fields.at(1).toDouble() != geoBottomY)
651 || (fields.at(0)==
"east:" && fields.at(1).toDouble() != geoRightX)
652 || ((fields.at(0)==
"west:" || fields.at(0) ==
"xllcorner" ) && fields.at(1).toDouble() != geoLeftX)
653 || ((fields.at(0)==
"rows:" || fields.at(0) ==
"nrows" ) && fields.at(1).toInt() != yNPixels)
654 || ((fields.at(0)==
"cols:" || fields.at(0) ==
"ncols" ) && fields.at(1).toInt() != xNPixels)
657 msgOut(
MSG_ERROR,
"Layer "+layerName+
" has different coordinates. Aborting reading.");
659 }
else if (fields.at(0)==
"null:" || fields.at(0) ==
"NODATA_value" || fields.at(0) ==
"nodata_value" ) {
660 localNoValue = fields.at(1).toDouble();
661 }
else if (fields.size() > 5) {
662 for (
int countColumn=0;countColumn<xNPixels;countColumn++){
663 inputValue = fields.at(countColumn).toDouble();
664 if (inputValue == localNoValue){
665 outputValue = noValue;
666 pxVector.at((countRow*xNPixels+countColumn)).changeValue(layerName,outputValue);
667 QColor nocolor(255,255,255);
671 outputValue=layerVector.at(i).filterExogenousDataset(fields.at(countColumn).toDouble());
672 pxVector.at((countRow*xNPixels+countColumn)).changeValue(layerName,outputValue);
673 color = layerVector.at(i).getColor(outputValue);
675 image.setPixel(countColumn,countRow,color.rgb());
680 if (MTHREAD->MD->getBoolSetting(
"initialRandomShuffle") ){
681 layerVector.at(i).randomShuffle();
683 this->filterSubRegion(layerName);
684 if(layerVector.at(i).getDisplay()){
685 MTHREAD->updateImage(layerName,image);
701 msgOut (1,
"Update image "+layerName_h+
"...");
704 QImage image = QImage(subXR-subXL+1, subYB-subYT+1, QImage::Format_RGB32);
706 image.fill(qRgb(255, 255, 255));
708 for (uint i=0;i<layerVector.size();i++){
709 if (layerVector.at(i).getName() == layerName_h){
718 for (
int countRow=subYT;countRow<subYB;countRow++){
719 for (
int countColumn=subXL;countColumn<subXR;countColumn++){
720 double value = pxVector.at((countRow*xNPixels+countColumn)).getDoubleValue(layerName_h);
721 QColor color = layerVector.at(layerIndex).getColor(value);
722 image.setPixel(countColumn-subXL,countRow-subYT,color.rgb());
725 MTHREAD->updateImage(layerName_h,image);
732 vector <Pixel* > candidates;
733 vector <uint> counts;
734 for(uint i=0;i<pxVector.size();i++) counts.push_back(i);
735 random_shuffle(counts.begin(), counts.end());
737 for (uint i=0;i<counts.size();i++){
738 if(pxVector.at(counts.at(i)).getDoubleValue(layer_h) == layerValue_h ) {
739 return &pxVector.at(counts.at(i));
743 msgOut(
MSG_CRITICAL_ERROR,
"We can't find any plot with "+d2s(layerValue_h)+
" value on layer "+layer_h+
".");
764 vector <Pixel* > candidates;
765 for (uint i=0;i<pxVector.size();i++){
766 if(pxVector.at(i).getDoubleValue(layer_h) == layerValue_h){
767 candidates.push_back(&pxVector.at(i));
771 if (candidates.size()>0){
772 random_shuffle(candidates.begin(), candidates.end());
775 msgOut(outputLevel,
"We can't find any free pixel with "+d2s(layerValue_h)+
" value on layer "+layer_h+
".");
791 vector <Pixel* > candidates;
792 string valuesToMatch;
796 for (uint j=0;j<layerValues_h.size();j++){
797 valuesToMatch = valuesToMatch +
" " + i2s(layerValues_h.at(j));
800 for (uint i=0;i<pxVector.size();i++){
801 z = valuesToMatch.find(d2s(pxVector.at(i).getDoubleValue(layer_h)));
803 candidates.push_back(&pxVector.at(i));
807 if (candidates.size()>0){
808 random_shuffle(candidates.begin(), candidates.end());
811 msgOut(outputLevel,
"We can't find any free plot with the specified values ("+valuesToMatch+
") on layer "+layer_h+
".");
824 vector <Pixel* > candidates;
826 for (uint i=0;i<pxVector.size();i++){
827 candidates.push_back(&pxVector.at(i));
829 if (candidates.size()>0){
830 random_shuffle(candidates.begin(), candidates.end());
832 msgOut(outputLevel,
"We can't find any free plot.");
836 vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
837 for(uint i=0;i<regIds2.size();i++){
838 vector <Pixel*> rpx = getAllPlotsByRegion(regIds2[i]);
842 candidates.insert( candidates.end(), rpx.begin(), rpx.end() );
844 if (candidates.size()>0){
845 random_shuffle(candidates.begin(), candidates.end());
847 msgOut(outputLevel,
"We can't find any free plot.");
856 vector <Pixel*> regionalPixels = region_h.
getMyPixels();
858 random_shuffle(regionalPixels.begin(), regionalPixels.end());
860 return regionalPixels;
865 ModelRegion* reg = MTHREAD->MD->getRegion(regId_h);
866 return getAllPlotsByRegion(*reg,shuffle);
873 vector <string> toReturn;
874 for (uint i=0;i<layerVector.size();i++){
875 toReturn.push_back(layerVector[i].getName());
882 vector <Layers*> toReturn;
883 for (uint i=0;i<layerVector.size();i++){
884 toReturn.push_back(&layerVector[i]);
898 max= pxVector.size();
903 msgOut(
MSG_DEBUG,
"Printing debug information for layer "+layerName_h+
".");
904 for (
int i=min;i<max;i++){
905 value = pxVector.at(i).getDoubleValue(layerName_h);
906 if (value != noValue){
908 X = pxVector.at(i).getX();
909 Y = pxVector.at(i).getY();
910 out =
"Px. "+i2s(ID)+
" ("+i2s(X)+
","+i2s(Y)+
"): "+d2s(value);
931 pow ( (((
double)px1->
getX()) - ((
double)px2->
getX()))*xMetersByPixel,2)
933 pow ( (((
double)px1->
getY()) - ((
double)px2->
getY()))*yMetersByPixel,2)
942 int iteration = MTHREAD->SCD->getIteration();
943 if(layerName_h ==
""){
944 for (uint i=0;i<layerVector.size();i++){
949 if (!iteration || layerVector[i].getDynamicContent()) layerVector[i].print();
952 for (uint i=0;i<layerVector.size();i++){
953 if(layerVector[i].getName() == layerName_h){
954 if (!iteration || layerVector[i].getDynamicContent()) layerVector[i].print();
958 msgOut(
MSG_ERROR,
"Layer "+layerName_h+
" unknow. No layer printed.");
964 msgOut(
MSG_DEBUG,
"Printing the maps as images");
965 int iteration = MTHREAD->SCD->getIteration();
966 if(layerName_h ==
""){
967 for (uint i=0;i<layerVector.size();i++){
968 if (!iteration || layerVector[i].getDynamicContent()) {layerVector[i].printBinMap();}
971 for (uint i=0;i<layerVector.size();i++){
972 if(layerVector[i].getName() == layerName_h){
973 if (!iteration || layerVector[i].getDynamicContent()) {layerVector[i].printBinMap();}
977 msgOut(
MSG_ERROR,
"Layer "+layerName_h+
" unknow. No layer printed.");
988 Gis::unpack(
const string& key,
string& parName,
string& forName,
string& dClass,
int& year)
const{
989 int parNameDelimiter = key.find(
"#",0);
990 int forNameDelimiter = key.find(
"#",parNameDelimiter+1);
991 int dClassDelimiter = key.find(
"#",forNameDelimiter+1);
992 int yearDelimiter = key.find(
"#",dClassDelimiter+1);
993 if (yearDelimiter == string::npos){
996 parName.assign(key,0,parNameDelimiter);
997 forName.assign(key,parNameDelimiter+1,forNameDelimiter-parNameDelimiter-1);
998 dClass.assign(key,forNameDelimiter+1,dClassDelimiter-forNameDelimiter-1);
999 string yearString=
"";
1000 yearString.assign(key,dClassDelimiter+1,yearDelimiter-dClassDelimiter-1);
1001 year = s2i(yearString);
1007 for(uint i=0;i<pxVector.size();i++) {
1008 pxVector[i].swap(swap_what);
void updateImage(string layerName_h)
Add one layer to the system.
void filterSubRegion(string layerName_h)
If subregion mode is on, this function place noValues on the selected layer for all out-of-region pix...
void resetLayer(string layerName_h)
Check if a layer with a certain name is loaded in the model. Used e.g. to check if the dtm layer (opt...
vector< LegendItems > getLegendItems()
void addLegendItems(vector< LegendItems > legendItems_h)
Print an ERROR message, but don't stop the model.
The required data is for the current year.
void swap(const int &swap_what)
void addLayer(string name_h, string label_h, bool isInteger_h, bool dynamicContent_h, string fullFileName_h="", bool display_h=true)
Fill a layer with empty values.
void printDebugValues(string layerName_h, int min_h=0, int max_h=0)
IO production matrix between the forest resources and the primary products (struct) ...
bool layerExist(const string &layerName_h, bool exactMatch=true) const
Return a pointer to a layer given its name.
void changeValue(const string &layerName_h, const double &value_h, const bool &setNoValueForZero=false)
Change the value of an existing layerMTHREAD->GIS->pack(parName, forName, dClass, year)...
void applyForestReclassification()
Apply the forest reclassification with the rules defined in reclRules sheet.
double getDistance(const Pixel *px1, const Pixel *px2)
void loadLayersDataFromFile()
Load the data of a layer its datafile.
vector< Pixel * > getAllPlots(bool masked=true, int outputLevel=MSG_WARNING)
Return the vector (shuffled) of all plots. It is also possible to specify the level in case of failur...
void initLayers()
Init the layers.
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
void applyStochasticRiskAdversion()
Give to each agend a stochastic risk adversion. For now Pixel = Agent.
void addLegendItem(string name_h, int D_h, string label_h, int rColor_h, int gColor_h, int bColor_h, double minValue_h, double maxValue_h)
Print an error message and stop the model.
void printBinMaps(string layerName_h="")
Save an image in standard png format.
double getDoubleValue(const string &layerName_h, const bool &returnZeroForNoValue=false) const
Return the value for a specific layer.
Pixel * getRandomPlotByValue(string layer_h, int layerValue__h)
Return a pointer to a plot with a specific value for the specified layer.
void applySpatialStochasticValues()
Apply stochastic simulation, e.g. regional volume growth s.d. -> tp multipliers.
Define layer objects at the regional level.
Print a debug message, normally filtered out.
Gis(ThreadManager *MTHREAD_h)
Constructor.
vector< Layers * > getLayerPointers()
Return a vector of pointers of existing layers.
vector< Pixel * > getAllPlotsByRegion(ModelRegion ®ion_h, bool shuffle=false)
Return the vector of all plots by a specific region (main region or subregion), optionally shuffled;...
void setCoordinates(int x_h, int y_h)
void printLayers(string layerName_h="")
Print the specified layer or all layers (if param layerName_h is missing).
void setSpace()
Set the initial space environment, including loading data from files.
vector< Pixel * > getAllPlotsByValue(string layer_h, int layerValue_h, int outputLevel=MSG_WARNING)
Return the vector (shuffled) of all plots with a specific value for a specified layer. It is also possible to specify the level in case of failure.
int sub2realID(int id_h)
Transform the ID of a pixel in subregion coordinates to the real (and model used) coordinates...
void countItems(const string &layerName_h, const bool &debug=false)
Count the pixels within each legend item for the selected layer.
vector< string > getLayerNames()
Return a vector of the layer ids (as string)
void initLayersPixelData()
vector< Pixel * > getMyPixels()
void unpack(const string &key, string &parName, string &forName, string &dClass, int &year) const
Layers * getLayer(const string &layerName_h)
Add a legend item to an existing layer.