ToolMap
Loading...
Searching...
No Matches
tmgisdataraster.h
1/***************************************************************************
2 tmgisdataraster.h
3 Super class for dealing with raster GIS data
4 -------------------
5 copyright : (C) 2007 CREALP Lucien Schreiber
6 ***************************************************************************/
7
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17// comment doxygen
18
19#ifndef _TM_GISDATARASTER_H_
20#define _TM_GISDATARASTER_H_
21
22// For compilers that support precompilation, includes "wx/wx.h".
23#include <wx/wxprec.h>
24
25// Include wxWidgets' headers
26#ifndef WX_PRECOMP
27#include <wx/wx.h>
28#endif
29
30#include <wx/dir.h> // for computing dir size
31
32#include "tmgisdata.h"
33
34DECLARE_EVENT_TYPE(tmEVT_LM_ROTATION_WARNING, -1)
35DECLARE_EVENT_TYPE(tmEVT_LM_INCOMPATIBLE_WARNING, -1)
36
37// if you add some raster format, don't forget
38// to update the tmGISVECTOR_OFFSET
39enum tmGISDATA_RASTER_TYPES {
40 tmGIS_RASTER_TIFF = 0,
41 tmGIS_RASTER_BINGRID,
42 tmGIS_RASTER_JPEG,
43 tmGIS_RASTER_WEB
44};
45
46static wxString tmGISDATA_RASTER_TYPE_WILDCARDS[] = {wxTRANSLATE("Tiff raster file (*.tif,*.tiff)|*.tif;*.tiff"),
47 wxTRANSLATE("Esri's binary GRID (hdr.adf)|hdr.adf"),
48 wxTRANSLATE("Jpeg raster file (*.jpg, *.jpeg)|*.jpg;*.jpeg")};
49
50static wxString tmGISDATA_RASTER_TYPE_EXTENSION[] = {_T("*.tif;*.tiff"), _T("*.adf"), _T("*.jpg;*.jpeg"), _T("*.xml")};
51
52const wxString tmRASTER_DATATYPES[] = {wxTRANSLATE("Unknown data type"),
53 wxTRANSLATE("Eight bit unsigned integer"),
54 wxTRANSLATE("Sixteen bit unsigned integer"),
55 wxTRANSLATE("Sixteen bit signed integer"),
56 wxTRANSLATE("Thirty two bit unsigned integer"),
57 wxTRANSLATE("Thirty two bit signed integer"),
58 wxTRANSLATE("Thirty two bit floating point"),
59 wxTRANSLATE("Sixty four bit floating point"),
60 wxTRANSLATE("Complex Int16"),
61 wxTRANSLATE("Complex Int32"),
62 wxTRANSLATE("Complex Float32"),
63 wxTRANSLATE("Complex Float64"),
64 wxTRANSLATE("Data type out of limits")};
65
66class tmGISDataRaster : public tmGISData {
67 private:
68 protected:
69 GDALDataset* m_DataSet;
70 GDALRasterBand* m_RasterBand;
71 wxString m_FileType;
72 wxRect m_PxImgFilter;
73 tmRealRect m_RasterExtent;
74 tmRealRect m_ClippedCoord;
75
76 wxArrayString m_RotationName;
77 wxArrayShort m_RotationStatus;
78
79 wxSize GetImagePxDim();
80
81 bool GetImagePxSize(double& pxsizeX, double& pxsizeY, const tmRealRect& imgrealcoord = tmRealRect(0, 0, 0, 0));
82
83 wxRect ConvertClipedImage(const tmRealRect& origin, const tmRealRect& clipped);
84
85 // reading image (DTM)
86 void* ReadImageData(GDALRasterBand* gdalBand, const wxRect& imgfilter, const wxSize& imgSize, int& buffsize);
87
88 double ReadGDALValueToDouble(void* data, GDALDataType type, int index);
89
90 // statistics function
91 bool GetStatMinMaxNoDataValue(double& dmin, double& dmax, double& dnodata);
92
93 public:
95
97
98 // standard GDAL functions
99 virtual bool Open(const wxString& filename, bool bReadWrite = TRUE);
100
101 void UseExisting(const wxString& filename, GDALDatasetH hdst);
102
103 virtual tmRealRect GetMinimalBoundingRectangle();
104
105 // static functions
106 static void InitGISDriversRaster();
107
108 static wxString GetAllRasterGISFormatsWildcards();
109
110 static tmGISDataRaster* CreateGISRasterBasedOnType(const int& gis_format_index);
111
112 static tmGISDataRaster* CreateGISRasterBasedOnExt(const wxString& extension);
113
114 // gis functions
115 virtual TM_GIS_SPATIAL_TYPES GetSpatialType() {
116 return LAYER_SPATIAL_RASTER;
117 }
118
119 // reading functions
120 virtual bool SetSpatialFilter(tmRealRect filter, int type);
121
122 virtual bool IsImageInsideVisibleArea();
123
124 virtual CPLErr GetImageData(unsigned char** imgbuf, unsigned int* imglen, unsigned char** maskbuf,
125 unsigned int* masklen, wxSize imgSize);
126
127 bool GetImageTranslucency(wxSize imgSize, int translucencypercent, unsigned char** alphachn);
128
129 virtual tmRealRect GetImageClipedCoordinates() {
130 return m_ClippedCoord;
131 }
132
133 virtual int GetBandCount();
134
135 virtual int GetPyramidsInfo(wxArrayString* pyramids = nullptr);
136
137 // virtual function for metadata
138 virtual wxString GetMetaDataAsHtml();
139
140 wxString GetBandMetaData();
141
142 wxString GetUnitMetaData();
143
144 wxString GetPyramidsMetadata();
145
146 wxString GetImagePxSizeMetadata();
147
148 virtual bool CreateSpatialIndex(GDALProgressFunc progress, void* pfProgressData);
149
150 virtual int IsRaster() {
151 return 1;
152 }
153};
154
155class tmRotationWarning_DLG : public wxDialog {
156 private:
157 bool m_Hide;
158 double m_Rotation1;
159 double m_Rotation2;
160 wxString m_Layer;
161
162 wxString m_TxtTemplate;
163
164 wxStaticText* m_TextLayerCtrl;
165 wxStaticText* m_TextRotationCtrl;
166 wxCheckBox* m_HideCtrl;
167 wxStdDialogButtonSizer* m_BtnSizerCtrl;
168 wxButton* m_BtnSizerCtrlOK;
169 wxButton* m_BtnSizerCtrlHelp;
170
171 void _CreateControls();
172
173 void OnHelp(wxCommandEvent& event);
174
175 public:
176 tmRotationWarning_DLG(wxWindow* parent, wxWindowID id, const wxString& title);
177
178 virtual ~tmRotationWarning_DLG();
179
180 virtual bool TransferDataFromWindow();
181
182 virtual bool TransferDataToWindow();
183
184 inline const bool GetHide() const;
185
186 void SetHide(bool value);
187
188 inline const double GetRotation1() const;
189
190 void SetRotation1(double value);
191
192 inline const double GetRotation2() const;
193
194 void SetRotation2(double value);
195
196 inline const wxString GetLayerName() const;
197
198 void SetLayerName(wxString value);
199};
200
201inline const bool tmRotationWarning_DLG::GetHide() const {
202 return m_Hide;
203}
204
205inline const double tmRotationWarning_DLG::GetRotation1() const {
206 return m_Rotation1;
207}
208
209inline const double tmRotationWarning_DLG::GetRotation2() const {
210 return m_Rotation2;
211}
212
213inline const wxString tmRotationWarning_DLG::GetLayerName() const {
214 return m_Layer;
215}
216
217#endif
Definition tmgisdataraster.h:66
virtual int GetPyramidsInfo(wxArrayString *pyramids=nullptr)
Get info about pyramids.
Definition tmgisdataraster.cpp:928
bool GetImagePxSize(double &pxsizeX, double &pxsizeY, const tmRealRect &imgrealcoord=tmRealRect(0, 0, 0, 0))
Return width and height of pixels in real units.
Definition tmgisdataraster.cpp:191
wxString GetUnitMetaData()
Get Informations about Unit formatted for html.
Definition tmgisdataraster.cpp:912
wxString GetBandMetaData()
Getting number of band formatted as html.
Definition tmgisdataraster.cpp:897
virtual CPLErr GetImageData(unsigned char **imgbuf, unsigned int *imglen, unsigned char **maskbuf, unsigned int *masklen, wxSize imgSize)
Extract image data.
Definition tmgisdataraster.cpp:325
bool GetStatMinMaxNoDataValue(double &dmin, double &dmax, double &dnodata)
Returning min - max - nodata stat.
Definition tmgisdataraster.cpp:818
wxString GetImagePxSizeMetadata()
Get Pixels width and height.
Definition tmgisdataraster.cpp:1008
bool GetImageTranslucency(wxSize imgSize, int translucencypercent, unsigned char **alphachn)
Return the buffer corresponding to an alpha channel with specified translucency.
Definition tmgisdataraster.cpp:707
virtual bool SetSpatialFilter(tmRealRect filter, int type)
Define the area of interest.
Definition tmgisdataraster.cpp:272
double ReadGDALValueToDouble(void *data, GDALDataType type, int index)
Getting double value from data returned by GDAL.
Definition tmgisdataraster.cpp:770
wxSize GetImagePxDim()
Get Image dimensions in Pixels.
Definition tmgisdataraster.cpp:170
virtual int GetBandCount()
Getting number of band.
Definition tmgisdataraster.cpp:883
void * ReadImageData(GDALRasterBand *gdalBand, const wxRect &imgfilter, const wxSize &imgSize, int &buffsize)
Reading image data based on GDAL type.
Definition tmgisdataraster.cpp:742
virtual bool IsImageInsideVisibleArea()
Should we load image data.
Definition tmgisdataraster.cpp:297
virtual wxString GetMetaDataAsHtml()
Get Metadata information well formated.
Definition tmgisdataraster.cpp:858
virtual bool Open(const wxString &filename, bool bReadWrite=TRUE)
Generic open code.
Definition tmgisdataraster.cpp:47
wxRect ConvertClipedImage(const tmRealRect &origin, const tmRealRect &clipped)
Convert clipped Real size to image pixels size.
Definition tmgisdataraster.cpp:213
wxString GetPyramidsMetadata()
Getting pyramids info as html string.
Definition tmgisdataraster.cpp:979
Main class for dealing with GIS data.
Definition tmgisdata.h:48
Class representing real rectangle.
Definition tmgisscale.h:44
Definition tmgisdataraster.h:155