Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GeoData.hpp
00001 
00013 #ifndef LGL_GEODATA_HPP
00014 #define LGL_GEODATA_HPP
00015 
00016 #include <list>
00017 #include <vector>
00018 #include <iostream>
00019 #include <fstream>
00020 #include <string>
00021 
00022 #include <gdal_priv.h>
00023 //#include <cpl_string.h>
00024 #include <ogr_spatialref.h>
00025 
00026 #include <lgl/RasterBand.hpp>
00027 #include <lgl/InfoBand.hpp>
00028 #include <lgl/LandmarkBand.hpp>
00029 #include <lgl/Attributes.hpp>
00030 
00031 
00032 namespace jafar {
00033   namespace lgl {
00034    
00035 
00036     // the index of raster bands inside the data set 
00037     typedef enum {GEODATA_TFLAT_BAND=1,
00038                   GEODATA_TROUGH_BAND,
00039                   GEODATA_TRICLASSOBST_BAND,
00040                   GEODATA_LANDMARK_BAND,
00041             GEODATA_VISIBILITY_BAND,
00042             GEODATA_VISIBILITY_HEIGHT_BAND,
00043                   GEODATA_NMAX_BAND} GEODATA_BAND;
00044 
00045     typedef enum {ENTROPY_MAP=0,
00046                   POTENTIAL_MAP,
00047                   UTILITY_MAP} GEODATA_INTERNAL_MAP;
00048 
00053     class GeoData : public Raster
00054     { /*{{{*/ 
00055       public:
00056 
00057         static const double DEFAULT_DATA_VALUE() { return -1.0; };
00058         static const double GEODATA_DEFAULT_SCALE() { return 1.0; };
00059       
00060         //enum FUSION_METHOD // defined in RasterBand.hpp
00061 
00062         
00064         GeoData();
00065 
00067         GeoData(const std::string& _dsfilename, FUSION_METHOD _fmethod=MEAN);
00068 
00070         GeoData(int _xsize, int _ysize, double* _bufferedData, FUSION_METHOD _fmethod=MEAN);
00071 
00073         ~GeoData();
00074 
00075         bool loadBand(GEODATA_BAND band, const std::string& _dsfilename);
00076         bool loadInfoBand(const std::string& _dsfilename, GEODATA_BAND aband);
00077         bool loadLandmarkBand(const std::string& _dsfilename);
00078 
00087         int isInVirtualMemory;
00088 
00090         double* mapPotential;
00091 
00093         double* mapH;
00094 
00095         double* mapUtility;
00096         //------------------- getters
00097 
00098         GDALDataset* getDataset() const;
00099 
00100         void getAffineTransform(double& _utmXRoot, double& _utmYRoot, double& _cellXRes, double& _cellYRes); 
00101 
00105         int getxroot() const;
00106         int getyroot() const;
00107         int getxsize() const;
00108         int getysize() const;
00109 
00110         double getScale() const;
00111 
00113         double geoxroot() const;
00115         double geoyroot() const;
00117         double geoxend() const;
00119         double geoyend() const;
00121         double geoxres() const;
00123         double geoyres() const;
00124 
00126         double getValueFromBand(GEODATA_BAND _aband, int index);
00127 
00131         double getValueFromBand(GEODATA_BAND _aband, int xindex, int yindex);
00132 
00133         // get the value atr given raster cell (x,y)
00134         double getData(GEODATA_BAND band, const RasterCellIndex& cell) const;
00135 
00136         // fusion
00137         double getData(const RasterCellIndex& cell) const;
00138         
00139         // get the fusion value of all bands at cluster rect
00140         double getData(const RasterRect& rect) const;
00141         double getData(GEODATA_BAND band, const RasterRect& rect) const;
00142         
00143         GDRasterBand<double>* getBand(GEODATA_BAND band);
00144         
00145         double getInterpolatedValue(GEODATA_BAND _aband, double xNavLoc, double yNavLoc);
00146         //-------------- setters
00147 
00149         void setScale(double _scale);
00150 
00153         void setValueInBand(GEODATA_BAND _aband, int _index, double _val);
00154 
00159         void setFusingMethod(FUSION_METHOD _fmethod);
00160 
00161         //void setGeoTransform(double _utmXRoot, double _utmYRoot, double _cellXRes, double _cellYRes); 
00162         bool setData(double* bufferedData, double* bufferedOther, int _xsize, int _ysize, int _band = GEODATA_TFLAT_BAND);
00163 
00175         bool setData(int at_i, int at_j, Attributes inatt, bool internalTransfer=true);
00176 
00178         void setDecompositionLimit(double _dl);
00179 
00181         void setDecompositionType(HOMOGENEOUS_TYPE ht_);
00182 
00184         void setProbabilityLag(double probaLag_);
00185 
00187         void setSigmaFactor(double sigmaF_);
00188 
00190         void setSimulationProbaVisionLimit(double spvl_);
00191 
00192         //-------------- testers
00196         bool isHomogeneous(const RasterRect& rect) const;
00197 
00198         // same value at all bands
00199         bool sameValue(const RasterRect& rect);
00200         // same value at given band
00201         bool sameValue(GEODATA_BAND band, const RasterRect& rect);
00202 
00206         bool overlaps(GeoData* _toMerge);
00207 
00208         //---------------- smarters
00209 
00221         bool mergeStrict(GeoData* _toMerge, GEODATA_BAND _aband);
00222 
00227         void addDataset(GDALDataset *_dataset);
00228 
00240         void fuseData(GeoData *_geodata2, GEODATA_BAND _aband, const RasterRect& innerRect, const RasterRect& fusingRect);
00241         
00248         double calculateBandHomogeneityPercentage(GEODATA_BAND _aband);
00249 
00251         void printInfo(bool verbose = true) const;
00252 
00254         bool saveData(const std::string& outfile, const char* wFormat="GTIFF");
00255 
00257         void bufferToMem();
00258 
00260         void memToBuffer();
00261 
00263         bool saveTraversability(const std::string& outfile);
00264 
00266         void resetBands();
00267 
00274         bool createNewInfoBand(GDInfoBand** thatNewBand);
00275 
00277         bool initUtility();
00278 
00292         bool setMap(GEODATA_INTERNAL_MAP map2set,double v1_, int x1_, int y1_, double v2_, int x2_, int y2_);
00293 
00295         bool buildUtility();
00296 
00297         void resetUtility();
00298 
00300         bool saveUtility(const std::string& outfile);
00302         bool saveEntropy(const std::string& outfile);
00304         bool savePotential(const std::string& outfile);
00305 
00307         double euclideanDistance(double, double, double, double);
00308 
00309         bool setUTMProjection(GDALDataset* inputDataset, int utmZone);
00310 
00312         double getFootPrintEntropy(int, int);
00313 
00315         HOMOGENEOUS_TYPE getTraversabilityHomogeneousType();
00317         HOMOGENEOUS_TYPE getRoughHomogeneousType();
00319         double getTraversabilityProbabilityLag();
00321         double getRoughProbabilityLag();
00323         double getTraversabilitySigmaFactor();
00325         double getRoughSigmaFactor();
00327         double getSimulationProbaVisionLimit();
00328 
00329 
00334         bool isVisionTransparent(int atx, int aty, int atz=0);
00335 
00341         bool loadVisibility ( const std::string& _visibilityFileName );
00342 
00343       private:
00344 
00346         double decompositionLimit;
00347 
00349         std::string dsfilename;
00350 
00354         GDALDataset* dataset;   
00355 
00364         double refGeoTransform[6];
00365 
00368         CPLErr refGeoTransformRType;
00369 
00370         //------------- GDRasterBand s -------------//
00371 
00374         //GDRasterBand<double>* mainBand;
00375 
00377         GDInfoBand* traversabilityBand;
00379         GDLandmarkBand* landmarkBand;
00381         GDInfoBand* roughTerrainBand;
00383         GDInfoBand* visibilityBand;
00385         GDInfoBand* visibilityHeightBand;
00386 
00392         FUSION_METHOD fmethod;
00393 
00400         double simulationProbaVisionLimit;
00401 
00405         void info(std::ostream& info, bool verbose = true) const;
00406             
00407         friend std::ostream& operator<< (std::ostream& out, const GeoData& gd);
00408 
00425         bool loadData(const std::string& _dsfilename, GDALDataset* _useThisDataset=NULL);
00426 
00433         bool loadVisibilityData(const std::string& _visibilityFileName, GDALDataset* _useThisDataset);
00434 
00435         // Friendly class
00436         friend class NavGraph;
00437         friend class PositionMap;
00438         friend class Decomp; 
00439 
00440     }; /*}}} end of class GeoData*/
00441 
00445     inline std::ostream& operator<< (std::ostream& out, const GeoData& gd) {
00446       gd.info(out,true);
00447       return out;
00448     }
00449   } // namespace lgl
00450 } // namespace jafar
00451 
00452 #endif /* LGL_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