src/terralib/ogr/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/ogr/Utils.cpp
22 
23  \brief Utility functions for OGR support.
24 */
25 
26 // TerraLib
27 #include "../common/Exception.h"
28 #include "../common/Globals.h"
29 #include "../core/translator/Translator.h"
30 #include "../dataaccess/dataset/DataSetType.h"
31 #include "../dataaccess/utils/Utils.h"
32 #include "../datatype/ArrayProperty.h"
33 #include "../datatype/DateTime.h"
34 #include "../datatype/DateTimeProperty.h"
35 #include "../datatype/NumericProperty.h"
36 #include "../datatype/Property.h"
37 #include "../datatype/SimpleProperty.h"
38 #include "../datatype/StringProperty.h"
39 #include "../geometry/Envelope.h"
40 #include "../geometry/Geometry.h"
41 #include "../geometry/GeometryProperty.h"
42 #include "../geometry/WKBReader.h"
43 #include "../srs/SpatialReferenceSystemManager.h"
44 #include "../srs/Config.h"
45 #include "Utils.h"
46 #include "../core/logger/Logger.h"
47 
48 // OGR
49 #include <ogrsf_frmts.h>
50 #include <ogr_spatialref.h>
51 
52 // Boost
53 #include <boost/algorithm/string.hpp>
54 #include <boost/filesystem.hpp>
55 
57 {
58  int wkbSize = ogrGeom->WkbSize();
59 
60  unsigned char* wkbArray = new unsigned char[wkbSize];
61 
62  ogrGeom->exportToWkb(wkbNDR, wkbArray);
63 
64  te::gm::Geometry* teGeom = nullptr;
65 
66  try
67  {
68  teGeom = te::gm::WKBReader::read((const char*)wkbArray);
69  }
70  catch(...)
71  {
72  delete [] wkbArray;
73  throw;
74  }
75 
76  delete [] wkbArray;
77 
78  return teGeom;
79 }
80 
81 OGRGeometry* te::ogr::Convert2OGR(const te::gm::Geometry* teGeom)
82 {
83  OGRSpatialReference* srs = Convert2OGRProjection(teGeom->getSRID());
84 
85  OGRGeometry* ogrGeom = Convert2OGR(teGeom, srs);
86 
87  OGRSpatialReference::DestroySpatialReference(srs);
88 
89  return ogrGeom;
90 }
91 
92 OGRGeometry* te::ogr::Convert2OGR(const te::gm::Geometry* teGeom, const OGRSpatialReference* srs)
93 {
94  size_t size = teGeom->getWkbSize();
95 
96  char* wkbArray = new char[size];
97 
99 
100  OGRGeometry* ogrGeom = nullptr;
101 
102  OGRSpatialReference *srs_aux = srs->Clone();
103  OGRErr result = OGRGeometryFactory::createFromWkb((unsigned char*)wkbArray, srs_aux, &ogrGeom, static_cast<int>(size));
104 
105  delete[] wkbArray;
106  srs_aux->Release();
107 
108  if (result == OGRERR_NONE)
109  return ogrGeom;
110 
111  if (result == OGRERR_NOT_ENOUGH_DATA)
112  throw te::common::Exception(TE_TR("Error when attempting convert the geometry to OGR. Not enough data."));
113 
114  if (result == OGRERR_UNSUPPORTED_GEOMETRY_TYPE)
115  throw te::common::Exception(TE_TR("Error when attempting convert the geometry to OGR. Unsupported geometry type."));
116 
117  if (result == OGRERR_CORRUPT_DATA)
118  throw te::common::Exception(TE_TR("Error when attempting convert the geometry to OGR. Corrupt data."));
119 
120  return nullptr;
121 }
122 
124 {
125  return new te::gm::Envelope(env->MinX, env->MinY, env->MaxX, env->MaxY);
126 }
127 
128 OGREnvelope* te::ogr::Convert2OGR(const te::gm::Envelope* env)
129 {
130  OGREnvelope* envOGR = new OGREnvelope();
131  envOGR->MinX = env->m_llx;
132  envOGR->MinY = env->m_lly;
133  envOGR->MaxX = env->m_urx;
134  envOGR->MaxY = env->m_ury;
135  return envOGR;
136 }
137 
138 int te::ogr::Convert2TerraLibProjection(OGRSpatialReference* osrs)
139 {
140  if(osrs == nullptr)
141  return TE_UNKNOWN_SRS;
142 
143  int srid = 0;
144 
145  OGRErr ogrReturn = osrs->AutoIdentifyEPSG();
146  if( ogrReturn == OGRERR_NONE )
147  {
148  const char* srsAuth = osrs->GetAuthorityCode(nullptr);
149 
150  if (srsAuth)
151  {
152  srid = atoi(srsAuth);
153  }
154  }
155 
156  std::string proj4;
157  if( srid == TE_UNKNOWN_SRS )
158  {
159  char* proj4StrPtr = nullptr;
160  ogrReturn = osrs->exportToProj4( &proj4StrPtr );
161 
162  if( ogrReturn == OGRERR_NONE )
163  {
164  std::pair< std::string, unsigned int > customSRID;
165  proj4 = std::string ( proj4StrPtr );
166 
167  OGRFree( proj4StrPtr );
168 
169  try
170  {
171  customSRID = te::srs::SpatialReferenceSystemManager::getInstance().getIdFromP4Txt(
172  proj4);
173  srid = (int)customSRID.second;
174  }
175  catch( te::common::Exception& )
176  {
177  }
178  }
179  }
180 
181  std::string wkt;
182  if( srid == TE_UNKNOWN_SRS )
183  {
184  char* wktPtr = nullptr;
185  ogrReturn = osrs->exportToWkt( &wktPtr );
186 
187  if( ogrReturn == OGRERR_NONE )
188  {
189  std::pair< std::string, unsigned int > customSRID;
190  wkt = std::string( wktPtr );
191 
192  OGRFree( wktPtr );
193 
194  try
195  {
196  customSRID = te::srs::SpatialReferenceSystemManager::getInstance().getIdFromWkt(
197  wkt);
198  srid = (int)customSRID.second;
199  }
200  catch( te::common::Exception& )
201  {
202  }
203  }
204  }
205 
206  if( srid == TE_UNKNOWN_SRS )
207  {
208  // geographic SIRGAS 2000 Datum
209  std::string straux(osrs->GetRoot()->GetChild(0)->GetValue());
210 
211  if (boost::find_first(straux, "SIRGAS"))
212  {
213  if (osrs->IsGeographic())
214  srid = TE_SRS_SIRGAS2000;
215  }
216  else if (boost::find_first(straux, "UTM "))
217  { // UTM using SIRGAS 2000 Datum
218  double centralm = osrs->GetProjParm(SRS_PP_CENTRAL_MERIDIAN,-1);
219  if (centralm != -1)
220  {
221  int zone = (int)(centralm/6 + 31);
222 
223  double fsnorth = osrs->GetProjParm(SRS_PP_FALSE_NORTHING,-1);
224  if (fsnorth > 0)
225  srid = 31960+zone;
226  else if (fsnorth == 0)
227  srid = 31954+zone;
228  }
229  }
230  }
231 
232  if (srid == TE_UNKNOWN_SRS)
233  {
234  //if we have an Unkwnown SRID, but the WKT and PROJ4 representations of the SRS were correctly decoded,
235  //we have a valid user defined projection. Lets register it
236  if (wkt.empty() == false && proj4.empty() == false)
237  {
238  std::string strNewSRID = te::srs::SpatialReferenceSystemManager::getInstance().getNewUserDefinedSRID();
239  srid = boost::lexical_cast<int>(strNewSRID);
240  std::string newName = "USER:" + strNewSRID;
241  te::srs::SpatialReferenceSystemManager::getInstance().add(newName, proj4, wkt, srid, "USER");
242  }
243  }
244 
245  return srid;
246 }
247 
248 OGRSpatialReference* te::ogr::Convert2OGRProjection(int srid)
249 {
250  std::unique_ptr< OGRSpatialReference > osrs( new OGRSpatialReference() );
251 
252  OGRErr error = osrs->importFromEPSG(srid);
253 
254  if( error != OGRERR_NONE )
255  {
256  try
257  {
258  std::string proj4Str =
260 
261  if( !proj4Str.empty() )
262  {
263  char* proj4StrPtr = (char*)proj4Str.c_str();
264  error = osrs->importFromProj4( proj4StrPtr );
265  }
266  }
267  catch( te::common::Exception& )
268  {
269  error = OGRERR_UNSUPPORTED_SRS;
270  }
271  }
272 
273  if( error != OGRERR_NONE )
274  {
275  try
276  {
277  std::string wktStr =
279 
280  if( !wktStr.empty() )
281  {
282  char* wktStrPtr = (char*)wktStr.c_str();
283  error = osrs->importFromWkt( &wktStrPtr );
284  }
285  }
286  catch( te::common::Exception& )
287  {
288  error = OGRERR_UNSUPPORTED_SRS;
289  }
290  }
291 
292  if(error != OGRERR_NONE)
293  throw(te::common::Exception(TE_TR("Error converting spatial reference system.")));
294 
295  return osrs.release();
296 }
297 
298 void te::ogr::Convert2TerraLib(OGRFeatureDefn* featDef, te::da::DataSetType* dt, int srs)
299 {
300  assert(dt);
301 
302  int nFields = featDef->GetFieldCount();
303 
304  for(int i = 0; i < nFields; i++)
305  {
306  OGRFieldDefn* fieldDef = featDef->GetFieldDefn(i);
307  te::dt::Property* p = Convert2TerraLib(fieldDef);
308  dt->add(p);
309  }
310 
311  OGRwkbGeometryType ogrGeomType = featDef->GetGeomType();
312 
313  if(ogrGeomType != wkbNone) // has geometry?
314  {
315  te::gm::GeomType geomType = Convert2TerraLib(ogrGeomType);
316  te::gm::GeometryProperty* geomPropertyType = new te::gm::GeometryProperty("OGR_GEOMETRY", srs, geomType);
317  dt->add(geomPropertyType);
318  }
319 }
320 
321 te::da::DataSetType* te::ogr::Convert2TerraLib(OGRFeatureDefn* featDef, int srs)
322 {
323  te::da::DataSetType* dt = new te::da::DataSetType(featDef->GetName());
324 
325  dt->setTitle(featDef->GetName());
326 
327  te::ogr::Convert2TerraLib(featDef,dt, srs);
328 
329  return dt;
330 }
331 
333 {
334  OGRFeatureDefn* featDef = new OGRFeatureDefn(dt->getName().c_str());
335  std::vector<te::dt::Property*> props = dt->getProperties();
336 
337  for(unsigned int i = 0; i < props.size(); i++)
338  {
339  te::dt::Property* p = props[i];
340  if(p->getType() != te::dt::GEOMETRY_TYPE)
341  featDef->AddFieldDefn(Convert2OGR(p));
342  }
343 
344  if(dt->hasGeom())
345  {
347  featDef->SetGeomType(Convert2OGR(geom->getGeometryType()));
348  }
349 
350  return featDef;
351 }
352 
354 {
355  te::dt::Property* p = nullptr;
356  std::string name = fieldDef->GetNameRef();
357  switch(fieldDef->GetType())
358  {
359  case OFTInteger:
361  break;
362 
363  case OFTInteger64:
365  break;
366 
367  case OFTIntegerList:
369  break;
370 
371  case OFTString:
372  {
373  te::dt::StringProperty* sp = nullptr;
374 
375  if(fieldDef->GetWidth() == 0)
376  sp = new te::dt::StringProperty(name, te::dt::STRING);
377  else
378  sp = new te::dt::StringProperty(name, te::dt::VAR_STRING, fieldDef->GetWidth());
379 
380  p = sp;
381  }
382  break;
383 
384  case OFTStringList:
386  break;
387 
388  case OFTReal:
390  break;
391 
392  case OFTRealList:
394  break;
395 
396  case OFTBinary:
398  break;
399 
400  case OFTDate:
401  p = new te::dt::DateTimeProperty(name, te::dt::DATE);
402  break;
403 
404  case OFTTime:
406  break;
407 
408  case OFTDateTime:
410  break;
411 
412  default:
413  throw(te::common::Exception(TE_TR("Unexpected data type.")));
414  }
415 
416  return p;
417 }
418 
420 {
421  OGRFieldDefn* fieldDef = new OGRFieldDefn(p->getName().c_str(), OFTInteger);
422  switch(p->getType())
423  {
424  case te::dt::INT32_TYPE:
425  return fieldDef;
426  break;
427 
428  case te::dt::INT64_TYPE:
429  {
430  fieldDef->SetType(OFTInteger64);
431  return fieldDef;
432  break;
433  }
434 
435  case te::dt::ARRAY_TYPE:
436  {
437  te::dt::ArrayProperty* at = static_cast<te::dt::ArrayProperty*>(p);
438  int elementType = at->getElementType()->getType();
439 
440  if(elementType == te::dt::INT32_TYPE)
441  fieldDef->SetType(OFTIntegerList);
442  else if(elementType == te::dt::STRING_TYPE)
443  fieldDef->SetType(OFTStringList);
444  else if(elementType == te::dt::DOUBLE_TYPE)
445  fieldDef->SetType(OFTRealList);
446  else
447  throw(te::common::Exception(TE_TR("Unsupported data type by OGR.")));
448  break;
449  }
450 
451  case te::dt::STRING_TYPE:
452  fieldDef->SetType(OFTString);
453  fieldDef->SetWidth(static_cast<int>(static_cast<te::dt::StringProperty*>(p)->size()));
454  break;
455 
456  case te::dt::DOUBLE_TYPE:
457  fieldDef->SetType(OFTReal);
458  break;
459 
461  fieldDef->SetType(OFTReal);
462  fieldDef->SetPrecision(static_cast<te::dt::NumericProperty*>(p)->getScale());
463  break;
464 
466  fieldDef->SetType(OFTBinary);
467  break;
468 
470  {
471  const te::dt::DateTimeProperty* dp = static_cast<const te::dt::DateTimeProperty*>(p);
472  te::dt::DateTimeType elementType = dp->getSubType();
473  if(elementType == te::dt::DATE)
474  fieldDef->SetType(OFTDate);
475  else if(elementType == te::dt::TIME_DURATION)
476  fieldDef->SetType(OFTTime);
477  else if(elementType == te::dt::TIME_INSTANT)
478  fieldDef->SetType(OFTDateTime);
479  else
480  throw(te::common::Exception(TE_TR("Unsupported data type by OGR.")));
481  break;
482  }
483 
484  default:
485  throw(te::common::Exception(TE_TR("Unsupported data type by OGR.")));
486  }
487 
488  return fieldDef;
489 }
490 
491 te::gm::GeomType te::ogr::Convert2TerraLib(OGRwkbGeometryType ogrGeomType)
492 {
493  switch(ogrGeomType)
494  {
495  case wkbPoint:
496  return te::gm::MultiPointType;
497 
498  case wkbPointM:
500 
501  case wkbPointZM:
503 
504  case wkbPoint25D:
506 
507  case wkbMultiPoint:
508  return te::gm::MultiPointType;
509 
510  case wkbMultiPointM:
512 
513  case wkbMultiPointZM:
515 
516  case wkbMultiPoint25D:
518 
519 
520  case wkbLinearRing:
522 
523  case wkbLineString:
525 
526  case wkbLineStringM:
528 
529  case wkbLineStringZM:
531 
532  case wkbLineString25D:
534 
535  case wkbMultiLineString:
537 
538  case wkbMultiLineStringM:
540 
541  case wkbMultiLineStringZM:
543 
544  case wkbMultiLineString25D:
546 
547 
548  case wkbPolygon:
550 
551  case wkbPolygonM:
553 
554  case wkbPolygonZM:
556 
557  case wkbPolygon25D:
559 
560  case wkbMultiPolygon:
562 
563  case wkbMultiPolygonM:
565 
566  case wkbMultiPolygonZM:
568 
569  case wkbMultiPolygon25D:
571 
572 
573  case wkbGeometryCollection:
575 
576  case wkbGeometryCollectionM:
578 
579  case wkbGeometryCollectionZM:
581 
582  case wkbGeometryCollection25D:
584 
585 
586  case wkbMultiSurface:
588 
589  case wkbMultiSurfaceM:
591 
592  case wkbMultiSurfaceZM:
594 
595  case wkbMultiSurfaceZ:
597 
598 
599  case wkbPolyhedralSurface:
601 
602  case wkbPolyhedralSurfaceM:
604 
605  case wkbPolyhedralSurfaceZM:
607 
608  case wkbPolyhedralSurfaceZ:
610 
611 
612  case wkbTIN:
613  return te::gm::TINType;
614 
615  case wkbTINM:
616  return te::gm::TINMType;
617 
618  case wkbTINZM:
619  return te::gm::TINZMType;
620 
621  case wkbTINZ:
622  return te::gm::TINZType;
623 
624  case wkbTriangle:
625  return te::gm::TriangleType;
626 
627  case wkbTriangleM:
628  return te::gm::TriangleMType;
629 
630  case wkbTriangleZM:
631  return te::gm::TriangleZMType;
632 
633  case wkbTriangleZ:
634  return te::gm::TriangleZType;
635 
636 
637  case wkbUnknown:
638  return te::gm::GeometryType;
639 
640  default:
642  }
643 }
644 
645 OGRwkbGeometryType te::ogr::Convert2OGR(te::gm::GeomType geomType)
646 {
647  switch(geomType)
648  {
650  return wkbUnknown;
651 
652  case te::gm::PointType:
653  return wkbPoint;
654 
655  case te::gm::PointZType:
656  return wkbPoint25D;
657 
658  case te::gm::PointMType:
659  return wkbPointM;
660 
661  case te::gm::PointZMType:
662  return wkbPointZM;
663 
664 
666  return wkbLineString;
667 
669  return wkbLineString25D;
670 
672  return wkbLineStringM;
673 
675  return wkbLineStringZM;
676 
677 
678  case te::gm::PolygonType:
679  return wkbPolygon;
680 
682  return wkbPolygon25D;
683 
685  return wkbPolygonM;
686 
688  return wkbPolygonZM;
689 
690 
692  return wkbMultiPoint;
693 
695  return wkbMultiPoint25D;
696 
698  return wkbMultiPointM;
699 
701  return wkbMultiPointZM;
702 
703 
705  return wkbMultiLineString;
706 
708  return wkbMultiLineString25D;
709 
711  return wkbMultiLineStringM;
712 
714  return wkbMultiLineStringZM;
715 
716 
718  return wkbMultiPolygon;
719 
721  return wkbMultiPolygon25D;
722 
724  return wkbMultiPolygonM;
725 
727  return wkbMultiPolygonZM;
728 
729 
731  return wkbGeometryCollection;
732 
734  return wkbGeometryCollection25D;
735 
737  return wkbGeometryCollectionM;
738 
740  return wkbGeometryCollectionZM;
741 
742 
744  return wkbMultiSurface;
745 
747  return wkbMultiSurfaceM;
748 
750  return wkbMultiSurfaceZM;
751 
753  return wkbMultiSurfaceZ;
754 
755 
757  return wkbPolyhedralSurface;
758 
760  return wkbPolyhedralSurfaceZ;
761 
763  return wkbPolyhedralSurfaceM;
764 
766  return wkbPolyhedralSurfaceZM;
767 
768 
769  case te::gm::TINType:
770  return wkbTIN;
771 
772  case te::gm::TINMType:
773  return wkbTINM;
774 
775  case te::gm::TINZMType:
776  return wkbTINZM;
777 
778  case te::gm::TINZType:
779  return wkbTINZ;
780 
781 
783  return wkbTriangle;
784 
786  return wkbTriangleM;
787 
789  return wkbTriangleZM;
790 
792  return wkbTriangleZ;
793 
794  default:
795  throw(te::common::Exception(TE_TR("Unsupported geometry type by OGR Driver.")));
796  }
797 }
798 
799 std::string te::ogr::GetDriverName(const std::string& path)
800 {
801  boost::filesystem::path mpath(path.c_str());
802 
803  std::string ext = mpath.extension().string();
804 
805  if(ext == ".shp" || ext == ".SHP")
806  return std::string("ESRI Shapefile");
807 
808  if(ext == ".mif" || ext == ".MIF")
809  return std::string("Mapinfo File");
810 
811  if(ext == ".kml" || ext == ".KML")
812  return std::string("KML");
813 
814  if(ext == ".geojson" || ext == ".GEOJSON")
815  return std::string("GeoJSON");
816 
817  if(ext == ".gml" || ext == ".GML")
818  return std::string("GML");
819 
820  if(ext == ".dxf" || ext == ".DXF")
821  return std::string("DXF");
822 
823  if(ext == ".dgn" || ext == ".DGN")
824  return std::string("DGN");
825 
826  if (ext == ".csv" || ext == ".CSV")
827  return std::string("CSV");
828 
829  return "";
830 }
831 
832 std::vector<std::string> te::ogr::GetOGRDrivers(bool filterCreate)
833 {
834  std::vector<std::string> drivernames;
835 
836  int ndrivers = GetGDALDriverManager()->GetDriverCount();
837 
838  for (int i = 0; i < ndrivers; ++i)
839  {
840  GDALDriver* driver = GetGDALDriverManager()->GetDriver(i);
841  if (filterCreate && !OGR_Dr_TestCapability(driver, ODrCCreateDataSource))
842  continue;
843  drivernames.push_back(driver->GetDescription());
844  }
845 
846  return drivernames;
847 }
848 
849 std::string te::ogr::GetOGRConnectionInfo(const std::map<std::string, std::string>& connInfo)
850 {
851  std::map<std::string, std::string>::const_iterator it = connInfo.find("URI");
852 
853  if(it != connInfo.end())
854  return it->second;
855 
856  it = connInfo.find("SOURCE");
857 
858  if(it != connInfo.end())
859  return it->second;
860 
861  throw te::common::Exception(TE_TR("Invalid data source connection information!."));
862 }
863 
864 std::string te::ogr::RemoveSpatialSql(const std::string& sql)
865 {
866  // Try find AND
867  std::size_t pos = sql.find("AND Intersection");
868 
869  // Try find without AND
870  if(pos == std::string::npos)
871  pos = sql.find("WHERE Intersection");
872 
873  if(pos == std::string::npos)
874  return sql;
875 
876  std::string newQuery;
877 
878  std::size_t pos2 = sql.find("))", pos);
879  newQuery = sql.substr(0, pos);
880  newQuery += sql.substr(pos2 + 2);
881 
882  return newQuery;
883 }
884 
886 {
887  static boost::mutex getStaticMutexStaticMutex;
888  return getStaticMutexStaticMutex;
889 }
890 
891 void te::ogr::OGRErrorHandler(CPLErr /*eErrClass*/, int /*errNo*/,
892  const char* msg)
893 {
894  TE_LOG_ERROR(msg);
895 }
void setTitle(const std::string &title)
It sets a human descriptive title for the DataSetType.
Definition: DataSetType.h:137
Geometric property.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
TEOGREXPORT OGRGeometry * Convert2OGR(const te::gm::Geometry *teGeom)
It converts the TerraLib Geometry to OGR Geometry.
An atomic property like an integer or double.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
bool hasGeom() const
It returns true if the DataSetType has at least one geometry property; otherwise, it returns false...
Definition: DataSetType.h:655
A class that models the description of a dataset.
Definition: DataSetType.h:72
TEOGREXPORT boost::mutex & getStaticMutex()
Returns a reference to a static mutex initialized when this module is initialized.
double m_urx
Upper right corner x-coordinate.
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian).
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
TEOGREXPORT std::string RemoveSpatialSql(const std::string &sql)
std::size_t getWkbSize() const _NOEXCEPT_OP(true)
It returns the size required by a WKB representation for this geometric object.
TEOGREXPORT std::vector< std::string > GetOGRDrivers(bool filterCreate=false)
It returns the list of OGR Drivers available.
It models a property definition.
Definition: Property.h:59
std::string GetDriverName(const std::string &path)
It tries extract the driver name used by OGR Library based on the given path.
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
double m_llx
Lower left corner x-coordinate.
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
static SpatialReferenceSystemManager & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
TEOGREXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
static te::dt::TimeDuration dt(20, 30, 50, 11)
te::gm::Polygon * p
The type for string types: FIXED_STRING, VAR_STRING or STRING.
Utility functions for the data access module.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
double m_lly
Lower left corner y-coordinate.
TEOGREXPORT std::string GetOGRConnectionInfo(const std::map< std::string, std::string > &connInfo)
int getType() const
It returns the property data type.
Definition: Property.h:161
void add(Constraint *c)
It adds a new constraint.
#define TE_SRS_SIRGAS2000
Property * getElementType() const
It returns the type of array elements.
Definition: ArrayProperty.h:98
The type for variable-length multidimensional arrays.
Definition: ArrayProperty.h:45
double m_ury
Upper right corner y-coordinate.
void OGRErrorHandler(CPLErr eErrClass, int errNo, const char *msg)
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.
#define TE_LOG_ERROR(message)
Use this tag in order to log a message to the TerraLib default logger with the ERROR level...
Definition: Logger.h:337
DateTimeType
The subtype of date and time type, based on ISO 8621.
DateTimeType getSubType() const
It returns the date time property sub type.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
te::da::DataSetType * Convert2TerraLib(sqlite3_stmt *pStmt)
#define TEOGREXPORT
You can use this macro in order to export/import classes and functions from this module.
TEOGREXPORT OGRSpatialReference * Convert2OGRProjection(int srid)
It converts the TerraLib Projection to OGR Projection.
TEOGREXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection.
static Geometry * read(const char *wkb)
It returns a valid geometry from a given WKB.
Definition: WKBReader.cpp:48
void getWkb(char *wkb, te::common::MachineByteOrder byteOrder) const _NOEXCEPT_OP(false)
It serializes the geometry to a WKB representation into the specified buffer.
const std::string & getName() const
It returns the property name.
Definition: Property.h:127