rasdaman complete source
RasdamanHelper2.h
Go to the documentation of this file.
1 /*
2  * This file is part of rasdaman community.
3  *
4  * Rasdaman community is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Rasdaman community is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * Copyright 2003 - 2011 Peter Baumann / rasdaman GmbH.
18  *
19  * For more information please see <http://www.rasdaman.org>
20  * or contact Peter Baumann via <baumann@rasdaman.com>.
21  */
22 
23 /*
24  * Contributed to rasdaman by Alexander Herzig, Landcare Research New Zealand
25  */
26 
39 #ifndef RASDAMANHELPER2_H_
40 #define RASDAMANHELPER2_H_
41 
42 // general includes
43 #include <iostream>
44 #include <cstring>
45 #include <string>
46 #include <vector>
47 
48 // the rasdaman basic data types
49 #include "rasdaman.hh"
50 
51 #ifdef ORFEOMAN
52 // otb includes
53 #include "itkImageIOBase.h"
54 #endif
55 
56 // other includes
57 #include "RasdamanConnector.h"
58 
59 // postgresql
60 #include "libpq-fe.h"
61 
62 // gdal
63 #include "gdal_priv.h"
64 #include "gdal_rat.h"
65 
67 {
68 public:
69 
78  virtual ~RasdamanHelper2();
79 
86  double doesCollectionExist(std::string collname) throw (r_Error);
87 
89  void insertCollection(std::string collname, r_Type::r_Type_Id rtype, bool asCube);
90 
92  void insertUserCollection(std::string collname, std::string colltypename);
93 
95  void dropCollection(std::string collname);
96 
98  void dropImage(std::string collname, double oid);
99 
101  std::vector<double> getImageOIDs(std::string collname);
102 
110  r_Minterval getImageSdom(std::string collname, double localImgOID);
111 
112  r_Marray_Type *getMarrayType(std::string collname);
113 
115  r_Type::r_Type_Id getBaseTypeId(std::string collname);
116 
118  std::string getBaseTypeName(std::string collname);
119 
121  unsigned int getBaseTypeSize(std::string collname);
122 
124  unsigned int getBaseTypeElementCount(std::string collname);
125 
126  unsigned int getTypeSize(r_Type::r_Type_Id rtype) throw (r_Error);
127 
132  std::string getTypePrefixString(r_Type::r_Type_Id rtype);
133 
134  // perhaps we don't need this.
135  // bool setComponentType(r_Type::r_Type_Id rtype);
136 
145  void getImageBuffer(std::string collname, double localImgOID, char* buf,
146  r_Minterval& sdom);
147 
149  double insertImage(std::string collname, char* buf,
150  r_Point& shift, r_Minterval& sdom, bool bRowMajor2ColMajor,
151  std::string marraytypename, std::string tiling);
152 
154  void updateImage(std::string collname, double imgid,
155  char* buf, r_Point& shift, r_Minterval& sdom, bool bRowMajor2ColMajor,
156  std::string marraytypename)
157  throw (r_Error);
158 
159 
169  void colBuf2RowBuf(char* colbuf, char* rowbuf, r_Type::r_Type_Id rtype,
170  int ncols, int nrows, int nlayers) throw (r_Error);
171 
179  void colBuf2RowBuf(char* colbuf, char* rowbuf, unsigned int pixelsize,
180  r_Minterval& sdom);
181 
183  void colBuf2RowBuf(char* colbuf, char* rowbuf, unsigned int pixelsize,
184  unsigned int nelem, int ncols, int nrows, int nlayers);
185 
195  void rowBuf2ColBuf(char* rowbuf, char* colbuf, r_Type::r_Type_Id rtype,
196  int ncols, int nrows, int nlayers) throw (r_Error);
197 
205  void rowBuf2ColBuf(char* rowbuf, char* colbuf, unsigned int pixelsize,
206  r_Minterval& sdom);
207 
209  void rowBuf2ColBuf(char* rowbuf, char* colbuf, unsigned int pixelsize,
210  unsigned int nelem, int ncols, int nrows, int nlayers);
211 
220  std::vector<int> offset2index(int offset, std::vector<int>& sdom);
221 
224  std::vector<int> offset2index(int offset, r_Minterval& sdom);
225 
226  int index2offset(r_Minterval& sdom, std::vector<int>& index);
227  int index2offset(std::vector<int>& sdom, std::vector<int>& index);
228 
229  void createCollection(r_Database& db, r_Ref< r_Set< r_Ref< r_GMarray > > >& imgSet,
230  r_Type::r_Type_Id rtype, bool asCube) throw (r_Error);
231 
232  void createMDD(r_Ref< r_GMarray >& image, r_Minterval sdom,
233  r_Type::r_Type_Id rtype) throw (r_Error);
234 
235  std::string getNumConstChar(r_Type::r_Type_Id rtype) throw (r_Error);
236  int getWCPSTypeId(r_Type::r_Type_Id rtype);
237  std::string getDataTypeString(r_Type::r_Type_Id rtype);
238 
239  long getMaxImgSize(void)
240  {
241  return this->m_maximgsize;
242  };
243  void setMaxImgSize(long maximgsize)
244  {
245  this->m_maximgsize = maximgsize;
246  };
247 
248  bool isNMMetaAvailable(void);
249 
250  void writeNMMetadata(
251  string collname,
252  long oid,
253  long epsgcode,
254  string crsname,
255  double minx,
256  double maxx,
257  double miny,
258  double maxy,
259  double minz,
260  double maxz,
261  double csx,
262  double csy,
263  double csz,
264  string pixeltype,
265  double stats_min,
266  double stats_max,
267  double stats_mean,
268  double stats_stddev,
269  string RATName) throw (r_Error);
270 
271  int writeNMRAT(std::string filename, double oid, int band) throw(r_Error);
272  int writePSMetadata(
273  std::string collname,
274  std::string crs,
275  r_Type::r_Type_Id rtype,
276  int nbands,
277  double xmin,
278  double xmax,
279  double ymin,
280  double ymax,
281  double zmax,
282  double zmin,
283  int xpix, int ypix, int zpix);
284 
285  std::vector<double> getNMMetaGeoDomain(long oid);
286  std::vector<double> getNMMetaCellSize(long oid);
287  std::string getNMMetaCrsName(long oid);
288 
289  int deletePSMetadata(std::string collname);
290  int deleteNMMetadata(std::string collname, double oid);
291 
292 
293  bool checkDbConnection(void);
294 
295 protected:
300 
302  // gets read or write by this helper
304 
305 };
306 
307 
308 #endif /* RASDAMANHELPER2_H_ */
Definition: marraytype.hh:49
std::string getTypePrefixString(r_Type::r_Type_Id rtype)
Definition: transaction.hh:58
Definition: RasdamanConnector.h:49
Definition: point.hh:59
int index2offset(r_Minterval &sdom, std::vector< int > &index)
r_Transaction m_transaction
private transaction object of this helper
Definition: RasdamanHelper2.h:299
void writeNMMetadata(string collname, long oid, long epsgcode, string crsname, double minx, double maxx, double miny, double maxy, double minz, double maxz, double csx, double csy, double csz, string pixeltype, double stats_min, double stats_max, double stats_mean, double stats_stddev, string RATName)
Definition: error.hh:88
Definition: clientcomm.hh:46
std::string getDataTypeString(r_Type::r_Type_Id rtype)
bool isNMMetaAvailable(void)
double insertImage(std::string collname, char *buf, r_Point &shift, r_Minterval &sdom, bool bRowMajor2ColMajor, std::string marraytypename, std::string tiling)
void dropCollection(std::string collname)
void rowBuf2ColBuf(char *rowbuf, char *colbuf, r_Type::r_Type_Id rtype, int ncols, int nrows, int nlayers)
double doesCollectionExist(std::string collname)
RasdamanHelper2(RasdamanConnector *rasconn)
Definition: database.hh:60
long m_maximgsize
the maximum image (tile/buffer) size that
Definition: RasdamanHelper2.h:303
std::vector< int > offset2index(int offset, std::vector< int > &sdom)
Helper class for handling rasdaman collections and images.
Definition: RasdamanHelper2.h:66
r_Marray_Type * getMarrayType(std::string collname)
std::string getNMMetaCrsName(long oid)
bool checkDbConnection(void)
int writeNMRAT(std::string filename, double oid, int band)
Definition: oqlquery.hh:46
void createCollection(r_Database &db, r_Ref< r_Set< r_Ref< r_GMarray > > > &imgSet, r_Type::r_Type_Id rtype, bool asCube)
r_Type::r_Type_Id getBaseTypeId(std::string collname)
unsigned int getBaseTypeElementCount(std::string collname)
RasdamanConnector * m_pRasconn
pointer to the connection object
Definition: RasdamanHelper2.h:297
void insertUserCollection(std::string collname, std::string colltypename)
void dropImage(std::string collname, double oid)
r_Minterval getImageSdom(std::string collname, double localImgOID)
void setMaxImgSize(long maximgsize)
Definition: RasdamanHelper2.h:243
void getImageBuffer(std::string collname, double localImgOID, char *buf, r_Minterval &sdom)
int getWCPSTypeId(r_Type::r_Type_Id rtype)
long getMaxImgSize(void)
Definition: RasdamanHelper2.h:239
unsigned int getBaseTypeSize(std::string collname)
r_Type_Id
Definition: raslib/type.hh:61
void colBuf2RowBuf(char *colbuf, char *rowbuf, r_Type::r_Type_Id rtype, int ncols, int nrows, int nlayers)
int writePSMetadata(std::string collname, std::string crs, r_Type::r_Type_Id rtype, int nbands, double xmin, double xmax, double ymin, double ymax, double zmax, double zmin, int xpix, int ypix, int zpix)
void updateImage(std::string collname, double imgid, char *buf, r_Point &shift, r_Minterval &sdom, bool bRowMajor2ColMajor, std::string marraytypename)
std::string getBaseTypeName(std::string collname)
void createMDD(r_Ref< r_GMarray > &image, r_Minterval sdom, r_Type::r_Type_Id rtype)
virtual ~RasdamanHelper2()
void insertCollection(std::string collname, r_Type::r_Type_Id rtype, bool asCube)
std::string getNumConstChar(r_Type::r_Type_Id rtype)
int deleteNMMetadata(std::string collname, double oid)
std::vector< double > getNMMetaGeoDomain(long oid)
int deletePSMetadata(std::string collname)
std::vector< double > getImageOIDs(std::string collname)
Definition: minterval.hh:249
std::vector< double > getNMMetaCellSize(long oid)
unsigned int getTypeSize(r_Type::r_Type_Id rtype)