00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef STDGIS_H
00021 #define STDGIS_H
00022
00023 #include <cstdlib>
00024 #include <list>
00025 #include <string>
00026 #include <vector>
00027 #include <stdexcept>
00028 #include <fstream>
00029 #include <iostream>
00030 #include <sstream>
00031
00032
00033 #include "BaseRegmas.h"
00034 #include "RegData.h"
00035 #include "Layers.h"
00036 #include "Pixel.h"
00037
00038 using namespace std;
00039
00040 struct lUseCats;
00041 struct reclassRules;
00042 class Pixel;
00043 class Agent_space;
00044 class QImage;
00045
00046
00048
00064 class Gis: public BaseRegmas{
00065
00066 public:
00067 Gis(ThreadManager* MTHREAD_h);
00068 ~Gis();
00070 void setSpace();
00072 void initLayers();
00074 void filterSubRegion(string layerName_h);
00076 void updateImage(string layerName_h);
00078 void addLayer(string name_h, string label_h, bool isInteger_h, bool dynamicContent_h, string fullFileName_h = "");
00080 void resetLayer(string layerName_h);
00082 bool layerExist(string layerName_h);
00084 void addLegendItem (
00085 string name_h,
00086 int D_h,
00087 string label_h,
00088 int rColor_h,
00089 int gColor_h,
00090 int bColor_h,
00091 double minValue_h,
00092 double maxValue_h );
00094 void addReclassificationRule(string name_h, int inCode_h, int outCode_h, double p_h);
00096 void countItems(string layerName_h, bool debug=false);
00098 Pixel* getRandomPlotByValue(string layer_h, int layerValue__h, bool onlyFreePlots=false);
00100 vector <Pixel*> getAllPlotsByValue(string layer_h, int layerValue_h, bool onlyFreePlots=false, int outputLevel=MSG_WARNING);
00102 vector <Pixel*> getAllPlotsByValue(string layer_h, vector<int> layerValues_h, bool onlyFreePlots=false, int outputLevel=MSG_WARNING);
00104 vector <Pixel*> getAllPlots(bool onlyFreePlots=false, int outputLevel=MSG_WARNING);
00106 vector <string> getLayerNames();
00108 vector <Layers*> getLayerPointers();
00110 void calculateDistancesToClosestFarm();
00112 void printLayers(string layerName_h="");
00114 void printBinMaps(string layerName_h="");
00115
00116
00118 void printDebugValues (string layerName_h, int min_h=0, int max_h=0);
00119 double getDistance(const Pixel* px1, const Pixel* px2);
00120 double getAgrDistCost(const Pixel* px1, const Pixel* px2);
00122 vector <Agent_space*> getClosestAgents(Pixel* px_h, int size, const string &category="");
00124 vector<double> getAgrLandStats();
00125
00126
00127 int getXNPixels() const {return xNPixels;};
00128 int getYNPixels() const {return yNPixels;};
00129 double getXyNPixels()const {return xyNPixels;};
00130 double getHaByPixel() const {return ((xMetersByPixel*yMetersByPixel)/10000) ;};
00131 double getNoValue() const {return noValue;};
00132 Pixel* getPixel(int x_h, int y_h){return &pxVector.at(x_h+y_h*xNPixels);};
00133 Pixel* getPixel(int ID_h){return &pxVector.at(ID_h);};
00134 double getGeoTopY() const {return geoTopY;};
00135 double getGeoBottomY() const {return geoBottomY;};
00136 double getGeoLeftX() const {return geoLeftX;};
00137 double getGeoRightX() const {return geoRightX;};
00138 double getXMetersByPixel() const {return xMetersByPixel;};
00139 double getYMetersByPixel() const {return yMetersByPixel;};
00140 int getSubXL() const {return subXL;};
00141 int getSubXR() const {return subXR;};
00142 int getSubYT() const {return subYT;};
00143 int getSubYB() const {return subYB;};
00145 int sub2realID(int id_h);
00146 bool isAgrCode(int code_h);
00147
00148 private:
00149 void loadLayersDataFromFile();
00150 vector <Pixel> pxVector;
00151 vector <Layers> layerVector;
00152 vector <double> lUseTotals;
00153 int xNPixels;
00154 int yNPixels;
00155 double xyNPixels;
00156 double xMetersByPixel;
00157 double yMetersByPixel;
00158 double geoLeftX;
00159 double geoTopY;
00160 double geoRightX;
00161 double geoBottomY;
00162 double noValue;
00163 int subXL;
00164 int subXR;
00165 int subYT;
00166 int subYB;
00167 bool subRegionMode;
00168
00169 };
00170
00171 #endif