summaryrefslogtreecommitdiffstats
path: root/conversion/convfactory.cc
blob: 31f27aedaa33e19faa34861c5ecbd72be1f32bd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
/
/**
 * SOURCE: convertor.cc
 *
 * MODULE:  conversion
 *
 * CLASSES: r_Convertor_Factory
 * 	Create convertors out of data formats
 *
 * COMMENTS:
 * - temporary, for debugging
*/

#include "raslib/rminit.hh"
#include "debug.hh"

#include "conversion/convfactory.hh"

// all the conversion types, for easy creation
#include "tiff.hh"
#include "hdf.hh"
#include "png.hh"
#include "jpeg.hh"
#include "bmp.hh"
#include "vff.hh"
#include "tor.hh"
#include "dem.hh"
#include "ecw.hh"
#include "ntf.hh"
#include "csv.hh"



bool r_Convertor_Factory::is_supported( r_Data_Format fmt )
{
  ENTER( "r_Convertor_Factory::is_supported( " << fmt << " )" );

  bool retval=false;
  switch (fmt)
  {
    case r_TIFF:
    case r_PNG:
    case r_JPEG:
    case r_BMP:
    case r_VFF:
    case r_TOR:
    case r_DEM:
    case r_ECW:
#ifndef DISABLE_HDF
    case r_HDF:
#endif
    // case r_NTF:
      retval=true;
      break;
    default:
      retval=false;
      break;
  }

  LEAVE( "r_Convertor_Factory::is_supported() -> " << retval );
  return retval;
}

r_Convertor *r_Convertor_Factory::create( r_Data_Format fmt, const char *src, const r_Minterval &interv, const r_Type *tp) throw(r_Error)
{
  ENTER( "r_Convertor_Factory::create( fmt=" << fmt << ", &src=" << ((r_Ptr) src) << ", interval=" << interv << ", &type=" << ((r_Ptr) tp) << " )" );
  r_Convertor *result = NULL;

  switch (fmt)
  {
    case r_TIFF:
      result = new r_Conv_TIFF(src, interv, tp);
      break;
    case r_PNG:
      result = new r_Conv_PNG(src, interv, tp);
      break;
    case r_CSV:
      result = new r_Conv_CSV(src, interv, tp);
      break;
    case r_JPEG:
      result = new r_Conv_JPEG(src, interv, tp);
      break;
    case r_BMP:
      result = new r_Conv_BMP(src, interv, tp);
      break;
    case r_VFF:
      result = new r_Conv_VFF(src, interv, tp);
      break;
    case r_TOR:
      result = new r_Conv_TOR(src, interv, tp);
      break;
    case r_DEM:
      result = new r_Conv_DEM(src, interv, tp);
      break;      
    case r_ECW:
      result = new r_Conv_ECW(src, interv, tp);
      break;      
#ifndef DISABLE_HDF
    case r_HDF:
      result = new r_Conv_HDF(src, interv, tp);
      break;
#endif
    // case r_NTF:
    //   TALK( "creating NTF converter..." );
    //   result = new r_Conv_NTF(src, interv, tp);
    //   break;      
    default:
      RMInit::logOut << "Error: in conversion factory during create: unsupported format: " << fmt << endl;
      r_Error err(CONVERSIONFORMATNOTSUPPORTED);
      throw(err);
  }

  LEAVE( "r_Convertor_Factory::create() -> " << result );
  return result;
}


r_Convertor *r_Convertor_Factory::create( r_Data_Format fmt, const char *src, const r_Minterval &interv, int type ) throw(r_Error)
{
  ENTER( "r_Convertor_Factory::create( fmt=" << fmt << ", &src=" << ((r_Ptr) src) << ", interval=" << interv << ", type=" << type << " )" );

  r_Convertor *result = NULL;

  switch (fmt)
  {
    case r_TIFF:
      result = new r_Conv_TIFF(src, interv, type);
      break;
    case r_PNG:
      result = new r_Conv_PNG(src, interv, type);
      break;
    case r_JPEG:
      result = new r_Conv_JPEG(src, interv, type);
      break;
    case r_BMP:
      result = new r_Conv_BMP(src, interv, type);
      break;
    case r_VFF:
      result = new r_Conv_VFF(src, interv, type);
      break;
    case r_TOR:
      result = new r_Conv_TOR(src, interv, type);
      break;      
    case r_DEM:
      result = new r_Conv_DEM(src, interv, type);
      break;            
    case r_ECW:
      result = new r_Conv_ECW(src, interv, type);
      break;            
#ifndef DISABLE_HDF
    case r_HDF:
      result = new r_Conv_HDF(src, interv, type);
      break;
#endif
    // case r_NTF:
    //   TALK( "creating NTF converter..." );
    //   result = new r_Conv_NTF(src, interv, type);
    //   break;      
    default:
      RMInit::logOut << "Error: in conversion factory during create: unsupported format: " << fmt << endl;
      r_Error err(CONVERSIONFORMATNOTSUPPORTED);
      throw(err);
  }

  LEAVE( "r_Convertor_Factory::create() -> " << result );
  return result;
}