rasdaman complete source
rimport.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 
46 #ifndef __rimport_h
47 #define __rimport_h
48 #define ctxRimport "rimport"
49 
50 #include <cstring>
51 
53 #ifdef EARLY_TEMPLATE
54 #define __EXECUTABLE__
55 #ifdef __GNUG__
56 #include "raslib/template_inst.hh"
57 #include "rasgeo_template_inst.hh"
58 #endif
59 #endif
60 
62 #include "gdal_priv.h"
63 #include "gdal_rat.h"
64 
66 #include "libpq-fe.h"
67 
69 #include "RasdamanHelper2.h"
70 
71 // required variables, if rasdaman is compiled with DEBUG enabled
72 #ifdef RMANDEBUG
73 int indentLevel;
74 bool debugOutput;
75 #endif
76 
78 struct NMsize
79 {
80  double x;
81  double y;
82  double z;
83 };
84 
85 struct Header
86 {
87  NMsize origin; // origin (upper left corner of the upper left pixel) (x,y)
88  long ncols; // number of columns
89  long nrows; // number of rows
90  long nlayers; // number of layers (i.e. z-axis)
91 
92  NMsize cellsize; // cellsize (x,y,z)
93  // for the following it is assumed that the image is north oriented
94  double xmin; // minimum x coordinate (real world coordinate)
95  // -> x coord. of the left edge of the leftmost pixel
96  double xmax; // maximum ...
97  // -> x coord. of the fight edge of the rightmost pixel
98  double ymax; // maximum y coordinate (real world coordinate)
99  // -> y coord. of the upper edge of the uppermost pixel
100  double ymin; // minimum ....
101  // -> y coord. of the lower edge of the lowermost pixel
102  double zmin;
103  double zmax;
104 
105  // some statistics if avaialable
106  double stats_max;
107  double stats_min;
108  double stats_mean;
109  double stats_stddev;
110 
111  int epsg_code; // epsg coordinate reference system code
112  std::string crs_name; // string representation of the coordinate reference system
113  r_Type::r_Type_Id rmantype; // the rasdaman pixel type of the image
114  GDALDataType gdaltype; // the gdal pixel type of the image
115  int nbands; // number of bands of the image
116  bool rat_avail; // denotes whether a raster attribute table is available (true) or not (false)
117 };
118 
119 int getDirContent(string path, string suffix, vector<string>&);
120 bool hasSuffix(string name, string suffix);
121 void readImageInformation(vector<string>& vnames, Header& header,
122  vector<double>& bnd, vector<string>& vvalidtiles,
123  bool b3D, double cellsizez);
124 bool readTileInformation(string filename, Header& header);
125 bool readTileInformation(GDALDataset* pDs, Header& header);
126 void printImageInformation(Header& header, RasdamanHelper2& helper);
127 void resetHeader(Header& header);
128 r_Type::r_Type_Id getRmanDataType(GDALDataType type);
129 bool tileOverlaps(Header& header, vector<double>& bnd);
130 bool parseCoordinateString(string bndstr, vector<double>& bnd);
131 bool parseTypeString(std::string typestr, std::vector<std::string>& types);
132 void showHelp();
133 
134 int importImage(RasdamanHelper2& helper, GDALDataset* pDs, string& collname, vector<double>& oids,
135  r_Minterval& readGDALImgDOM, r_Point& writeShift, Header& newGeoRegion,
136  bool asCube, std::string marraytypename, string tiling);
137 
138 int processImageFiles(vector<string>& filenames, string collname, vector<double>& oids,
139  Header& processRegion, string mode3D, r_Point& shiftPt, RasdamanHelper2& helper,
140  std::string marraytypename, string tiling);
141 
142 void intersectRegions2D(Header& inoutRegion, Header& intersectRegion);
143 void intersectRegions2D(Header& inoutRegion, std::vector<double>& intersectRegions);
144 void unionRegions2D(Header& inoutRegion, Header& unionRegion);
145 void unionRegions2D(Header& inoutRegion, std::vector<double>& unionRegion);
146 void copyRegion2D(Header& outRegion, Header& inRegion);
147 void copyRegion2D(Header& outRegion, std::vector<double>& inRegion);
148 
149 // DEBUG
150 void printRegion(Header& reg, string descr);
151 void printRegion(std::vector<double>& sdom, string descr);
152 
153 #endif // __rimport_h
double xmax
Definition: rimport.h:96
int nbands
Definition: rimport.h:115
double stats_stddev
Definition: rimport.h:109
double ymax
Definition: rimport.h:98
r_Type::r_Type_Id rmantype
Definition: rimport.h:113
double stats_max
Definition: rimport.h:106
double xmin
Definition: rimport.h:94
void unionRegions2D(Header &inoutRegion, Header &unionRegion)
double zmin
Definition: rimport.h:102
double z
Definition: rimport.h:82
Definition: rimport.h:85
double y
Definition: rimport.h:81
NMsize cellsize
Definition: rimport.h:92
int epsg_code
Definition: rimport.h:111
void printRegion(Header &reg, string descr)
double x
Definition: rimport.h:80
NMsize origin
Definition: rimport.h:87
bool hasSuffix(string name, string suffix)
bool parseTypeString(std::string typestr, std::vector< std::string > &types)
r_Type::r_Type_Id getRmanDataType(GDALDataType type)
double zmax
Definition: rimport.h:103
void intersectRegions2D(Header &inoutRegion, Header &intersectRegion)
void showHelp()
Helper class for handling rasdaman collections and images.
Definition: RasdamanHelper2.h:66
double stats_min
Definition: rimport.h:107
void printImageInformation(Header &header, RasdamanHelper2 &helper)
GDALDataType gdaltype
Definition: rimport.h:114
bool readTileInformation(string filename, Header &header)
RASDAMAN includes.
Definition: rimport.h:78
long nrows
Definition: rimport.h:89
long nlayers
Definition: rimport.h:90
r_Type_Id
Definition: raslib/type.hh:61
void copyRegion2D(Header &outRegion, Header &inRegion)
double stats_mean
Definition: rimport.h:108
long ncols
Definition: rimport.h:88
bool tileOverlaps(Header &header, vector< double > &bnd)
void readImageInformation(vector< string > &vnames, Header &header, vector< double > &bnd, vector< string > &vvalidtiles, bool b3D, double cellsizez)
bool rat_avail
Definition: rimport.h:116
std::string crs_name
Definition: rimport.h:112
int getDirContent(string path, string suffix, vector< string > &)
int importImage(RasdamanHelper2 &helper, GDALDataset *pDs, string &collname, vector< double > &oids, r_Minterval &readGDALImgDOM, r_Point &writeShift, Header &newGeoRegion, bool asCube, std::string marraytypename, string tiling)
void resetHeader(Header &header)
int processImageFiles(vector< string > &filenames, string collname, vector< double > &oids, Header &processRegion, string mode3D, r_Point &shiftPt, RasdamanHelper2 &helper, std::string marraytypename, string tiling)
double ymin
Definition: rimport.h:100
bool parseCoordinateString(string bndstr, vector< double > &bnd)