Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GeoData.hpp
00001 
00013 #ifndef GRAMER_GEODATA_HPP
00014 #define GRAMER_GEODATA_HPP
00015 
00016 #include <list>
00017 #include <vector>
00018 #include <iostream>
00019 #include <fstream>
00020 #include <string>
00021 
00022 #include <boost/tokenizer.hpp>
00023 #include <boost/lexical_cast.hpp>
00024 
00025 #include <gdal_priv.h>
00026 #include <ogr_spatialref.h>
00027 //#include <cpl_string.h>
00028 
00029 #include <gramer/Attributes.hpp>
00030 
00031 #define MAX_NUMBER_OF_BANDDEFINITIONS 4
00032 #define MAX_NUMBER_OF_BANDCONDITIONS  4
00033 
00035 
00036         //void bufferToMem();
00038         //void memToBuffer();
00039         
00041         //HOMOGENEOUS_TYPE getTraversabilityHomogeneousType();
00042 
00044         //HOMOGENEOUS_TYPE getRoughHomogeneousType();
00045 
00052         //bool createNewInfoBand(GDInfoBand** thatNewBand);
00053 
00055         //bool buildUtility();
00056         //void resetUtility();
00057 
00070         //bool setMap(GEODATA_INTERNAL_MAP map2set,double v1_, int x1_, int y1_, double v2_, int x2_, int y2_);
00071 
00077         //bool loadVisibility ( const std::string& _visibilityFileName );
00078 
00079         // same value at all bands
00080         //bool sameValue(const RasterCell& rect);
00081 
00083         //bool sameValue(GEODATA_BAND band, const RasterCell& rect);
00084 
00086         //double getFootPrintEntropy(int, int);
00087 
00094         //double calculateBandHomogeneityPercentage(BandDefinition _aband);
00095 
00100         //bool isVisionTransparent(int atx, int aty, int atz=0);
00101 
00103 
00104 namespace jafar {
00105   namespace gramer {
00106    
00107 
00109     typedef enum {  FUSION_OVERWRITE=0,
00110             FUSION_MEAN
00111           } FUSION_METHOD;
00112 
00114     typedef enum {  HT_NONE=-1,
00115             HT_SIMPLE,
00116             HT_NEARLY,
00117             HT_SIGMA
00118           } HOMOGENEOUS_TYPE;
00119       
00125     static const std::string prefixedBandDefinitions[MAX_NUMBER_OF_BANDDEFINITIONS] =
00126     { "TRA", "VIS", "LOC", "COM" };
00127 
00133     static const std::string prefixedBandConditions[MAX_NUMBER_OF_BANDCONDITIONS] =
00134     { "AIR", "GROUND", "SURFACE", "UNDERWATER"};
00135 
00136     // To define points and rectangular areas
00137     typedef struct RasterCell {
00138       // Coordinate calculated buffer
00139       int x; 
00140       int y; 
00141       // Size in pixels
00142       int xsize;
00143       int ysize;
00145       RasterCell()
00146       {
00147         x = 0;
00148         y = 0;
00149         xsize = 0;
00150         ysize = 0;
00151       }
00152 
00154       RasterCell(int x_, int y_, int xs_=1, int ys_=1)
00155       {
00156         x = x_;
00157         y = y_;
00158         xsize = xs_;
00159         ysize = ys_;
00160       }
00161 
00162       // - Geographical information depends on the data Band
00163       // - Resolution depends on the data band
00164     } RasterCell;
00165 
00170     class GeoData 
00171     { /*{{{*/ 
00172       public:
00173 
00174         static const double DEFAULT_DATA_VALUE() { return -1.0; };
00175 
00176         static const double GEODATA_DEFAULT_SCALE() { return 1.0; };
00177       
00179         typedef struct BandDefinition {
00180           std::string confFileSource;
00181           std::string sourceFile;
00182           std::string name;
00183           int bandNumber;
00184           std::string geoUtmZone;
00185           float geoRefX;
00186           float geoRefY;
00187           float geoRefZ;
00188           float geoPixelSizeX;
00189           float geoPixelSizeY;
00190           float geoPixelSizeZ;
00191           std::vector<std::string> otherInfo;
00192         } BandDefinition;
00193         
00195         GeoData();
00196 
00203         GeoData(const std::string& _conffilename, FUSION_METHOD _fmethod=FUSION_MEAN);
00204 
00206         //GeoData(int _xsize, int _ysize, double* _bufferedData, FUSION_METHOD _fmethod=FUSION_MEAN);
00207 
00209         ~GeoData();
00210 
00211         bool loadBand(BandDefinition band, const std::string& _dsfilename);
00212 
00231         bool loadConfigurationFile(const std::string& conffile);
00232 
00241         int isInVirtualMemory;
00242 
00243         //------------------- getters
00244 
00246         GDALDataset* getDataset() const;
00247 
00249         void getAffineTransform(double& _utmXRoot, double& _utmYRoot, double& _cellXRes, double& _cellYRes); 
00250 
00254         int getxsize() const;
00255         int getysize() const;
00256 
00258         double getScale() const;
00259 
00261         double geoxroot() const;
00263         double geoyroot() const;
00265         double geoxend() const;
00267         double geoyend() const;
00269         double geoxres() const;
00271         double geoyres() const;
00272 
00277         double getSigmaFactor();
00278 
00283         double getProbabilityLag();
00284 
00286         // TODO
00287         //double getValueFromBand(BandDefinition _aband, int index);
00288 
00292         bool getValueFromBand(BandDefinition _aband, int xindex, int yindex, double& readValue);
00293 
00294         // get the fusion value of all bands at given cell
00295         double getData(const RasterCell& rect) const;
00296 
00297         // get the band value at given cell
00298         double getData(const BandDefinition& bandDef, const RasterCell& rect) const;
00299         
00300         // TODO
00301         //GDRasterBand<double>* getBand(BandDefinition band);
00302         
00303         // TODO
00304         //double getInterpolatedValue(GEODATA_BAND _aband, double xNavLoc, double yNavLoc);
00305 
00306         //-------------- setters
00307 
00309         void setScale(double _scale);
00310 
00311         // TODO
00314         //void setValueInBand(GEODATA_BAND _aband, int _index, double _val);
00315 
00320         void setFusingMethod(FUSION_METHOD _fmethod);
00321 
00322         //void setGeoTransform(double _utmXRoot, double _utmYRoot, double _cellXRes, double _cellYRes); 
00323         // TODO reimplement
00325 
00337         // TODO
00338         // bool setData(int at_i, int at_j, Attributes inatt, bool internalTransfer=true);
00339 
00341         void setDecompositionLimit(double _dl);
00342 
00344         void setDecompositionType(HOMOGENEOUS_TYPE ht_);
00345 
00347         void setProbabilityLag(double probaLag_);
00348 
00350         void setSigmaFactor(double sigmaF_);
00351 
00353         void setSimulationProbaVisionLimit(double spvl_);
00354 
00355         //-------------- testers
00359         bool isHomogeneous(const RasterCell& rect) const;
00360 
00361 
00365         bool overlaps(GeoData* _toMerge);
00366 
00367         //---------------- smarters
00368 
00385         bool loadData(const std::string& _dsfilename);
00386 
00390         bool setBandTag(int iband, BandDefinition& bandDef);
00391 
00396         bool addBandToDataset(BandDefinition& inputinfo);
00397 
00402         void addDataset(GDALDataset *_dataset);
00403 
00415         //bool mergeStrict(GeoData* _toMerge, GEODATA_BAND _aband);
00416 
00428         //void fuseData(GeoData *_geodata2, GEODATA_BAND _aband, const RasterCell& innerRect, const RasterCell& fusingRect);
00429         
00431         void printInfo(bool verbose = true) const;
00432 
00434         bool saveData(const std::string& outfile, const char* wFormat="GTIFF");
00435 
00437         // TODO
00438         //bool saveTraversability(const std::string& outfile);
00439 
00441         void resetBands();
00442 
00444         bool saveUtility(const std::string& outfile);
00446         bool saveEntropy(const std::string& outfile);
00448         bool savePotential(const std::string& outfile);
00449 
00451         double euclideanDistance(double, double, double, double);
00452 
00453         bool setUTMProjection(GDALDataset* inputDataset, int utmZone);
00454 
00455 
00456 // TODO
00458         //double getTraversabilityProbabilityLag();
00460         //double getRoughProbabilityLag();
00462         //double getTraversabilitySigmaFactor();
00464         //double getRoughSigmaFactor();
00466         double getSimulationProbaVisionLimit();
00467 
00468 
00469       private:
00470 
00472         std::string conffilename;
00473 
00475         std::string dsfilename;
00476 
00480         GDALDataset* dataset;   
00481 
00490         double refGeoTransform[6];
00491 
00494         CPLErr refGeoTransformRType;
00495 
00497         RasterCell rootCell;
00498 
00499         //------------- GDRasterBand s -------------//
00500 
00508         FUSION_METHOD fmethod;
00509 
00511         HOMOGENEOUS_TYPE htype;
00512 
00514         double decompositionLimit;
00515 
00517         double sigmaFactor;
00518 
00524         double probabilityLag;
00525 
00532         double simulationProbaVisionLimit;
00533 
00543         std::vector<BandDefinition> geoBands;
00544 
00545         //--------------- private functions -----------------//
00546 
00550         void info(std::ostream& info, bool verbose = true) const;
00551 
00552         friend std::ostream& operator<< (std::ostream& out, const GeoData& gd);
00553 
00554     }; /*}}} end of class GeoData*/
00555 
00559     inline std::ostream& operator<< (std::ostream& out, const GeoData& gd) {
00560       gd.info(out,true);
00561       return out;
00562     }
00563   } // namespace gramer
00564 } // namespace jafar
00565 
00566 #endif /* GRAMER_GEODATA_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:20 for Jafar by doxygen 1.7.6.1
LAAS-CNRS