All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.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 terralib/ado/Utils.cpp
22 
23  \brief Utility functions for ADO.
24 */
25 
26 // TerraLib
27 #include "../common/Exception.h"
28 #include "../common/Translator.h"
29 #include "../datatype.h"
30 #include "../dataaccess/dataset/DataSetType.h"
31 #include "../dataaccess/dataset/ForeignKey.h"
32 #include "../dataaccess/dataset/CheckConstraint.h"
33 #include "../dataaccess/dataset/Constraint.h"
34 #include "../dataaccess/dataset/PrimaryKey.h"
35 #include "../dataaccess/dataset/UniqueKey.h"
36 #include "../dataaccess/utils/Utils.h"
37 #include "../geometry/GeometryProperty.h"
38 #include "../geometry/Envelope.h"
39 #include "../geometry/Enums.h"
40 #include "../memory/DataSet.h"
41 #include "../memory/DataSetItem.h"
42 #include "DataSet.h"
43 #include "Config.h"
44 #include "Utils.h"
45 #include "Globals.h"
46 
47 // Boost
48 #include <boost/format.hpp>
49 #include <boost/lexical_cast.hpp>
50 
51 inline void TESTHR( HRESULT hr )
52 {
53  if( FAILED(hr) ) _com_issue_error( hr );
54 }
55 
56 void te::ado::Blob2Variant(const char* blob, int size, _variant_t & var)
57 {
58  try
59  {
60  char *pByte;
61 
62  SAFEARRAY FAR* psa;
63  SAFEARRAYBOUND rgsabound[1];
64  rgsabound[0].lLbound = 0;
65  rgsabound[0].cElements = size;
66 
67  psa = SafeArrayCreate(VT_I1, 1, rgsabound);
68 
69  if(SafeArrayAccessData(psa,(void **)&pByte) == NOERROR)
70  memcpy(pByte, blob, size);
71  SafeArrayUnaccessData(psa);
72 
73  var.vt = VT_ARRAY | VT_UI1;
74  var.parray = psa;
75  }
76  catch(_com_error& e)
77  {
78  throw te::common::Exception((LPCSTR)e.ErrorMessage());
79  }
80 }
81 
82 std::string te::ado::MakeConnectionStr(const std::map<std::string, std::string>& dsInfo)
83 {
84  std::map<std::string, std::string>::const_iterator it = dsInfo.find("PROVIDER");
85  std::map<std::string, std::string>::const_iterator it_end = dsInfo.end();
86  std::string connInfo;
87 
88  if(it != it_end)
89  connInfo += "Provider=" + it->second;
90 
91  it = dsInfo.find("DB_NAME");
92 
93  if(it != it_end)
94  connInfo += ";Data Source=" + it->second;
95 
96  it = dsInfo.find("USER_NAME");
97 
98  if(it != it_end)
99  connInfo += ";User Id=" + it->second;
100 
101  it = dsInfo.find("PASSWORD");
102 
103  if(it != it_end)
104  connInfo += ";Jet OLEDB:Database Password=" + it->second + ";";
105 
106  return connInfo;
107 }
108 
109 void te::ado::Variant2Blob(const _variant_t var, int size, char* & blob)
110 {
111  try
112  {
113  char *cdata = 0;
114  if(var.vt == (VT_ARRAY | VT_UI1))
115  {
116  SafeArrayAccessData(var.parray,(void **)&cdata);
117  blob = new char[size];
118  memcpy(blob, cdata, size);
119  SafeArrayUnaccessData(var.parray);
120  }
121  }
122  catch(_com_error& e)
123  {
124  throw te::common::Exception((LPCSTR)e.ErrorMessage());
125  }
126 }
127 
128 ADOX::DataTypeEnum te::ado::Convert2Ado(int terralib)
129 {
130  switch(terralib)
131  {
132  case te::dt::CHAR_TYPE:
133  case te::dt::UCHAR_TYPE:
134  return ADOX::adWChar;
135  break;
136 
137  case te::dt::INT16_TYPE:
138  return ADOX::adInteger;
139  break;
140 
141  case te::dt::INT32_TYPE:
142  return ADOX::adInteger;
143  break;
144 
145  case te::dt::INT64_TYPE:
146  return ADOX::adInteger;
147  break;
148 
150  return ADOX::adDate;
151 
152  case te::dt::FLOAT_TYPE:
153  case te::dt::DOUBLE_TYPE:
155  return ADOX::adDouble;
156  break;
157 
158  case te::dt::STRING_TYPE:
159  return ADOX::adLongVarWChar;
160  break;
161 
163  return ADOX::adBoolean;
164  break;
165 
167  return ADOX::adLongVarBinary;
168  break;
169 
171  case te::dt::ARRAY_TYPE:
172  return ADOX::adLongVarBinary;
173  break;
174 
175  default:
176  throw te::common::Exception(TE_TR("The informed type could not be mapped to ADO type system!"));
177  break;
178  }
179 }
180 
181 std::string te::ado::GetAdoStringType(const int& terralib)
182 {
183  ADOX::DataTypeEnum aType = te::ado::Convert2Ado(terralib);
184 
185  switch(aType)
186  {
187  case ADOX::adInteger:
188  return "Integer";
189  break;
190 
191  case ADOX::adDate:
192  return "Date/Time";
193  break;
194 
195  case ADOX::adDouble:
196  return "Double";
197  break;
198 
199  case ADOX::adBoolean:
200  return "Yes/No";
201  break;
202 
203  case ADOX::adLongVarBinary:
204  return "Memo";
205  break;
206 
207  case ADOX::adLongVarWChar:
208  return "Text";
209  break;
210  }
211 
212  return "";
213 }
214 
215 void te::ado::Convert2Ado(const te::gm::Geometry* geo, _variant_t & var)
216 {
217  long size = geo->getWkbSize();
218 
219  char* wkb = new char[size];
220 
221  geo->getWkb(wkb, te::common::NDR);
222 
223  unsigned int newWkbSize = size+4;
224 
225  char* newWkb = new char[newWkbSize];
226 
227  memcpy(newWkb, wkb, size);
228 
229  unsigned int srid = geo->getSRID();
230 
231  memcpy(newWkb+size, &srid, 4);
232 
233  te::ado::Blob2Variant(newWkb, newWkbSize, var);
234 }
235 
236 int te::ado::Convert2Terralib(ADOX::DataTypeEnum adoType)
237 {
238  switch(adoType)
239  {
240  case ADOX::adBoolean:
241  return te::dt::BOOLEAN_TYPE;
242  break;
243 
244  case ADOX::adEmpty:
245  return te::dt::VOID_TYPE;
246  break;
247 
248  case ADOX::adBinary:
249  case ADOX::adVarBinary:
250  case ADOX::adLongVarBinary:
252  break;
253 
254  case ADOX::adVarWChar:
255  case ADOX::adWChar:
256  case ADOX::adVarChar:
257  case ADOX::adLongVarChar:
258  case ADOX::adLongVarWChar:
259  case ADOX::adBSTR:
260  case ADOX::adChar:
261  return te::dt::STRING_TYPE;
262  break;
263 
264  case ADOX::adBigInt:
265  return te::dt::INT16_TYPE;
266  break;
267 
268  case ADOX::adSingle:
269  return te::dt::FLOAT_TYPE;
270  break;
271 
272  case ADOX::adDouble:
273  case ADOX::adDecimal:
274  return te::dt::DOUBLE_TYPE;
275  break;
276 
277  case ADOX::adInteger:
278  return te::dt::INT32_TYPE;
279  break;
280 
281  case ADOX::adTinyInt:
282  case ADOX::adSmallInt:
283  return te::dt::INT16_TYPE;
284  break;
285 
286  case ADOX::adUnsignedBigInt:
287  return te::dt::UINT64_TYPE;
288  break;
289 
290  case ADOX::adUnsignedInt:
291  return te::dt::UINT32_TYPE;
292  break;
293 
294  case ADOX::adUnsignedSmallInt:
295  case ADOX::adUnsignedTinyInt:
296  return te::dt::UINT16_TYPE;
297  break;
298 
299  case ADOX::adDate:
300  case ADOX::adDBDate:
301  case ADOX::adDBTime:
302  case ADOX::adDBTimeStamp:
303  return te::dt::DATETIME_TYPE;
304  break;
305 
306  //case ADOX::adGUID:
307  //case ADOX::adError:
308  //case ADOX::adSingle:
309  //case ADOX::adDecimal:
310  //case ADOX::adNumeric:
311  //case ADOX::adChapter:
312  //case ADOX::adVarNumeric:
313  //case ADOX::adCurrency:
314  //case ADOX::adFileTime:
315  //case ADOX::adPropVariant:
316  //case ADOX::adUserDefined:
317 
318  default:
319  return te::dt::UNKNOWN_TYPE;
320  break;
321  }
322 }
323 
324 int te::ado::Convert2Terralib(::DataTypeEnum adoType)
325 {
326  switch(adoType)
327  {
328  case ::adBoolean:
329  return te::dt::BOOLEAN_TYPE;
330  break;
331 
332  case ::adEmpty:
333  return te::dt::VOID_TYPE;
334  break;
335 
336  case ::adBinary:
337  case ::adVarBinary:
338  case ::adLongVarBinary:
340  break;
341 
342  case ::adVarWChar:
343  case ::adWChar:
344  case ::adVarChar:
345  case ::adLongVarChar:
346  case ::adLongVarWChar:
347  case ::adBSTR:
348  case ::adChar:
349  return te::dt::STRING_TYPE;
350  break;
351 
352  case ::adBigInt:
353  return te::dt::INT16_TYPE;
354  break;
355 
356  case ::adSingle:
357  return te::dt::FLOAT_TYPE;
358  break;
359 
360  case ::adDouble:
361  case ::adDecimal:
362  return te::dt::DOUBLE_TYPE;
363  break;
364 
365  case ::adInteger:
366  return te::dt::INT32_TYPE;
367  break;
368 
369  case ::adTinyInt:
370  case ::adSmallInt:
371  return te::dt::INT16_TYPE;
372  break;
373 
374  case ::adUnsignedBigInt:
375  return te::dt::UINT64_TYPE;
376  break;
377 
378  case ::adUnsignedInt:
379  return te::dt::UINT32_TYPE;
380  break;
381 
382  case ::adUnsignedSmallInt:
383  case ::adUnsignedTinyInt:
384  return te::dt::UINT16_TYPE;
385  break;
386 
387  case ::adDate:
388  case ::adDBDate:
389  case ::adDBTime:
390  case ::adDBTimeStamp:
391  return te::dt::DATETIME_TYPE;
392  break;
393 
394  //case ::adGUID:
395  //case ::adError:
396  //case ::adSingle:
397  //case ::adDecimal:
398  //case ::adNumeric:
399  //case ::adChapter:
400  //case ::adVarNumeric:
401  //case ::adCurrency:
402  //case ::adFileTime:
403  //case ::adPropVariant:
404  //case ::adUserDefined:
405 
406  default:
407  return te::dt::UNKNOWN_TYPE;
408  break;
409  }
410 }
411 
413 {
414  te::dt::Property* prop = 0;
415 
416  _bstr_t cName = column->GetName();
417 
418  ADOX::DataTypeEnum cType = column->GetType();
419 
420  long cSize = column->GetDefinedSize();
421 
422  switch(cType)
423  {
424  case ::adBoolean:
425  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
426  break;
427 
428  case ::adVarWChar:
429  case ::adWChar:
430  case ::adVarChar:
431  case ::adLongVarChar:
432  case ::adLongVarWChar:
433  case ::adBSTR:
434  case ::adChar:
435  prop = new te::dt::StringProperty(std::string(cName), (te::dt::StringType)Convert2Terralib(cType), cSize);
436  break;
437 
438  case ADOX::adTinyInt:
439  case ADOX::adSmallInt:
440  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
441  break;
442 
443  case ADOX::adInteger:
444  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
445  break;
446 
447  case ADOX::adBigInt:
448  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
449  break;
450 
451  case ADOX::adDouble:
452  case ADOX::adDecimal:
453  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
454  break;
455 
456  case ::adUnsignedBigInt:
457  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
458  break;
459 
460  case ::adUnsignedInt:
461  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
462  break;
463 
464  case ::adUnsignedSmallInt:
465  case ::adUnsignedTinyInt:
466  prop = new te::dt::SimpleProperty(std::string(cName),Convert2Terralib(cType));
467  break;
468 
469  case ADOX::adLongVarBinary:
470  prop = new te::dt::ArrayProperty(std::string(cName), new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType)));
471  break;
472 
473  case ADOX::adDate:
474  case ADOX::adDBDate:
475  prop = new te::dt::DateTimeProperty(std::string(cName), te::dt::DATE);
476  break;
477 
478  case ADOX::adDBTime:
479  prop = new te::dt::DateTimeProperty(std::string(cName), te::dt::TIME_DURATION);
480  break;
481 
482  case ADOX::adDBTimeStamp:
483  prop = new te::dt::DateTimeProperty(std::string(cName), te::dt::TIME_INSTANT);
484  break;
485 
486  default:
487  throw te::common::Exception(TE_TR("The informed column could not be mapped to TerraLib Data Set Type!"));
488  }
489 
490  return prop;
491 }
492 
493 std::vector<te::dt::Property*> te::ado::Convert2Terralib(ADOX::ColumnsPtr columns)
494 {
495  std::vector<te::dt::Property*> properties;
496 
497  for(long i = 0; i < columns->GetCount(); i++)
498  properties.push_back(Convert2Terralib(columns->GetItem(i)));
499 
500  return properties;
501 }
502 
504 {
505 
506  if(key->GetType() == ADOX::adKeyPrimary)
507  {
508  te::da::PrimaryKey* con = new te::da::PrimaryKey(std::string(key->GetName()));
509  con->setProperties(Convert2Terralib(key->GetColumns()));
510 
511  return con;
512  }
513  else if(key->GetType() == ADOX::adKeyForeign)
514  {
515  te::da::ForeignKey* con = new te::da::ForeignKey(std::string(key->GetName()));
516  con->setProperties(Convert2Terralib(key->GetColumns()));
517 
518  return con;
519  }
520  else if(key->GetType() == ADOX::adKeyUnique)
521  {
522  te::da::UniqueKey* con = new te::da::UniqueKey(std::string(key->GetName()));
523  con->setProperties(Convert2Terralib(key->GetColumns()));
524 
525  return con;
526  }
527  else
528  throw te::common::Exception(TE_TR("Unknown type!"));
529 
530 }
531 
533 {
534  switch(t)
535  {
537  return Globals::sm_geometryTypeName;
538  break;
539 
540  case te::gm::PointType:
541  return Globals::sm_pointTypeName;
542  break;
543 
545  return Globals::sm_lineStringTypeName;
546  break;
547 
548  case te::gm::PolygonType:
549  return Globals::sm_polygonTypeName;
550  break;
551 
553  return Globals::sm_multiPointTypeName;
554  break;
555 
557  return Globals::sm_multiLineStringTypeName;
558  break;
559 
561  return Globals::sm_multiPolygonTypeName;
562  break;
563 
565  return Globals::sm_curvePolygonTypeName;
566  break;
567 
569  return Globals::sm_polyhedralSurfaceTypeName;
570  break;
571 
573  return Globals::sm_geometryZTypeName;
574  break;
575 
576  case te::gm::PointZType:
577  return Globals::sm_pointZTypeName;
578  break;
579 
581  return Globals::sm_lineStringZTypeName;
582  break;
583 
585  return Globals::sm_polygonZTypeName;
586  break;
587 
589  return Globals::sm_multiPointZTypeName;
590  break;
591 
593  return Globals::sm_multiLineStringZTypeName;
594  break;
595 
597  return Globals::sm_multiPolygonZTypeName;
598  break;
599 
601  return Globals::sm_curvePolygonZTypeName;
602  break;
603 
605  return Globals::sm_polyhedralSurfaceZTypeName;
606  break;
607 
609  return Globals::sm_geometryMTypeName;
610  break;
611 
612  case te::gm::PointMType:
613  return Globals::sm_pointMTypeName;
614  break;
615 
617  return Globals::sm_lineStringMTypeName;
618  break;
619 
621  return Globals::sm_polygonMTypeName;
622  break;
623 
625  return Globals::sm_multiPointMTypeName;
626  break;
627 
629  return Globals::sm_multiLineStringMTypeName;
630  break;
631 
633  return Globals::sm_multiPolygonMTypeName;
634  break;
635 
637  return Globals::sm_curvePolygonMTypeName;
638  break;
639 
641  return Globals::sm_polyhedralSurfaceMTypeName;
642  break;
643 
645  return Globals::sm_geometryZMTypeName;
646  break;
647 
648  case te::gm::PointZMType:
649  return Globals::sm_pointZMTypeName;
650  break;
651 
653  return Globals::sm_lineStringZMTypeName;
654  break;
655 
657  return Globals::sm_polygonZMTypeName;
658  break;
659 
661  return Globals::sm_multiPointZMTypeName;
662  break;
663 
665  return Globals::sm_multiLineStringZMTypeName;
666  break;
667 
669  return Globals::sm_multiPolygonZMTypeName;
670  break;
671 
673  return Globals::sm_curvePolygonZMTypeName;
674  break;
675 
677  return Globals::sm_polyhedralSurfaceZMTypeName;
678  break;
679 
680  default:
681  return Globals::sm_geometryTypeName;
682  }
683 }
684 
686 {
687 
688  if(t == Globals::sm_geometryTypeName)
689  return te::gm::GeometryType;
690 
691  else if(t == Globals::sm_pointTypeName)
692  return te::gm::PointType;
693 
694 
695  else if(t == Globals::sm_lineStringTypeName)
696  return te::gm::LineStringType;
697 
698 
699  else if(t == Globals::sm_polygonTypeName)
700  return te::gm::PolygonType;
701 
702 
703  else if(t == Globals::sm_multiPointTypeName)
704  return te::gm::MultiPointType;
705 
706 
707  else if(t == Globals::sm_multiLineStringTypeName)
709 
710 
711  else if(t == Globals::sm_multiPolygonTypeName)
713 
714 
715  else if(t == Globals::sm_curvePolygonTypeName)
717 
718 
719  else if(t == Globals::sm_polyhedralSurfaceTypeName)
721 
722 
723  else if(t == Globals::sm_geometryZTypeName)
724  return te::gm::GeometryZType;
725 
726 
727  else if(t == Globals::sm_pointZTypeName)
728  return te::gm::PointZType;
729 
730 
731  else if(t == Globals::sm_lineStringZTypeName)
733 
734 
735  else if(t == Globals::sm_polygonZTypeName)
736  return te::gm::PolygonZType;
737 
738 
739  else if(t == Globals::sm_multiPointZTypeName)
741 
742 
743  else if(t == Globals::sm_multiLineStringZTypeName)
745 
746 
747  else if(t == Globals::sm_multiPolygonZTypeName)
749 
750 
751  else if(t == Globals::sm_curvePolygonZTypeName)
752 
754 
755  else if(t == Globals::sm_polyhedralSurfaceZTypeName)
757 
758 
759  else if(t == Globals::sm_geometryMTypeName)
760  return te::gm::GeometryMType;
761 
762 
763  else if(t == Globals::sm_pointMTypeName)
764  return te::gm::PointMType;
765 
766 
767  else if(t == Globals::sm_lineStringMTypeName)
769 
770 
771  else if(t == Globals::sm_polygonMTypeName)
772  return te::gm::PolygonMType;
773 
774 
775  else if(t == Globals::sm_multiPointMTypeName)
777 
778 
779  else if(t == Globals::sm_multiLineStringMTypeName)
781 
782 
783  else if(t == Globals::sm_multiPolygonMTypeName)
785 
786 
787  else if(t == Globals::sm_curvePolygonMTypeName)
789 
790 
791  else if(t == Globals::sm_polyhedralSurfaceMTypeName)
793 
794 
795  else if(t == Globals::sm_geometryZMTypeName)
796  return te::gm::GeometryZMType;
797 
798 
799  else if(t == Globals::sm_pointZMTypeName)
800  return te::gm::PointZMType;
801 
802 
803  else if(t == Globals::sm_lineStringZMTypeName)
805 
806 
807  else if(t == Globals::sm_polygonZMTypeName)
808  return te::gm::PolygonZMType;
809 
810 
811  else if(t == Globals::sm_multiPointZMTypeName)
813 
814 
815  else if(t == Globals::sm_multiLineStringZMTypeName)
817 
818 
819  else if(t == Globals::sm_multiPolygonZMTypeName)
821 
822 
823  else if(t == Globals::sm_curvePolygonZMTypeName)
825 
826 
827  else if(t == Globals::sm_polyhedralSurfaceZMTypeName)
829 
830  else
832 
833 }
834 
835 int te::ado::GetSRID(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
836 {
837  _RecordsetPtr recset;
838  TESTHR(recset.CreateInstance(__uuidof(Recordset)));
839 
840  std::string sel = "SELECT * FROM geometry_columns where f_table_name = '";
841  sel += tableName + "' and f_geometry_column = '" + geomPropName + "'";
842 
843  _variant_t variantSel;
844  variantSel.SetString(sel.c_str());
845 
846  try
847  {
848  TESTHR(recset->Open(variantSel, _variant_t((IDispatch *)adoConn),
849  adOpenStatic, adLockReadOnly, adCmdText));
850  }
851  catch(_com_error& e)
852  {
853  throw te::common::Exception((LPCSTR)e.ErrorMessage());
854  }
855 
856  return (int32_t)recset->GetFields()->GetItem("srid")->GetValue();
857 }
858 
859 te::gm::GeomType te::ado::GetType(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
860 {
861  _RecordsetPtr recset;
862  TESTHR(recset.CreateInstance(__uuidof(Recordset)));
863 
864  std::string sel = "SELECT * FROM geometry_columns where f_table_name = '";
865  sel += tableName + "' and f_geometry_column = '" + geomPropName + "'";
866 
867  _variant_t variantSel;
868  variantSel.SetString(sel.c_str());
869 
870  try
871  {
872  TESTHR(recset->Open(variantSel, _variant_t((IDispatch *)adoConn),
873  adOpenStatic, adLockReadOnly, adCmdText));
874  }
875  catch(_com_error& e)
876  {
877  throw te::common::Exception((LPCSTR)e.ErrorMessage());
878  }
879 
880  std::string type = (LPCSTR)(_bstr_t)recset->GetFields()->GetItem("type")->GetValue();
881 
882  return GetGeometryType(type);
883 }
884 
885 bool te::ado::IsGeomProperty(_ConnectionPtr adoConn, std::string tableName, std::string columnName)
886 {
887  ADOX::_CatalogPtr pCatalog;
888 
889  TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
890 
891  try
892  {
893  pCatalog->PutActiveConnection(variant_t((IDispatch *)adoConn));
894 
895  for(long i = 0; i < pCatalog->GetTables()->Count; i++)
896  {
897  if(std::string(pCatalog->GetTables()->GetItem(i)->GetName()) == "geometry_columns")
898  {
899  _RecordsetPtr recset;
900  TESTHR(recset.CreateInstance(__uuidof(Recordset)));
901 
902  TESTHR(recset->Open(_bstr_t("geometry_columns"),
903  _variant_t((IDispatch*)adoConn,true), adOpenKeyset, adLockOptimistic, adCmdTable));
904 
905  while(!recset->EndOfFile)
906  {
907  if(std::string((_bstr_t)recset->Fields->GetItem("f_table_name")->Value) == tableName
908  && std::string((_bstr_t)recset->Fields->GetItem("f_geometry_column")->Value) == columnName)
909  return true;
910 
911  recset->MoveNext();
912  }
913  }
914  }
915  }
916  catch(_com_error& e)
917  {
918  throw te::common::Exception((LPCSTR)e.ErrorMessage());
919  }
920 
921  return false;
922 }
923 
925 {
926  if( (type >= 1000 && type < 2000) || (type >= 3000 && type < 4000) )
927  return true;
928  return false;
929 }
930 
931 std::string te::ado::GetSystemDateTimeFormat(std::string& indAM, std::string& indPM, std::string& sepD, std::string& sepT)
932 {
933  std::string key = "Control Panel\\International";
934  std::string dateFormat = "sShortDate"; //formato da data d/M/yyyy
935  std::string timeFormat = "sTimeFormat"; //formato da hora HH:mm:ss
936  std::string hourFormat = "iTime"; //12 horas (0) ou 24 horas(1)
937  std::string indicatorAM = "s1159"; //AM
938  std::string indicatorPM = "s2359"; //PM
939  std::string dateSeparator = "sDate"; //separador de data
940  std::string timeSeparator = "sTime"; //separador de hora
941 
942  std::string rdateFormat;
943  std::string rtimeFormat;
944  std::string rhourFormat;
945  std::string rdateSeparator;
946  std::string rtimeSeparator;
947 
948  HKEY hk;
949  DWORD DataSize = 1024;
950  DWORD Type = REG_SZ;
951  char buf[1024];
952 
953  if (RegOpenKeyExA(HKEY_CURRENT_USER, key.c_str(), 0, KEY_READ, &hk) == ERROR_SUCCESS)
954  {
955  memset (buf, 0, 1024);
956  DataSize = 1024;
957  //date format
958  if (RegQueryValueExA(hk, dateFormat.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
959  rdateFormat = buf;
960 
961  memset (buf, 0, 1024);
962  DataSize = 1024;
963  //date separator
964  if (RegQueryValueExA(hk, dateSeparator.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
965  rdateSeparator = buf;
966 
967  memset (buf, 0, 1024);
968  DataSize = 1024;
969  //time format
970  if (RegQueryValueExA(hk, timeFormat.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
971  rtimeFormat = buf;
972 
973  memset (buf, 0, 1024);
974  DataSize = 1024;
975  //hour format
976  if (RegQueryValueExA(hk, hourFormat.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
977  rhourFormat = buf;
978 
979  memset (buf, 0, 1024);
980  DataSize = 1024;
981  //indicator AM
982  if (RegQueryValueExA(hk, indicatorAM.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
983  indAM = buf;
984 
985  memset (buf, 0, 1024);
986  DataSize = 1024;
987  //indicator PM
988  if (RegQueryValueExA(hk, indicatorPM.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
989  indPM = buf;
990 
991  memset (buf, 0, 1024);
992  DataSize = 1024;
993  //time separator
994  if (RegQueryValueExA(hk, timeSeparator.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
995  rtimeSeparator = buf;
996  }
997  else
998  return "";
999 
1000  sepD = rdateSeparator;
1001  sepT = rtimeSeparator;
1002 
1003  //DATE
1004  //first
1005  int pos = rdateFormat.find(rdateSeparator);
1006  std::string firstD = rdateFormat.substr(0,pos);
1007  std::string temp = rdateFormat.substr(pos+1);
1008  //second and third
1009  pos = temp.find(rdateSeparator);
1010  std::string secondD = temp.substr(0,pos);
1011  std::string thirdD = temp.substr(pos+1);
1012 
1013  //passar para o formato
1014  if(firstD.find("a")==0)
1015  replace(firstD.begin(), firstD.end(), 97, 89);
1016  else if(secondD.find("a")==0)
1017  replace(secondD.begin(), secondD.end(),97, 89);
1018  else if(thirdD.find("a")==0)
1019  replace(thirdD.begin(), thirdD.end(), 97, 89);
1020 
1021  //TIME
1022  //first
1023  pos = rtimeFormat.find(rtimeSeparator);
1024  std::string firstT = rtimeFormat.substr(0,pos);
1025  temp = rtimeFormat.substr(pos+1);
1026  //second and third
1027  pos = temp.find(rtimeSeparator);
1028  std::string secondT = temp.substr(0,pos);
1029  int posEmpth = temp.find(" ");
1030  std::string thirdT;
1031 
1032  if(posEmpth==-1)
1033  thirdT = temp.substr(pos+1);
1034  else
1035  thirdT = temp.substr(pos+1, (posEmpth-(pos+1)));
1036 
1037  int hFormat = atoi(rhourFormat.c_str());
1038 
1039  //passar para o formato
1040 
1041  firstT = te::common::Convert2UCase(firstT);
1042  secondT = te::common::Convert2UCase(secondT);
1043  thirdT = te::common::Convert2UCase(thirdT);
1044 
1045  if((firstT.find("M")==0))
1046  replace(firstT.begin(), firstT.end(), 77, 109);
1047  else if(secondT.find("M")==0)
1048  replace(secondT.begin(), secondT.end(), 77, 109);
1049  else if(thirdT.find("M")==0)
1050  replace(thirdT.begin(), thirdT.end(), 77, 109);
1051 
1052  std::string timef;
1053  if(hFormat==0)
1054  timef = "sTT";
1055  else
1056  timef = "";
1057 
1058  std::string result = te::common::Convert2UCase(firstD) +"s"+
1059  te::common::Convert2UCase(secondD) +"s"+
1060  te::common::Convert2UCase(thirdD) +"s"+
1061  firstT +"s"+
1062  secondT +"s"+
1063  thirdT + timef;
1064 
1065  RegCloseKey (hk);
1066  return result;
1067 }
1068 
1069 int te::ado::GetMonth(const std::string& month)
1070 {
1071  std::string tempM = te::common::Convert2UCase(month);
1072  if(tempM=="JAN")
1073  return 1;
1074  else if(tempM=="FEB")
1075  return 2;
1076  else if(tempM=="MAR")
1077  return 3;
1078  else if(tempM=="APR")
1079  return 4;
1080  else if(tempM=="MAY")
1081  return 5;
1082  else if(tempM=="JUN")
1083  return 6;
1084  else if(tempM=="JUL")
1085  return 7;
1086  else if(tempM=="AUG")
1087  return 8;
1088  else if(tempM=="SEP")
1089  return 9;
1090  else if(tempM=="OCT")
1091  return 12;
1092  else if(tempM=="NOV")
1093  return 11;
1094  else if(tempM=="DEC")
1095  return 12;
1096 
1097  return -1;
1098 }
1099 
1100 std::auto_ptr<te::dt::DateTime> te::ado::GetDateTime(std::string& value, std::string& mask,
1101  std::string& sepD, std::string& sepT)
1102 {
1103  int sec = 0;
1104  int min = 0;
1105  int hour = 0;
1106  int day = 0;
1107  int mon = 0;
1108  int year = 0;
1109 
1110  if(mask == "DDsMMsYYYYsHHsmmsSS")
1111  {
1112  std::vector<std::string> tokGeneral;
1113  te::common::Tokenize(value, tokGeneral, " ");
1114 
1115  // Only Date or only Time
1116  if(tokGeneral.size() == 1)
1117  {
1118  std::vector<std::string> tokDate;
1119  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1120  std::vector<std::string> tokTime;
1121  te::common::Tokenize(tokGeneral[0], tokTime, sepT);
1122 
1123  // Only Date
1124  if(tokDate.size() > 1)
1125  {
1126  day = boost::lexical_cast<int>(tokDate[0]);
1127  mon = boost::lexical_cast<int>(tokDate[1]);
1128  year = boost::lexical_cast<int>(tokDate[2]);
1129  }
1130  // Only Time
1131  else if(tokTime.size() > 1)
1132  {
1133  hour = boost::lexical_cast<int>(tokTime[0]);
1134  min = boost::lexical_cast<int>(tokTime[1]);
1135  sec = boost::lexical_cast<int>(tokTime[2]);
1136  }
1137  }
1138  // Date and Time
1139  else if(tokGeneral.size() == 2)
1140  {
1141  std::vector<std::string> tokDate;
1142  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1143  std::vector<std::string> tokTime;
1144  te::common::Tokenize(tokGeneral[1], tokTime, sepT);
1145 
1146  day = boost::lexical_cast<int>(tokDate[0]);
1147  mon = boost::lexical_cast<int>(tokDate[1]);
1148  year = boost::lexical_cast<int>(tokDate[2]);
1149  hour = boost::lexical_cast<int>(tokTime[0]);
1150  min = boost::lexical_cast<int>(tokTime[1]);
1151  sec = boost::lexical_cast<int>(tokTime[2]);
1152  }
1153  }
1154  else if(mask == "MsDsYYYYsHsmmsSSsTT")
1155  {
1156  std::vector<std::string> tokGeneral;
1157  te::common::Tokenize(value, tokGeneral, " ");
1158 
1159  // Only Date
1160  if(tokGeneral.size() == 1)
1161  {
1162  std::vector<std::string> tokDate;
1163  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1164  mon = boost::lexical_cast<int>(tokDate[0]);
1165  day = boost::lexical_cast<int>(tokDate[1]);
1166  year = boost::lexical_cast<int>(tokDate[2]);
1167  }
1168  // Only Time
1169  else if(tokGeneral.size() == 2)
1170  {
1171  std::vector<std::string> tokTime;
1172  te::common::Tokenize(tokGeneral[0], tokTime, sepT);
1173  hour = boost::lexical_cast<int>(tokTime[0]);
1174  min = boost::lexical_cast<int>(tokTime[1]);
1175  sec = boost::lexical_cast<int>(tokTime[2]);
1176  }
1177  // Date and Time
1178  else if(tokGeneral.size() == 3)
1179  {
1180  std::vector<std::string> tokDate;
1181  std::vector<std::string> tokTime;
1182  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1183  te::common::Tokenize(tokGeneral[1], tokTime, sepT);
1184 
1185  mon = boost::lexical_cast<int>(tokDate[0]);
1186  day = boost::lexical_cast<int>(tokDate[1]);
1187  year = boost::lexical_cast<int>(tokDate[2]);
1188  hour = boost::lexical_cast<int>(tokTime[0]);
1189  min = boost::lexical_cast<int>(tokTime[1]);
1190  sec = boost::lexical_cast<int>(tokTime[2]);
1191  }
1192  }
1193  else if(mask == "YYYYsMMsDDsHHsmmsSS")
1194  {
1195  std::vector<std::string> tokGeneral;
1196  te::common::Tokenize(value, tokGeneral, " ");
1197 
1198  // Only Date or only Time
1199  if(tokGeneral.size() == 1)
1200  {
1201  std::vector<std::string> tokDate;
1202  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1203  std::vector<std::string> tokTime;
1204  te::common::Tokenize(tokGeneral[0], tokTime, sepT);
1205 
1206  // Only Date
1207  if(tokDate.size() > 1)
1208  {
1209  year = boost::lexical_cast<int>(tokDate[0]);
1210  mon = boost::lexical_cast<int>(tokDate[1]);
1211  day = boost::lexical_cast<int>(tokDate[2]);
1212  }
1213  // Only Time
1214  else if(tokTime.size() > 1)
1215  {
1216  hour = boost::lexical_cast<int>(tokTime[0]);
1217  min = boost::lexical_cast<int>(tokTime[1]);
1218  sec = boost::lexical_cast<int>(tokTime[2]);
1219  }
1220  }
1221  // Date and Time
1222  else if(tokGeneral.size() == 2)
1223  {
1224  std::vector<std::string> tokDate;
1225  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1226  std::vector<std::string> tokTime;
1227  te::common::Tokenize(tokGeneral[1], tokTime, sepT);
1228 
1229  year = boost::lexical_cast<int>(tokDate[0]);
1230  mon = boost::lexical_cast<int>(tokDate[1]);
1231  day = boost::lexical_cast<int>(tokDate[2]);
1232  hour = boost::lexical_cast<int>(tokTime[0]);
1233  min = boost::lexical_cast<int>(tokTime[1]);
1234  sec = boost::lexical_cast<int>(tokTime[2]);
1235  }
1236  }
1237  else
1238  throw te::common::Exception((boost::format(TE_TR("DateTime format not provided or invalid: %1%!")) % mask).str());
1239 
1240  te::dt::DateTime* result = 0;
1241 
1242  if((day > 0 || mon > 0 || year > 0) && (sec > 0 || min > 0 || hour > 0))
1243  {
1244  te::dt::Date d(year, mon, day);
1245  te::dt::TimeDuration td(hour, min, sec);
1246  result = new te::dt::TimeInstant(d, td);
1247  }
1248  else if(day > 0 || mon > 0 || year > 0)
1249  {
1250  result = new te::dt::Date(year, mon, day);
1251  }
1252  else if(sec > 0 || min > 0 || hour > 0)
1253  {
1254  result = new te::dt::TimeDuration(hour, min, sec);
1255  }
1256  else
1257  return std::auto_ptr<te::dt::DateTime>(0);
1258 
1259  return std::auto_ptr<te::dt::DateTime>(result);
1260 }
1261 
1263 {
1264  std::string result = "";
1265 
1266  te::dt::Date* dtime = dynamic_cast<te::dt::Date*>(dateTime);
1267 
1268  std::string mAM, mPM, sepD, sepT;
1269 
1270  std::string mask = GetSystemDateTimeFormat(mAM, mPM, sepD, sepT);
1271 
1272  if(dtime)
1273  {
1274  if(mask.find("DDsMMsYYYY") != std::string::npos)
1275  {
1276  result = boost::lexical_cast<std::string>(dtime->getDay()) + sepD;
1277  result += boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(dtime->getMonth()))) + sepD;
1278  result += boost::lexical_cast<std::string>(dtime->getYear());
1279  }
1280  else if(mask.find("MsDsYYYY") != std::string::npos)
1281  {
1282  result = boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(dtime->getMonth()))) + sepD;
1283  result += boost::lexical_cast<std::string>(dtime->getDay()) + sepD;
1284  result += boost::lexical_cast<std::string>(dtime->getYear());
1285  }
1286  else if(mask.find("YYYYsMMsDD") != std::string::npos)
1287  {
1288  result = boost::lexical_cast<std::string>(dtime->getYear()) + sepD;
1289  result += boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(dtime->getMonth()))) + sepD;
1290  result += boost::lexical_cast<std::string>(dtime->getDay());
1291  }
1292  }
1293 
1294  te::dt::TimeDuration* tduration = dynamic_cast<te::dt::TimeDuration*>(dateTime);
1295 
1296  if(tduration)
1297  {
1298  if(mask.find("HHsmmsSS") != std::string::npos)
1299  {
1300  result = boost::lexical_cast<std::string>(tduration->getHours()) + sepT;
1301  result += boost::lexical_cast<std::string>(tduration->getMinutes()) + sepT;
1302  result += boost::lexical_cast<std::string>(tduration->getSeconds());
1303  }
1304  else if(mask.find("HsmmsSSsTT") != std::string::npos)
1305  {
1306  result = boost::lexical_cast<std::string>(tduration->getHours()) + sepT;
1307  result += boost::lexical_cast<std::string>(tduration->getMinutes()) + sepT;
1308  result += boost::lexical_cast<std::string>(tduration->getSeconds());
1309  }
1310  }
1311 
1312  te::dt::TimeInstant* tinst = dynamic_cast<te::dt::TimeInstant*>(dateTime);
1313 
1314  if(tinst)
1315  {
1316  te::dt::Date date = tinst->getDate();
1317  te::dt::TimeDuration time = tinst->getTime();
1318 
1319  if(mask == "DDsMMsYYYYsHHsmmsSS")
1320  {
1321  result = boost::lexical_cast<std::string>(date.getDay()) + sepD;
1322  result += boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(date.getMonth()))) + sepD;
1323  result += boost::lexical_cast<std::string>(date.getYear()) + " ";
1324  result += boost::lexical_cast<std::string>(time.getHours()) + sepT;
1325  result += boost::lexical_cast<std::string>(time.getMinutes()) + sepT;
1326  result += boost::lexical_cast<std::string>(time.getSeconds());
1327  }
1328  else if(mask == "MsDsYYYYsHsmmsSSsTT")
1329  {
1330  result = boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(date.getMonth()))) + sepD;
1331  result += boost::lexical_cast<std::string>(date.getDay()) + sepD;
1332  result += boost::lexical_cast<std::string>(date.getYear()) + " ";
1333  result += boost::lexical_cast<std::string>(time.getHours()) + sepT;
1334  result += boost::lexical_cast<std::string>(time.getMinutes()) + sepT;
1335  result += boost::lexical_cast<std::string>(time.getSeconds());
1336  }
1337  else if(mask == "YYYYsMMsDDsHHsmmsSS")
1338  {
1339  result = boost::lexical_cast<std::string>(date.getYear()) + sepD;
1340  result += boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(date.getMonth()))) + sepD;
1341  result += boost::lexical_cast<std::string>(date.getDay()) + " ";
1342  result += boost::lexical_cast<std::string>(time.getHours()) + sepT;
1343  result += boost::lexical_cast<std::string>(time.getMinutes()) + sepT;
1344  result += boost::lexical_cast<std::string>(time.getSeconds());
1345  }
1346  }
1347 
1348  te::dt::TimeInstantTZ* tinstZ = dynamic_cast<te::dt::TimeInstantTZ*>(dateTime);
1349 
1350  if(tinstZ)
1351  {
1352  boost::local_time::local_date_time boostTime = tinstZ->getTimeInstantTZ();
1353 
1354  int hh = boostTime.utc_time().time_of_day().hours();
1355  int mm = boostTime.utc_time().time_of_day().minutes();
1356  int ss = boostTime.utc_time().time_of_day().seconds();
1357 
1358  if(mask.find("HHsmmsSS") != std::string::npos)
1359  {
1360  result = boost::lexical_cast<std::string>(hh) + sepT;
1361  result += boost::lexical_cast<std::string>(mm) + sepT;
1362  result += boost::lexical_cast<std::string>(ss);
1363  }
1364  else if(mask.find("HsmmsSSsTT") != std::string::npos)
1365  {
1366  result = boost::lexical_cast<std::string>(hh) + sepT;
1367  result += boost::lexical_cast<std::string>(mm) + sepT;
1368  result += boost::lexical_cast<std::string>(ss);
1369  }
1370  }
1371 
1372  return result;
1373 }
1374 
StringType
The subtype of string property.
Definition: Enums.h:171
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
Definition: Geometry.h:189
int GetMonth(const std::string &month)
It gets the index of a month.
Definition: Utils.cpp:1069
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
DataSet class implementation for Microsoft Access driver.
int GetSRID(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
Read the geometry_columns table end return a SRID.
Definition: Utils.cpp:835
An atomic property like an integer or double.
const std::string & GetGeometryName(te::gm::GeomType t)
It returns the geometry OGC names.
Definition: Utils.cpp:532
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that form the unique key.
Definition: UniqueKey.h:117
te::gm::GeomType GetType(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
Read the geometry_columns table end return a geometry type.
Definition: Utils.cpp:859
void getWkb(char *wkb, te::common::MachineByteOrder byteOrder) const
It serializes the geometry to a WKB representation into the specified buffer.
Definition: Geometry.cpp:139
int Convert2Terralib(ADOX::DataTypeEnum adoType)
Bind ADOX Type to TerraLib Type.
Definition: Utils.cpp:236
long getSeconds() const
It returns the seconds of a minute - from 0 to 59.
Definition: TimeDuration.h:105
Spatial reference system transformation function.
void Blob2Variant(const char *blob, int size, _variant_t &var)
Convert a blob to a variant.
Definition: Utils.cpp:56
boost::gregorian::greg_year getYear() const
It returns the gregorian year.
Definition: Date.h:111
Configuration flags for the TerraLib ADO Data Access driver.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:163
boost::gregorian::greg_day getDay() const
It returns the gregorian day - from 1 to 31.
Definition: Date.h:97
std::string GetSystemDateTimeFormat(std::string &indAM, std::string &indPM, std::string &sepD, std::string &sepT)
It gets the system Date and Time format.
Definition: Utils.cpp:931
std::string MakeConnectionStr(const std::map< std::string, std::string > &dsInfo)
Create a connection string based on a map.
Definition: Utils.cpp:82
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
std::string GetFormattedDateTime(te::dt::DateTime *dateTime)
It gets a formatted DateTime string for ADO.
Definition: Utils.cpp:1262
std::size_t getWkbSize() const
It returns the size required by a WKB representation for this geometric object.
Definition: Geometry.cpp:134
It models a property definition.
Definition: Property.h:59
A class to represent time instant.
Definition: TimeInstant.h:55
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
Definition: StringUtils.h:216
std::string GetAdoStringType(const int &terralib)
Bind TerraLib type to an ADO valid fiel type name.
Definition: Utils.cpp:181
Date getDate() const
It returns the date associated to time instant.
Definition: TimeInstant.h:106
A base class for date data types.
Definition: Date.h:53
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that form the primary key.
Definition: PrimaryKey.h:116
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
const boost::local_time::local_date_time & getTimeInstantTZ() const
It returns the boost time instant with time zone type.
Definition: TimeInstantTZ.h:71
The type for string types: FIXED_STRING, VAR_STRING or STRING.
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
te::common::AccessPolicy Convert2Terralib(std::string accessPolicy)
Definition: Serializer.cpp:393
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that take part of the foreign key constraint.
Definition: ForeignKey.h:121
const te::gm::GeomType GetGeometryType(std::string t)
It returns the geometry type concerning the OGC name.
Definition: Utils.cpp:685
The type for variable-length multidimensional arrays.
Definition: ArrayProperty.h:45
Utility functions for ADO.
A class to represent time duration with nano-second/micro-second resolution.
Definition: TimeDuration.h:51
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
ADOX::DataTypeEnum Convert2Ado(int terralib)
Bind TerraLib Type to ADO Type.
Definition: Utils.cpp:128
The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
TimeDuration getTime() const
It returns the time duration associated to time instant.
Definition: TimeInstant.cpp:49
bool IsZProperty(te::gm::GeomType type)
Verifies whether Z property.
Definition: Utils.cpp:924
bool IsGeomProperty(_ConnectionPtr adoConn, std::string tableName, std::string columnName)
Verifies whether is in the geometry_columns table.
Definition: Utils.cpp:885
long getMinutes() const
It returns the minutes of a hour - from 0 to 59.
Definition: TimeDuration.h:98
std::auto_ptr< te::dt::DateTime > GetDateTime(std::string &value, std::string &mask, std::string &sepD, std::string &sepT)
It gets the DateTime TerraLib 5 from string.
Definition: Utils.cpp:1100
A class to represent time instant with time zone.
Definition: TimeInstantTZ.h:52
void TESTHR(HRESULT hr)
Definition: Utils.cpp:51
boost::gregorian::greg_month getMonth() const
It returns the gregorian month - from 1 to 12.
Definition: Date.h:104
An static class with global definitions.
void Variant2Blob(const _variant_t var, int size, char *&blob)
Convert a variant to a blob.
Definition: Utils.cpp:109
long getHours() const
It returns the hours of a day - from 0 to 23.
Definition: TimeDuration.h:91