summaryrefslogtreecommitdiffstats
path: root/rasodmg/test/test_alignedtiling.cc
blob: 636a3c14fefc4d07ded3067171f5c37eab9134ce (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
/*
* 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: test_alignedtiling.cc
 *
 * MODULE: rasodmg
 *
 * COMMENTS:
 *		None
*/

#include <iostream>
#include <string.h>

#ifdef __VISUALC__
  #define __EXECUTABLE__
#endif
// #include "clientcomm/clientcomm.hh"
#include "rasodmg/ref.hh"
#include "rasodmg/transaction.hh"
#include "rasodmg/database.hh"
#include "rasodmg/set.hh"
#include "rasodmg/marray.hh"
#include "rasodmg/odmgtypes.hh"
#include "raslib/minterval.hh"
#include "rasodmg/alignedtiling.hh"
#ifdef __VISUALC__
  #undef  __EXECUTABLE__
#endif


int checkArguments( int argc, char** argv, const char* searchText, int& optionValueIndex )
{
  int found = 0;
  int i=1;

  while( !found && i<argc )
    found = !strcmp( searchText, argv[i++] );   

  if( found && i<argc && !strchr(argv[i],'-') )
    optionValueIndex = i;
  else
    optionValueIndex = 0;
  
  return found;
}


int main( int argc, char** argv )
{   
  
  int  optionValueIndex;
  if( argc < 5 || checkArguments( argc, argv, "-h", optionValueIndex ) )
  {
    cout << "Usage:   test_alignedtiling tile_config tile_size  cell_size domain" << endl << endl;
    cout << "Options: -h  ... this help" << endl;
    cout << endl;
    return 0;
  }
  
  r_Minterval* tile_config = 0;
  r_Minterval* domain = 0;
  
  try {
    tile_config = new r_Minterval( argv[1] );
    domain = new r_Minterval( argv[4] );
  }
  catch (...)
  {
     return -1;
  }
  
  unsigned cell_size = strtoul( argv[3], (char **)NULL, 10 );
  unsigned long tile_size = strtoul( argv[2],  (char **)NULL, 10 );
     
  cout << "Tile Config " << *tile_config << endl;
  r_Aligned_Tiling storeOptions( *tile_config, tile_size );
  
  cout << endl;

  cout << "Tiling Options : ts - " << storeOptions.get_tile_size( ) 
       << ", tc - " << storeOptions.get_tile_config( ) << endl;  
  
  cout << "Object domain : " << *domain << ", cell size " << cell_size << endl; 
 

  r_Aligned_Tiling newSL(storeOptions);
      
  cout << "Testing copy constructor. Newly constructed object..." << endl;
  cout << "Tiling Options : ts - " << storeOptions.get_tile_size( ) 
       << ", tc - " << storeOptions.get_tile_config( ) << endl;  
  
  cout << "Object domain : " << *domain << ", cell size " << cell_size << endl;
  
  r_Minterval result_tile = 
    storeOptions.compute_tile_domain(cell_size, *domain);
  
  cout << "Tiling Options resulting tile :" << result_tile << endl;
  
  
  delete domain;
  delete tile_config;
   
  return 0;
}