TsManagerDataSource.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file TsManagerDataSource.cpp
22 
23  \brief A static class for managing the resources used by Test suit.
24  */
25 
26 // TerraLib
27 #include <terralib/common.h>
28 #include <terralib/dataaccess.h>
29 #include <terralib/datatype.h>
30 #include <terralib/geometry.h>
31 //#include <terralib/gdal2.h>
32 #include <terralib/raster.h>
33 // Unit-Test TerraLib
34 #include "TsManagerDataSource.h"
35 #include "../dataaccess/Config.h"
36 #include <terralib/dataaccess/datasource/DataSourceFactory.h> //por algum motivo se nao colocar essa linha pega o antigo.
37 
38 // Boost
39 #include <boost/property_tree/json_parser.hpp>
40 #include <boost/foreach.hpp>
41 
42 // cppUnit
43 #include <cppunit/extensions/HelperMacros.h>
44 
45 // static members defined aand loaded from *.json file for each driver(postgis.json, gdal.josn, mysql.json, etc)
46 
47 // Datasource type and connection parameters
48 //std::auto_ptr<te::da::DataSource> TsManagerDataSource::sm_datasource;
51 std::map<std::string, std::string> TsManagerDataSource::sm_connInfo;
52 std::map<std::string, std::string> TsManagerDataSource::sm_connInfoExist;
53 
55 std::map<std::string, std::string> TsManagerDataSource::sm_connInfoNewDs;
56 std::map<std::string, std::string> TsManagerDataSource::sm_connInfoDropDs;
58 
59 // Vector of dataSetTypes names, envelops, rect, size, recsize
60 std::vector<std::string> TsManagerDataSource::sm_vecDtNames;
61 std::vector<te::gm::Envelope> TsManagerDataSource::sm_vecEnvelops;
62 std::vector<te::gm::Envelope> TsManagerDataSource::sm_recEnvelops;
63 std::vector<size_t> TsManagerDataSource::sm_dtSize;
64 std::vector<size_t> TsManagerDataSource::sm_dtRecSize;
65 
66 //Pair of values based on vectors above
67 std::vector<std::pair<std::string, te::gm::Envelope> > TsManagerDataSource::sm_vecDtNamesAndEnvelops;
68 std::vector<std::pair<std::string, te::gm::Envelope> > TsManagerDataSource::sm_vecNamesAndRecs;
69 std::vector<std::pair<std::string, size_t> > TsManagerDataSource::sm_vecNamesSizes;
70 std::vector<std::pair<std::string, size_t> > TsManagerDataSource::sm_vecNamesSizesRec;
71 
72 // DataSetType names
73 std::string TsManagerDataSource::sm_newDataSetType; //used in loadCatalog and Persistence
74 std::string TsManagerDataSource::sm_newCapabilitiesDt; //based on DataSource Capabilities
75 std::string TsManagerDataSource::sm_dtcloned; //cloned
76 std::string TsManagerDataSource::sm_newDataSetType2; //used to rename cloned one
77 std::string TsManagerDataSource::sm_newDataSetType3; //used to create dt with pk,uk,idx, etc.
78 
80 
81 // Names of primary key, Unique key, Index, Foreign Key, Sequences and Check Constraints
82 std::vector<std::string> TsManagerDataSource::sm_vecPkNames;
83 std::vector<std::string> TsManagerDataSource::sm_vecUkNames;
84 std::vector<std::string> TsManagerDataSource::sm_vecIdxNames;
85 std::vector<std::string> TsManagerDataSource::sm_vecFkNames;
86 std::vector<std::string> TsManagerDataSource::sm_vecSeqNames;
87 std::vector<std::string> TsManagerDataSource::sm_vecCcNames;
88 
89 // Defining some geometries valid for the first dataSet in sm_vecDtNames (postgis: "br_munic_2001" and city "Ouro Preto")
90 //TODO:Agora s� tem dado para o primeiro dt=br_munic_2001 , mas pode ter mais e o teste varrer os datasets...
91 te::gm::Envelope TsManagerDataSource::sm_box; //(-43.9329795837402, -20.6328010559082, -43.4036407470703, -20.1612071990967);
92 te::gm::Point TsManagerDataSource::sm_pt; //(4291, 0, -43.6107606714293, -20.3913548070123);
95 
96 // Used in DataSetTypePersistence
100 
101 std::string TsManagerDataSource::sm_ccName; //check constrain name
103 
104 // Defining specific variables to test DataSetTypePersistence...
105 
106 // Attribute names
116 
123 
126 
127 // End of Specification of variables to be used in TsDataSetTypePersistence
128 
129 void TsManagerDataSource::ConvertVectorToEnvelope(std::vector<std::vector<double> >& vectd, std::vector<te::gm::Envelope>& vecte)
130 {
131  std::vector<std::vector<double> >::iterator it;
132  te::gm::Envelope envi;
133  std::vector<double> vecti;
134  for(it = vectd.begin(); it < vectd.end(); it++)
135  {
136  vecti = (*it);
137  te::gm::Envelope envi(vecti);
138  vecte.push_back(envi);
139  }
140 }
141 
142 void TsManagerDataSource::ConvertVectorToPoints(std::vector<std::vector<double> >& vectd, std::vector<te::gm::Point>& vectp)
143 {
144  std::vector<std::vector<double> >::iterator it;
145  std::vector<double>::iterator it1;
146  te::gm::Point pt;
147  double d[3]={0.0,0.0,0.0};int i=0;
148  std::vector<double> vecti;
149  for(it = vectd.begin(); it < vectd.end(); it++)
150  {
151  vecti = (*it);
152  for(it1 = vecti.begin(); it1 < vecti.end(); it1++)
153  {
154  d[i] = (*it1);
155  i+= 1;
156  }
157  pt.setSRID((int)d[0]);
158  pt.setX(d[1]);
159  pt.setY(d[2]);
160  vectp.push_back(pt);
161  }
162 }
163 
164 void TsManagerDataSource::ConvertVectorToLinearRing(std::vector<std::vector<double> >& vectd, te::gm::LinearRing& lr)
165 {
166  std::vector<std::vector<double> >::iterator it;
167  std::vector<double>::iterator it1;
168  te::gm::Point pt;
169  double d[3]={0.0,0.0,0.0};int i=0; int p =0;
170  std::vector<double> vecti;
171  for(it = vectd.begin(); it < vectd.end(); it++)
172  {
173  vecti = (*it); i=0;
174  for(it1 = vecti.begin(); it1 < vecti.end(); it1++)
175  {
176  d[i] = (*it1);
177  i+= 1;
178  }
179  lr.setPoint(p,d[1],d[2]);
180  p+= 1;
181  }
182  lr.setSRID((int)d[0]);
183 }
184 
186 {
187  if (s == "te::dt::FIXED_STRING")
189  else if (s == "te::dt::VAR_STRING")
190  t = te::dt::VAR_STRING;
191  else if (s == "te::dt::STRING")
192  t = te::dt::STRING;
193  else if (s == "te::dt::STRING")
194  t = te::dt::STRING;
195 }
196 void TsManagerDataSource::ConvertToPropType(std::string s, int &t)
197 {
198  if (s == "te::dt::INT16_TYPE")
199  t = te::dt::INT16_TYPE;
200  else if (s == "te::gm::PolygonMType")
201  t = te::gm::PolygonMType; // te::gm::GeomType t
202 }
203 /* TODO:
204  switch(s)
205  {
206  case "te::dt::CHAR_TYPE":
207  t = te::dt::CHAR_TYPE;
208  break;
209  case "te::dt::UCHAR_TYPE":
210  t = te::dt::UCHAR_TYPE;
211  break;
212  case "te::dt::INT16_TYPE":
213  t = te::dt::INT16_TYPE;
214  break;
215  case "te::dt::INT32_TYPE":
216  t = te::dt::INT32_TYPE;
217  break;
218  case "te::dt::INT64_TYPE":
219  t = te::dt::INT64_TYPE;
220  break;
221  case "te::dt::NUMERIC_TYPE":
222  t = te::dt::NUMERIC_TYPE;
223  break;
224  case "te::dt::te::dt::DATE":
225  t = te::dt::DATE;
226  break;
227  case "te::dt::TIME_DURATION":
228  t = te::dt::TIME_DURATION;
229  break;
230  case "te::dt::TIME_INSTANT":
231  t = te::dt::TIME_INSTANT;
232  break;
233  case "te::dt::TIME_INSTANT_TZ":
234  t = te::dt::TIME_INSTANT_TZ;
235  break;
236  case "te::dt::FLOAT_TYPE":
237  t = te::dt::FLOAT_TYPE;
238  break;
239  case "te::dt::DOUBLE_TYPE":
240  t = te::dt::DOUBLE_TYPE;
241  break;
242  case "te::dt::FIXED_STRING":
243  t = te::dt::FIXED_STRING;
244  break;
245  case "te::dt::VAR_STRING":
246  t = te::dt::VAR_STRING;
247  break;
248  case "te::dt::STRING_TYPE":
249  t = te::dt::STRING_TYPE;
250  break;
251  case "te::dt::BOOLEAN_TYPE":
252  t = te::dt::BOOLEAN_TYPE;
253  break;
254  case "te::dt::BYTE_ARRAY_TYPE":
255  t = te::dt::BYTE_ARRAY_TYPE;
256  break;
257  case "te::dt::GEOMETRY_TYPE":
258  t = te::dt::GEOMETRY_TYPE;
259  break;
260  case "te::dt::ARRAY_TYPE":
261  t = te::dt::ARRAY_TYPE;
262  break;
263  default:
264  t = te::dt::STRING_TYPE;
265  break;
266  }
267 */
268 
269 void TsManagerDataSource::initialize(const std::string driver_name)
270 {
271 //*** Initializing datasource drivers - all available in drivers.json ***//
272 
273 // the static variables sm_* for each datasource will be read from a *.json file
274 
275  boost::property_tree::ptree driver;
276 
277  boost::property_tree::read_json(driver_name, driver);
278 
279  sm_dsType = driver.get_child("ds.ds_type").data();
280 
281  te::common::Convert(driver.get_child("ds.ds_connInfo"), sm_connInfo);
282  te::common::Convert(driver.get_child("ds.ds_connInfoExist"), sm_connInfoExist);
283  te::common::Convert(driver.get_child("ds.ds_connInfoNewDs"), sm_connInfoNewDs);
284  te::common::Convert(driver.get_child("ds.ds_connInfoDropDs"), sm_connInfoDropDs);
285  sm_connStr = driver.get_child("ds.ds_connStr").data();
286 
287  std::string sss = driver.get_value("ds.ds_connStr");
288 
289  // Reading dataSetType names that already exist in DataSource
290  te::common::Convert(driver.get_child("dt.dt_Names"), sm_vecDtNames);
291 
292  //Reading dataSetType names that will be created for some Persistence test
293  sm_newDataSetType = driver.get_child("dt_new").data();
294  sm_newCapabilitiesDt = driver.get_child("dt_newCapabilities").data();
295  sm_dtcloned = driver.get_child("dt_clonedName").data();
296  sm_newDataSetType2 = driver.get_child("dt_newDt").data();
297  sm_newDataSetType3 = driver.get_child("dt_newDtWithPk").data();
298 
299  sm_Attr1 = "43.78";
300  sm_newdt = new te::da::DataSetType(sm_newDataSetType);
302 
303  if (sm_dsType == "GDAL")
304  {
305  te::rst::Grid* grid = new te::rst::Grid(100,100);
306  grid->setGeoreference(te::gm::Coord2D(100,100), 29183, 1,1);
307  std::vector<te::rst::BandProperty*> bprops;
308  bprops.push_back(new te::rst::BandProperty(0, te::dt::UCHAR_TYPE));
309  std::map<std::string, std::string> rinfo1;
310 
311  te::rst::RasterProperty* rstp = new te::rst::RasterProperty(grid, bprops, rinfo1);
312  sm_newdt->add(rstp);
313 
314  te::rst::Grid* grid3 = new te::rst::Grid(100,100);
315  grid3->setGeoreference(te::gm::Coord2D(100,100), 29183, 1,1);
316  std::vector<te::rst::BandProperty*> bprops3;
317  bprops3.push_back(new te::rst::BandProperty(0, te::dt::UCHAR_TYPE));
318  std::map<std::string, std::string> rinfo3;
319  te::rst::RasterProperty* rstp3 = new te::rst::RasterProperty(grid3, bprops3, rinfo3);
320  sm_newdt3->add(rstp3);
321  }
322  else
323  { //to other drivers...
324 
325  //Reading-envelopes (rec) that will be used as FILTER when retrieving datasets(using intersects)
326  std::vector<std::vector<double> > vect_res;
327  te::common::Convert(driver.get_child("dt.dt_envelop"), vect_res);
329 
330  //teste marisa
331  std::vector<std::vector<double> > vect_res3;
332  std::vector<te::gm::Envelope> vecEnv3;
333  te::common::Convert(driver.get_child("dt.dt_envelop3.br_munic_2001"), vect_res3);
334  ConvertVectorToEnvelope(vect_res3,vecEnv3);
335  // testefim
336 
337  std::vector<std::vector<double> > vect_rec;
338  te::common::Convert(driver.get_child("dt.dt_rect"), vect_rec);
340 
341  //Used in CatalogLoader of each driver defined in drivers.json
342  te::common::Convert(driver.get_child("dt.dt_size_envelop"), sm_dtSize);
343  te::common::Convert(driver.get_child("dt.dt_size_rec"), sm_dtRecSize);
344 
345  te::common::Convert(driver.get_child("dt.dt_pk_names"), sm_vecPkNames);
346  te::common::Convert(driver.get_child("dt.dt_idx_names"), sm_vecIdxNames);
347  te::common::Convert(driver.get_child("dt.dt_seq_names"), sm_vecSeqNames);
348  te::common::Convert(driver.get_child("dt.dt_fk_names"), sm_vecFkNames);
349  te::common::Convert(driver.get_child("dt.dt_uk_names"), sm_vecUkNames);
350 
351  te::common::Convert(driver.get_child("dt.dt_cconstrains_names"), sm_vecCcNames);
352 
353  setPairsValues(); //Setting some pairs of values based on related vetors above
354  //Reading-envelopes (rec) - end
355 
356  //Reading-geometries used as spatial filter
357  //Now it is only defined for the first dataSetType defined in the "dt.dt_Names"
358  //but the tests could change to recevive a vector of pts,env, pol, geom
359 
360  //reading srid of the geometries used as filters
361  std::string srid_s = driver.get_child("geom.geom_srid").data();
362  int geom_srid = boost::lexical_cast<int>(srid_s);
363  //reading points
364  std::vector<std::vector<double> > vect_pts;
365  std::vector<te::gm::Point> vect_pts1;
366  te::common::Convert(driver.get_child("geom.geom_pts"), vect_pts);
367 
368  std::vector<std::vector<double> > vect_envboxs;
369  std::vector<te::gm::Envelope> vect_boxEnvel; //sm_box
370  std::vector<std::vector<double> > vect_lines;
371  std::vector<std::vector<double> > vect_pols;
372  //TODO:Mudar para vetor os sm_pt, sm_box, sm_pol, sm_linearRing nos programas de teste...
373 
374  //reading-box
375  te::common::Convert(driver.get_child("geom.geom_boxs"), vect_envboxs);
376  ConvertVectorToEnvelope(vect_envboxs,vect_boxEnvel); // TODO sm_box mudar para vector
377 
378  if (vect_boxEnvel.size() > 0)
379  {
380  std::vector<te::gm::Envelope>::iterator it = vect_boxEnvel.begin();
381  sm_box = (*it);
382  ConvertVectorToPoints(vect_pts,vect_pts1);
383  std::vector<te::gm::Point>::iterator it1 = vect_pts1.begin();
384  sm_pt = (*it1);
385  }
386  sm_pt.setSRID(geom_srid);
387 
388  // reading-polgygon (points that will compose the sm_pol geometry (polygon) used in getDataSet)
389  std::vector<std::vector<double> > vect_ptsx;
390  te::common::Convert(driver.get_child("geom.geom_linearRings"), vect_ptsx);
391  if (vect_ptsx.size() >0)
392  {
393  te::gm::LinearRing *sm_linearRing1= new te::gm::LinearRing(vect_ptsx.size(),te::gm::LineStringType);
394  ConvertVectorToLinearRing(vect_ptsx, *sm_linearRing1);
395 
396  size_t lr_size = sm_linearRing1->size();
397  std::size_t i;
398  std::vector<te::gm::Point> vect_pis;
399  te::gm::Point pi;
400 
401  for(i = 0; i < lr_size; i++)
402  {
403  pi.setX(sm_linearRing1->getPointN(i)->getX()) ;
404  pi.setY(sm_linearRing1->getPointN(i)->getY()) ;
405  vect_pis.push_back(pi);
406  }
407 
408  sm_pol->push_back(sm_linearRing1);
409  sm_pol->setSRID(geom_srid);
410  }
411  te::common::Convert(driver.get_child("geom.geom_pols"), vect_pols);
412 
413  //adding numeric properties (it could be read from .json in a vector of numeric properties)
414  sm_newdt->add(new te::dt::NumericProperty("attribute1_numeric", 10, 3, true, new std::string(sm_Attr1)));
415  sm_newdt3->add(new te::dt::NumericProperty("attribute1_numeric", 10, 3, true, new std::string(sm_Attr1)));
416 
417  //reading string properties and adding to dataSetTypes
418  std::vector<std::map<std::string, std::string> > vectProp;
419  te::common::Convert(driver.get_child("dt_new_attr.dt_att_str"), vectProp);
420 
421  std::vector<std::map<std::string, std::string> >::iterator itvectmap;
422  std::map<std::string, std::string> atti;
423  for(itvectmap = vectProp.begin(); itvectmap < vectProp.end(); itvectmap++)
424  {
425  atti = (*itvectmap);
426  std::string propname= atti["name"];
427  std::string proptypeM = atti["strtype"];
428  te::dt::StringType propType;
429  ConvertToPropType(proptypeM, propType);
430  std::string prop_size = atti["strsize"];
431  int propsizeI = boost::lexical_cast<int>(prop_size);
432  sm_newdt->add(new te::dt::StringProperty(propname, propType,propsizeI));
433  sm_newdt3->add(new te::dt::StringProperty(propname, propType,propsizeI));
434  }
435 
436  //reading some specific names used as pk,uk,Idx,check Constraints
437  sm_NameAttr6 = driver.get_child("dt_propPkName").data();
438  sm_Attr6Pk = driver.get_child("dt_PkName").data();
439 
440  sm_NameAttr3 = driver.get_child("dt_propUkName1").data();
441  sm_NameAttr4 = driver.get_child("dt_propUkName2").data();
442  sm_Attr3e4Uk = driver.get_child("dt_UkName").data();
443 
444  sm_NameAttr5 = driver.get_child("dt_propIdxGeom").data();
445  sm_Attr5idx = driver.get_child("dt_IdxGeomName").data();
446 
447  sm_NameAttr2 = driver.get_child("dt_propIdxName").data();
448  sm_Attr2idx = driver.get_child("dt_IdxName").data();
449 
450  sm_NameAttr1 = driver.get_child("dt_propCcName").data();
451  sm_ccName = driver.get_child("dt_CheckCcName").data();
452 
453  //sm_NameAttr6 = driver.get_child("dt_propFkName").data();
454  sm_Attr6Fk = driver.get_child("dt_FkName").data();
455  sm_NameAttr7 = driver.get_child("dt_propNameToChange").data();
456 
457  sm_NameAttr8 = driver.get_child("dt_propOldName").data();
458  sm_oldNameProp = driver.get_child("dt_propOldName").data();
459  sm_newNameProp = driver.get_child("dt_propNewName").data();
460 
461  //initializing something to be used in persistence tests
466 
467  //Defining checkConstraint over properties m_NameAttr1 (cc name will be recorded as lower case)
468  sm_cc = new te::da::CheckConstraint(sm_ccName); // era cc_datasettype2
469  std::string e = sm_NameAttr1 + ">0" ;
470  sm_cc->setExpression(e);
471 
472  //adding primaryKey
475  pk->add(prop);
476  sm_newdt3->add(pk);
477 
478  //adding uniqueKey
480  CPPUNIT_ASSERT(x);
482  CPPUNIT_ASSERT(y);
484  uk->add(x);
485  uk->add(y);
486  sm_newdt3->add(uk);
487 
488  //adding index using geometry property m_NameAttr5
490  CPPUNIT_ASSERT(g);
492  idx->add(g);
493  sm_newdt3->add(idx);
494 
495  //adding checkConstraint over properties m_NameAttr1
496  te::da::CheckConstraint* cc = new te::da::CheckConstraint(sm_ccName+"3"); //"cc_datasetType3"
497  std::string ee = sm_NameAttr1 + ">0" ;
498  cc->setExpression(ee);
499  sm_newdt3->add(cc);
500 
501  //Defining foreign key (based on sm_NameAttr6 from dtRef=sm_newdt) to be added in sm_newdt3 by tests
504  sm_fk->add(propfk);
505  //te::da::DataSetType* dtRef = cl->getDataSetType(m_newDataSetType,true);
508  }//postgis and other drivers
509 
510  // End of Specification of variables to be used in DataSetTypePersistence tests
511 
513 // sm_datasource = te::da::DataSourceFactory::make(sm_dsType);
514  //sm_datasource = te::da::DataSourceFactory::make(sm_dsType);
515  sm_datasource->setConnectionInfo(sm_connInfo);
516 
518 }
519 
521 {
522 // delete all static pointers created at TsManagerDataSource::initialize
523  //delete sm_datasource;
524  sm_dsType = "";
525  sm_connInfo.clear();
526  sm_connInfoExist.clear();
527  sm_connInfoNewDs.clear();
528  sm_connInfoDropDs.clear();
529 
530  sm_vecDtNames.clear();
531  sm_vecEnvelops.clear();
532  sm_recEnvelops.clear();
533  sm_dtSize.clear();
534  sm_dtRecSize.clear();
535  sm_recEnvelops.clear();
536 
537  sm_vecPkNames.clear();
538  sm_vecUkNames.clear();
539  sm_vecIdxNames.clear();
540  sm_vecFkNames.clear();
541  sm_vecSeqNames.clear();
542  sm_vecCcNames.clear();
543 
544  sm_vecDtNamesAndEnvelops.clear();
545  sm_vecNamesAndRecs.clear();
546  sm_vecNamesSizes.clear();
547  sm_vecNamesSizesRec.clear();
548 
549  sm_pol->clear();
550  delete sm_geom;
551 }
552 
554 {
555 // showing up DataSet names to be tested
556  std::vector<std::string>::iterator it;
557  for(it = sm_vecDtNames.begin(); it < sm_vecDtNames.end(); it++)
558  {
559  std::cout << "DataSets to be tested: " << *it << std::endl;
560  }
561 /*
562 //All of this are defined in posgtis.json or gdal.json, or other drive
563 
564 // vector of DataSets Envelops
565  te::gm::Envelope *envBrMunic2001 = new te::gm::Envelope(-73.994430541992202,-33.752063751220703,-28.835882186889599,5.2718071937561000);
566  te::gm::Envelope *envBatimetria = new te::gm::Envelope(622925.37500000000,9744215.0000000000,715161.12500000000,9780345.0000000000);
567  te::gm::Envelope *envBrFocos2003 = new te::gm::Envelope(-73.066673278808594,-33.566669464111300,-34.834999084472699,5.0933332443237296);
568 
569 // sm_vecEnvelops.push_back(*envBrMunic2001);
570  sm_vecEnvelops.push_back(*(new te::gm::Envelope(-73.994430541992202,-33.752063751220703,-28.835882186889599,5.2718071937561000)));
571  sm_vecEnvelops.push_back(*envBatimetria);
572  sm_vecEnvelops.push_back(*envBrFocos2003);
573 
574 
575 // vector of rectangles to be used spatial filter when retrieving datasets (using intersects or ...)
576  te::gm::Envelope *recBrMunic2001 = new te::gm::Envelope(-60.0,-20.0,-35.0,2.0);
577  te::gm::Envelope *recBatimetria = new te::gm::Envelope(680000.0,9750000.0,700000.0,9778000.0000000000);
578  te::gm::Envelope *recBrFocos2003 = new te::gm::Envelope(-60.0,-20.0,-35.0,2.0);
579 
580  sm_recEnvelops.push_back(*recBrMunic2001);
581  sm_recEnvelops.push_back(*recBatimetria);
582  sm_recEnvelops.push_back(*recBrFocos2003);
583 
584 // vector of DataSet Size (same order of sm_vecDtNames)
585  sm_dtSize.push_back (5562);
586  sm_dtSize.push_back (562932);
587  sm_dtSize.push_back (46109);
588 
589 // vector of DataSetRec Size (same order of sm_vecDtNames)
590  sm_dtRecSize.push_back (3048);
591  sm_dtRecSize.push_back (66991);
592  sm_dtRecSize.push_back (31878);
593 */
594  size_t ss = sm_vecEnvelops.size();
595 
596  std::vector<te::gm::Envelope>::iterator itEnv;
597  std::vector<size_t>::iterator itSize;
598 
599  unsigned int i = 0;
600  std::pair<std::string, te::gm::Envelope> dtNameEnvelPair;
601  std::pair<std::string, te::gm::Envelope> dtNameRecPair;
602  std::pair<std::string, size_t> dtNameSize;
603  std::pair<std::string, size_t> dtNameRecSize;
604 
605  i = 0;
606  it = sm_vecDtNames.begin();
607  itEnv = sm_vecEnvelops.begin();
608  while ( ( i < ss ) && ( it < sm_vecDtNames.end() ) && ( itEnv < sm_vecEnvelops.end() ) )
609  {
610  dtNameEnvelPair.first = *it;
611  dtNameEnvelPair.second = *itEnv;
612  sm_vecDtNamesAndEnvelops.push_back(dtNameEnvelPair);
613 
614  i++;
615  it++;
616  itEnv++;
617  }
618 
619  i = 0;
620  it = sm_vecDtNames.begin();
621  itEnv = sm_recEnvelops.begin();
622  while( ( i < ss ) && ( it < sm_vecDtNames.end() ) && ( itEnv < sm_recEnvelops.end() ) )
623  {
624  dtNameRecPair.first = *it;
625  dtNameRecPair.second = *itEnv;
626  sm_vecNamesAndRecs.push_back(dtNameRecPair);
627 
628  i++;
629  it++;
630  itEnv++;
631  }
632 
633  i = 0;
634  it = sm_vecDtNames.begin();
635  itSize = sm_dtSize.begin();
636  while( ( i < ss ) && ( it < sm_vecDtNames.end() ) && ( itSize < sm_dtSize.end() ) )
637  {
638  dtNameSize.first = *it;
639  dtNameSize.second = *itSize;
640  sm_vecNamesSizes.push_back(dtNameSize);
641 
642  i++;
643  it++;
644  itSize++;
645  }
646 
647  i = 0;
648  it = sm_vecDtNames.begin();
649  itSize = sm_dtRecSize.begin();
650  while( ( i < ss ) && ( it < sm_vecDtNames.end() ) && ( itSize < sm_dtRecSize.end() ) )
651  {
652  dtNameRecSize.first = *it;
653  dtNameRecSize.second = *itSize;
654  sm_vecNamesSizesRec.push_back(dtNameRecSize);
655 
656  i++;
657  it++;
658  itSize++;
659  }
660 
661 // showing up DataSet names and their envelops(bounding box)
662  std::vector<std::pair<std::string, te::gm::Envelope> >::iterator itpair;
663  for(itpair = sm_vecDtNamesAndEnvelops.begin(); itpair < sm_vecDtNamesAndEnvelops.end(); itpair++)
664  {
665  std::cout << (*itpair).first << std::endl;
666  std::cout << (*itpair).second.m_llx << "," << (*itpair).second.m_lly << "," << (*itpair).second.m_urx << "," << (*itpair).second.m_ury << std::endl;
667  }
668 
669 // showing up DataSet names and the rectangles to be used as a spatial filter when retrieving datasets
670  for(itpair = sm_vecNamesAndRecs.begin(); itpair < sm_vecNamesAndRecs.end(); itpair++)
671  {
672  std::cout << (*itpair).first << std::endl;
673  std::cout << (*itpair).second.m_llx << "," << (*itpair).second.m_lly << "," << (*itpair).second.m_urx << "," << (*itpair).second.m_ury << std::endl;
674  }
675 }
static te::gm::Polygon * sm_pol
This file contains include headers for the Data Type module of TerraLib.
Property * getProperty(std::size_t i) const
It returns the i-th property.
void add(te::dt::Property *p)
It adds the property to the list of properties that participates in the unique key.
Definition: UniqueKey.h:124
StringType
The subtype of string property.
static std::vector< std::pair< std::string, size_t > > sm_vecNamesSizes
void push_back(Curve *ring)
It adds the curve to the curve polygon.
static std::string sm_newDataSetType3
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
Geometric property.
static te::gm::Envelope sm_box
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
Definition: PrimaryKey.h:123
static te::da::DataSourceCapabilities sm_capabilit
static std::map< std::string, std::string > sm_connInfoNewDs
void setSRID(int srid) _NOEXCEPT_OP(true)
It sets the Spatial Reference System ID of the Point.
static std::string sm_Attr1
An atomic property like an integer or double.
static std::map< std::string, std::string > sm_connInfoExist
void setSRID(int srid)
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
static std::string sm_Attr2idx
A raster band description.
Definition: BandProperty.h:61
static std::string sm_newDataSetType
static std::string sm_Attr6Fk
A class that models the description of a dataset.
Definition: DataSetType.h:72
static std::string sm_NameAttr1
static std::string sm_connStr
static te::da::DataSetType * sm_newdt3
static te::da::DataSource * sm_datasource
static std::string sm_Attr3e4Uk
static std::vector< size_t > sm_dtSize
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
static std::string sm_oldNameProp
static std::string sm_NameAttr7
static std::map< std::string, std::string > sm_connInfoDropDs
void add(te::dt::Property *p)
It adds the property to the list of properties of the index.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
void setGeoreference(const te::gm::Coord2D &ulLocation, int srid, double resX, double resY)
Sets the information needed to georeference the grid.
A class that describes a check constraint.
static te::da::ForeignKey * sm_fk
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
static std::string sm_NameAttr2
static std::string sm_newDataSetType2
static void setPairsValues()
It will set vectors of pairs of values based in some vector already known.
It models a property definition.
Definition: Property.h:59
Raster property.
TECOMMONEXPORT void Convert(const boost::property_tree::ptree &p, std::map< std::string, std::string > &dict)
Converts a property tree node into a std::map<std::string, std::string>.
Definition: BoostUtils.cpp:36
static std::string sm_NameAttr6
static std::string sm_Attr5idx
The type for arbitrary precison numbers, like numeric(p, q).
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
virtual const DataSourceCapabilities & getCapabilities() const =0
It returns the known capabilities of the data source.
static std::vector< std::pair< std::string, size_t > > sm_vecNamesSizesRec
static te::da::CheckConstraint * sm_cc
A point with x and y coordinate values.
Definition: Point.h:50
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
static void initialize(const std::string driver_name)
It will initialize the resources used by Test Suit: TsDataSource, TsDataSet, TsDataSetTypePersistence...
An Envelope defines a 2D rectangular region.
void add(te::dt::Property *p)
It adds a property to the foreign key constraint.
Definition: ForeignKey.h:112
static size_t sm_nroDataSets
static void ConvertVectorToEnvelope(std::vector< std::vector< double > > &vectd, std::vector< te::gm::Envelope > &vecte)
Converts a vector of vector of doubles - representing the envelopes of layers into a vector of te::gm...
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
static std::vector< size_t > sm_dtRecSize
static te::gm::Point sm_pt
static std::vector< std::string > sm_vecDtNames
static void ConvertVectorToPoints(std::vector< std::vector< double > > &vectd, std::vector< te::gm::Point > &vectp)
Converts a vector of vector of 3 doubles - representing points (SRID,X,Y) into a vector of te::gm::En...
static void finalize()
It will finalize the resources used in Teste Suit: TsDataSource, TsDataSet, TsDataSetTypePersistence...
A factory for data sources.
static std::string sm_NameAttr3
static te::gm::Geometry * sm_geom
te::gm::Polygon * p
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
The type for string types: FIXED_STRING, VAR_STRING or STRING.
void addRefProperty(te::dt::Property *p)
It adds a reference property (on the referenced DataSetType) of this foreign key constraint.
Definition: ForeignKey.h:137
static std::vector< std::string > sm_vecIdxNames
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
A static class for managing the resources used by DataSource test suit.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
static std::vector< std::string > sm_vecSeqNames
static std::map< std::string, std::string > sm_connInfo
static std::vector< te::gm::Envelope > sm_recEnvelops
void add(Constraint *c)
It adds a new constraint.
static std::vector< std::pair< std::string, te::gm::Envelope > > sm_vecNamesAndRecs
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
void setX(const double &x)
It sets the Point x-coordinate value.
Definition: Point.h:145
static std::vector< std::pair< std::string, te::gm::Envelope > > sm_vecDtNamesAndEnvelops
static std::string sm_Attr6Pk
static std::string sm_Attr7_seq
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
static std::vector< te::gm::Envelope > sm_vecEnvelops
void setExpression(const std::string &e)
It sets the check constraint expression.
static std::string sm_NameAttr5
static std::string sm_NameAttr8
void clear()
It deletes all the rings of the CurvePolygon and clear it.
void setSRID(int srid)
It sets the Spatial Reference System ID of the linestring.
static te::da::DataSetType * sm_newdt
This file contains include headers for the TerraLib Common Runtime module.
static std::string sm_newCapabilitiesDt
void setReferencedDataSetType(DataSetType *refDt)
It sets the referenced DataSetType of this foreign key constraint.
Definition: ForeignKey.h:160
static std::string sm_newNameProp
static std::string sm_ccName
static std::vector< std::string > sm_vecPkNames
void setY(const double &y)
It sets the Point y-coordinate value.
Definition: Point.h:159
static std::string sm_dtcloned
This file contains include headers for the Vector Geometry model of TerraLib.
A rectified grid is the spatial support for raster data.
Definition: raster/Grid.h:68
This file contains include headers for the Data Access module of TerraLib.
static std::vector< std::string > sm_vecCcNames
static std::vector< std::string > sm_vecFkNames
static void ConvertToPropType(std::string s, te::dt::StringType &t)
Converts a string into a string (Enum) property type.
It describes an index associated to a DataSetType.
static void ConvertVectorToLinearRing(std::vector< std::vector< double > > &vectd, te::gm::LinearRing &lr)
Converts a vector of vector of 3 doubles - representing points (SRID,X,Y) into a vector of te::gm::Li...
static std::string sm_dsType
std::size_t size() const
It returns the number of points (vertexes) in the geometry.
Definition: LineString.h:262
static std::string sm_NameAttr4
static std::vector< std::string > sm_vecUkNames