GlobeEngine
TileMapService.hpp
Go to the documentation of this file.
1 //
2 // TileMapService.hpp
3 // GlobeEngine
4 //
5 // Created by Alireza Amiraghdam on 15/05/16.
6 //
7 //
8 
9 #ifndef TileMapService_hpp
10 #define TileMapService_hpp
11 
12 #include <stdio.h>
13 #include <string>
14 #include "TMSXml.hpp"
15 #include "GlobeEngineGeoTiff.h"
16 #include "TileManager.hpp"
17 #include <vmmlib/vmmlib.hpp>
18 #include "SpatialKey.h"
19 #include "NormalCommand.h"
20 
21 namespace geTerrainPreprocess{
22 
24  int tileSize;
25  int bitPerSample = -1;
26  int samplePerPixel = -1;
27  int sampleFormat = -1;//1=UINT,2=INT,3=FLOAT
28  /* colorSpace:
29  * -1= from input;
30  * 0 = WhiteIsZero. For bilevel and grayscale images: 0 is imaged as white.
31  * 1 = BlackIsZero. For bilevel and grayscale images: 0 is imaged as black.
32  * 2 = RGB. RGB value of (0,0,0) represents black, and (255,255,255) represents white, assuming 8-bit components.
33  */
34  int colorSpace = -1;
35  std::string endFileName;
36  std::string extension;
37  };
38 
40  {
41  private:
42  std::string location;
43  int maxLod;
44  TMSTileSetting tmsTileSetting;
45  TMSXml tmsXml;
46  std::vector<vmml::Vector2d> pixelScalings;
47  TileManager tileManager;
48  std::function<void(int const&)> callbackProgress = nullptr;
49  std::function<void(std::string const&)> callbackLog = nullptr;
50  NormalCommand *normalCommand;
51  bool maxminZero = false;
52  std::string normalExtension;
53  std::string normalEndOfFileName;
54  unsigned short overlapping = 1;
55  int compression = 1;
56  public:
58  void initTiles(TMSTileSetting _tmsTileSetting){ tmsTileSetting = _tmsTileSetting; calculatePixelScaling(); };
59  void load();
60  void loadNormal();
61  void generateXml();
62  void importTiff(std::string _fileName, double _scale);
63  void produceNormal();
64  void readTileSetting();
65  void calculatePixelScaling();
66  std::shared_ptr<vmml::Vector4i> tileOfCoordinate(int _lod, vmml::Vector4f _coor);
70  void removeZeroTiles();
72  void readExistingMaxLod();
73  vmml::Vector4i readBoundingAtLod(int _lod);
74  void removeZeronNormals();
75 
76  public:
77  void setLocation(std::string _location){ location = _location[_location.size() - 1] == '/' ? _location.substr(0, _location.size() - 1) : _location; };
78  std::string getLocaiton(){ return location; };
79  void setMaxLod(int _maxLod){ maxLod = _maxLod; };
80  int getMaxLod(){ return maxLod; };
81  int getTileSize(){ return tmsTileSetting.tileSize; };
82  vmml::Vector2i getUVforTilesAtLod(int _Lod);
83  double getPixelScaleX(short _lod){ return pixelScalings[_lod].x(); };
84  double getPixelScaleY(short _lod){ return pixelScalings[_lod].y(); };
85  void setBitPerSample(int _bitPerSample){ tmsTileSetting.bitPerSample = _bitPerSample; };
86  void setSampleFormat(int _sampleFormat){ tmsTileSetting.sampleFormat = _sampleFormat; };
87  int getBitPerSample(){ return tmsTileSetting.bitPerSample; };
88  int getSampleFormat(){ return tmsTileSetting.sampleFormat; };
89  int getSamplePerPixel(){ return tmsTileSetting.samplePerPixel; };
90  int getColorSpace(){ return tmsTileSetting.colorSpace; };
91  void setSamplePerPixel(int _SamplePerPixel){ tmsTileSetting.samplePerPixel = _SamplePerPixel; };
92  void setColorSpace(int _ColorSpace){ tmsTileSetting.colorSpace = _ColorSpace; };
93  void setCallbackProgress(std::function<void(int const&)> const& _callbackProgress){ callbackProgress = _callbackProgress; };
94  void setCallbackLog(std::function<void(std::string const&)> const& _callbackLog){ callbackLog = _callbackLog; };
95  std::function<void(int const&)> getCallbackProgress(){ return callbackProgress; };
96  TileManager getTileManager(){ return tileManager; };
97  void setExtension(std::string _extension){ tmsTileSetting.extension = _extension; };
98  std::string getExtension(){ return tmsTileSetting.extension; };
99  void setEndFileName(std::string _endFileName){ tmsTileSetting.endFileName = _endFileName; };
100  std::string getEndFileName(){ return tmsTileSetting.endFileName; };
101  void setNormalCommand(NormalCommand *_nc){ normalCommand = _nc; };
102  NormalCommand *getNormalCommand(){ return normalCommand; };
103  void setMaxMinZero(){ maxminZero = true; };
104  void unsetMaxMinZero(){ maxminZero = false; };
105  void setNormalExtension(std::string _normalExtension){ normalExtension = _normalExtension; };
106  std::string getNormalExtension(){ return normalExtension; };
107  void setNormalEndOfFileName(std::string _normalEndOfFileName){ normalEndOfFileName = _normalEndOfFileName; };
108  std::string getNormalEndOfFileName(){ return normalEndOfFileName; };
109  void setOverlapping(int _overlapping){ overlapping = _overlapping; };
110  unsigned short getoverlapping(){ return overlapping; };
111  void setCompression(int _compression){ compression = _compression; };
112  int getCompression(){ return compression; };
113  private:
114  void createTilesInLodFromImage(int _lod, geoTiffIo::GlobeEngineGeoTiff _gTiff, double _scale);
115  void mergeUp(int _fromLod, int _toLod);
116  geoTiffIo::ScanLineBufferPtr ComputeNormalBuffer(geoTiffIo::ScanLineBufferPtr _bufin1, geoTiffIo::ScanLineBufferPtr _bufin2, geoTiffIo::ScanLineBufferPtr _bufin3);
117  };
118 }
119 
120 #endif /* TileMapService_hpp */
Definition: TileManager.hpp:30
int colorSpace
Definition: TileMapService.hpp:34
TileMapService()
Definition: TileMapService.cpp:57
int bitPerSample
Definition: TileMapService.hpp:25
void removeZeroTiles()
Definition: TileMapService.cpp:615
void removeZeronNormals()
Definition: TileMapService.cpp:638
void setMaxLod(int _maxLod)
Definition: TileMapService.hpp:79
void setCallbackLog(std::function< void(std::string const &)> const &_callbackLog)
Definition: TileMapService.hpp:94
void readTileSetting()
Definition: TileMapService.cpp:510
void setBitPerSample(int _bitPerSample)
Definition: TileMapService.hpp:85
void setCompression(int _compression)
Definition: TileMapService.hpp:111
int getSampleFormat()
Definition: TileMapService.hpp:88
void setOverlapping(int _overlapping)
Definition: TileMapService.hpp:109
unsigned short getoverlapping()
Definition: TileMapService.hpp:110
vmml::Vector4d getPCSBoundaryOfTile(geSpatial::SpatialKey2ui _key)
Definition: TileMapService.cpp:554
void setColorSpace(int _ColorSpace)
Definition: TileMapService.hpp:92
void unsetMaxMinZero()
Definition: TileMapService.hpp:104
void setNormalCommand(NormalCommand *_nc)
Definition: TileMapService.hpp:101
void readExistingMaxLod()
Definition: TileMapService.cpp:449
void loadNormal()
Definition: TileMapService.cpp:31
vmml::Vector2i getUVforTilesAtLod(int _Lod)
Definition: TileMapService.cpp:109
void removeEmptyDirectories()
Definition: TileMapService.cpp:586
std::string getNormalExtension()
Definition: TileMapService.hpp:106
void load()
Definition: TileMapService.cpp:15
std::string getExtension()
Definition: TileMapService.hpp:98
std::string getNormalEndOfFileName()
Definition: TileMapService.hpp:108
int tileSize
Definition: TileMapService.hpp:24
int getCompression()
Definition: TileMapService.hpp:112
int getSamplePerPixel()
Definition: TileMapService.hpp:89
std::string endFileName
Definition: TileMapService.hpp:35
int getBitPerSample()
Definition: TileMapService.hpp:87
Definition: NormalCommand.h:16
std::string getEndFileName()
Definition: TileMapService.hpp:100
int getMaxLod()
Definition: TileMapService.hpp:80
std::function< void(int const &)> getCallbackProgress()
Definition: TileMapService.hpp:95
int sampleFormat
Definition: TileMapService.hpp:27
void setLocation(std::string _location)
Definition: TileMapService.hpp:77
void importTiff(std::string _fileName, double _scale)
Definition: TileMapService.cpp:120
NormalCommand * getNormalCommand()
Definition: TileMapService.hpp:102
void calculatePixelScaling()
Definition: TileMapService.cpp:96
int getColorSpace()
Definition: TileMapService.hpp:90
Definition: TileMapService.hpp:23
void setMaxMinZero()
Definition: TileMapService.hpp:103
int samplePerPixel
Definition: TileMapService.hpp:26
void setNormalExtension(std::string _normalExtension)
Definition: TileMapService.hpp:105
Definition: NormalCommand.h:14
Definition: SpatialKey.h:137
double getPixelScaleX(short _lod)
Definition: TileMapService.hpp:83
void setEndFileName(std::string _endFileName)
Definition: TileMapService.hpp:99
Definition: TileMapService.hpp:39
TileManager getTileManager()
Definition: TileMapService.hpp:96
void checkAndCreateDirectory(geSpatial::SpatialKey2ui _key)
Definition: TileMapService.cpp:662
std::string extension
Definition: TileMapService.hpp:36
vmml::Vector4i readBoundingAtLod(int _lod)
Definition: TileMapService.cpp:456
void setCallbackProgress(std::function< void(int const &)> const &_callbackProgress)
Definition: TileMapService.hpp:93
vmml::Vector4d getPCSBoundaryOfPoint(geSpatial::SpatialKey2ui _key)
Definition: TileMapService.cpp:570
void setSampleFormat(int _sampleFormat)
Definition: TileMapService.hpp:86
void initTiles(TMSTileSetting _tmsTileSetting)
Definition: TileMapService.hpp:58
double getPixelScaleY(short _lod)
Definition: TileMapService.hpp:84
int getTileSize()
Definition: TileMapService.hpp:81
std::string getLocaiton()
Definition: TileMapService.hpp:78
Definition: TMSXml.hpp:51
void setSamplePerPixel(int _SamplePerPixel)
Definition: TileMapService.hpp:91
void setNormalEndOfFileName(std::string _normalEndOfFileName)
Definition: TileMapService.hpp:107
void produceNormal()
Definition: TileMapService.cpp:231
void generateXml()
Definition: TileMapService.cpp:61
std::shared_ptr< vmml::Vector4i > tileOfCoordinate(int _lod, vmml::Vector4f _coor)
Definition: TileMapService.cpp:542
void setExtension(std::string _extension)
Definition: TileMapService.hpp:97