src/terralib/qt/plugins/mobile/geopackage/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 "../../../../gdal/Raster.h"
40 #include "../../../../geometry/Envelope.h"
41 #include "../../../../geometry/Geometry.h"
42 #include "../../../../geometry/GeometryProperty.h"
43 #include "../../../../geometry/WKBReader.h"
44 #include "../../../../raster/BandProperty.h"
45 #include "../../../../raster/Grid.h"
46 #include "../../../../raster/RasterFactory.h"
47 #include "../../../../raster/RasterProperty.h"
48 #include "../../../../srs/SpatialReferenceSystemManager.h"
49 #include "../../../../srs/Config.h"
50 #include "Utils.h"
51 
52 
53 
54 // GDAL
55 #include <gdal_priv.h>
56 
57 // OGR
58 #include <ogrsf_frmts.h>
59 #include <ogr_spatialref.h>
60 
61 // Boost
62 #include <boost/algorithm/string.hpp>
63 #include <boost/filesystem.hpp>
64 
66 {
67  int wkbSize = ogrGeom->WkbSize();
68 
69  unsigned char* wkbArray = new unsigned char[wkbSize];
70 
71  ogrGeom->exportToWkb(wkbNDR, wkbArray);
72 
73  te::gm::Geometry* teGeom = 0;
74 
75  try
76  {
77  teGeom = te::gm::WKBReader::read((const char*)wkbArray);
78  }
79  catch(...)
80  {
81  delete [] wkbArray;
82  throw;
83  }
84 
85  delete [] wkbArray;
86 
87  return teGeom;
88 }
89 
90 OGRGeometry* te::gpkg::Convert2OGR(const te::gm::Geometry* teGeom)
91 {
92  size_t size = teGeom->getWkbSize();
93 
94  char* wkbArray = new char[size];
95 
97 
98  OGRSpatialReference* srs = Convert2OGRProjection(teGeom->getSRID());
99 
100  OGRGeometry* ogrGeom = 0;
101 
102  OGRErr result = OGRGeometryFactory::createFromWkb((unsigned char*)wkbArray, srs, &ogrGeom, static_cast<int>(size));
103 
104  delete [] wkbArray;
105 
106  if(result == OGRERR_NONE)
107  return ogrGeom;
108 
109  if(result == OGRERR_NOT_ENOUGH_DATA)
110  throw te::common::Exception(TE_TR("Error when attempting convert the geometry to OGR. Not enough data."));
111 
112  if(result == OGRERR_UNSUPPORTED_GEOMETRY_TYPE)
113  throw te::common::Exception(TE_TR("Error when attempting convert the geometry to OGR. Unsupported geometry type."));
114 
115  if(result == OGRERR_CORRUPT_DATA)
116  throw te::common::Exception(TE_TR("Error when attempting convert the geometry to OGR. Corrupt data."));
117 
118  return 0;
119 }
120 
122 {
123  return new te::gm::Envelope(env->MinX, env->MinY, env->MaxX, env->MaxY);
124 }
125 
126 OGREnvelope* te::gpkg::Convert2OGR(const te::gm::Envelope* env)
127 {
128  OGREnvelope* envOGR = new OGREnvelope();
129  envOGR->MinX = env->m_llx;
130  envOGR->MinY = env->m_lly;
131  envOGR->MaxX = env->m_urx;
132  envOGR->MaxY = env->m_ury;
133  return envOGR;
134 }
135 
136 int te::gpkg::Convert2TerraLibProjection(OGRSpatialReference* osrs)
137 {
138  if(osrs == 0)
139  return TE_UNKNOWN_SRS;
140 
141  int srid = 0;
142 
143  OGRErr ogrReturn = osrs->AutoIdentifyEPSG();
144  if( ogrReturn == OGRERR_NONE )
145  {
146  const char* srsAuth = osrs->GetAuthorityCode(0);
147 
148  if (srsAuth)
149  {
150  srid = atoi(srsAuth);
151  }
152  }
153 
154  if( srid == TE_UNKNOWN_SRS )
155  {
156  char* wktPtr = 0;
157  ogrReturn = osrs->exportToWkt( &wktPtr );
158 
159  if( ogrReturn == OGRERR_NONE )
160  {
161  std::pair< std::string, unsigned int > customSRID;
162  std::string projRefStr( wktPtr );
163 
164  OGRFree( wktPtr );
165 
166  try
167  {
168  customSRID = te::srs::SpatialReferenceSystemManager::getInstance().getIdFromWkt(
169  projRefStr );
170  srid = (int)customSRID.second;
171  }
172  catch( te::common::Exception& )
173  {
174  }
175  }
176  }
177 
178  if( srid == TE_UNKNOWN_SRS )
179  {
180  char* proj4StrPtr = 0;
181  ogrReturn = osrs->exportToProj4( &proj4StrPtr );
182 
183  if( ogrReturn == OGRERR_NONE )
184  {
185  std::pair< std::string, unsigned int > customSRID;
186  std::string projRefStr( proj4StrPtr );
187 
188  OGRFree( proj4StrPtr );
189 
190  try
191  {
192  customSRID = te::srs::SpatialReferenceSystemManager::getInstance().getIdFromP4Txt(
193  projRefStr );
194  srid = (int)customSRID.second;
195  }
196  catch( te::common::Exception& )
197  {
198  }
199  }
200  }
201 
202  if( srid == TE_UNKNOWN_SRS )
203  {
204  // geographic SIRGAS 2000 Datum
205  std::string straux(osrs->GetRoot()->GetChild(0)->GetValue());
206 
207  if (boost::find_first(straux, "SIRGAS"))
208  {
209  if (osrs->IsGeographic())
210  srid = TE_SRS_SIRGAS2000;
211  }
212  else if (boost::find_first(straux, "UTM "))
213  { // UTM using SIRGAS 2000 Datum
214  double centralm = osrs->GetProjParm(SRS_PP_CENTRAL_MERIDIAN,-1);
215  if (centralm != -1)
216  {
217  int zone = (int)(centralm/6 + 31);
218 
219  double fsnorth = osrs->GetProjParm(SRS_PP_FALSE_NORTHING,-1);
220  if (fsnorth > 0)
221  srid = 31960+zone;
222  else if (fsnorth == 0)
223  srid = 31954+zone;
224  }
225  }
226  }
227 
228  return srid;
229 }
230 
231 OGRSpatialReference* te::gpkg::Convert2OGRProjection(int srid)
232 {
233  std::auto_ptr< OGRSpatialReference > osrs( new OGRSpatialReference() );
234 
235  OGRErr error = osrs->importFromEPSG(srid);
236 
237  if( error != OGRERR_NONE )
238  {
239  try
240  {
241  std::string wktStr =
243 
244  if( !wktStr.empty() )
245  {
246  char* wktStrPtr = (char*)wktStr.c_str();
247  error = osrs->importFromWkt( &wktStrPtr );
248  }
249  }
250  catch( te::common::Exception& )
251  {
252  error = OGRERR_UNSUPPORTED_SRS;
253  }
254  }
255 
256  if( error != OGRERR_NONE )
257  {
258  try
259  {
260  std::string proj4Str =
262 
263  if( !proj4Str.empty() )
264  {
265  char* proj4StrPtr = (char*)proj4Str.c_str();
266  error = osrs->importFromProj4( proj4StrPtr );
267  }
268  }
269  catch( te::common::Exception& )
270  {
271  error = OGRERR_UNSUPPORTED_SRS;
272  }
273  }
274 
275  if(error != OGRERR_NONE)
276  throw(te::common::Exception(TE_TR("Error converting spatial reference system.")));
277 
278  return osrs.release();
279 }
280 
281 void te::gpkg::Convert2TerraLib(OGRFeatureDefn* featDef, te::da::DataSetType* dt, int srs)
282 {
283  assert(dt);
284 
285  int nFields = featDef->GetFieldCount();
286 
287  for(int i = 0; i < nFields; i++)
288  {
289  OGRFieldDefn* fieldDef = featDef->GetFieldDefn(i);
290  te::dt::Property* p = Convert2TerraLib(fieldDef);
291  dt->add(p);
292  }
293 
294  OGRwkbGeometryType ogrGeomType = featDef->GetGeomType();
295 
296  if(ogrGeomType != wkbNone) // has geometry?
297  {
298  te::gm::GeomType geomType = Convert2TerraLib(ogrGeomType);
299  te::gm::GeometryProperty* geomPropertyType = new te::gm::GeometryProperty("OGR_GEOMETRY", srs, geomType);
300  dt->add(geomPropertyType);
301  }
302 }
303 
304 te::da::DataSetType* te::gpkg::Convert2TerraLib(OGRFeatureDefn* featDef, int srs)
305 {
306  te::da::DataSetType* dt = new te::da::DataSetType(featDef->GetName());
307 
308  dt->setTitle(featDef->GetName());
309 
310  te::gpkg::Convert2TerraLib(featDef,dt, srs);
311 
312  return dt;
313 }
314 
316 {
317  OGRFeatureDefn* featDef = new OGRFeatureDefn(dt->getName().c_str());
318  std::vector<te::dt::Property*> props = dt->getProperties();
319 
320  for(unsigned int i = 0; i < props.size(); i++)
321  {
322  te::dt::Property* p = props[i];
323  if(p->getType() != te::dt::GEOMETRY_TYPE)
324  featDef->AddFieldDefn(Convert2OGR(p));
325  }
326 
327  if(dt->hasGeom())
328  {
330  featDef->SetGeomType(Convert2OGR(geom->getGeometryType()));
331  }
332 
333  return featDef;
334 }
335 
337 {
338  te::dt::Property* p = 0;
339  std::string name = fieldDef->GetNameRef();
340  switch(fieldDef->GetType())
341  {
342  case OFTInteger:
344  break;
345 
346  case OFTInteger64:
348  break;
349 
350  case OFTIntegerList:
352  break;
353 
354  case OFTString:
355  {
356  te::dt::StringProperty* sp = 0;
357 
358  if(fieldDef->GetWidth() == 0)
359  sp = new te::dt::StringProperty(name, te::dt::STRING);
360  else
361  sp = new te::dt::StringProperty(name, te::dt::VAR_STRING, fieldDef->GetWidth());
362  p = sp;
363  }
364  break;
365 
366  case OFTStringList:
368  break;
369 
370  case OFTReal:
372  break;
373 
374  case OFTRealList:
376  break;
377 
378  case OFTBinary:
380  break;
381 
382  case OFTDate:
383  p = new te::dt::DateTimeProperty(name, te::dt::DATE);
384  break;
385 
386  case OFTTime:
388  break;
389 
390  case OFTDateTime:
392  break;
393 
394  default:
395  throw(te::common::Exception(TE_TR("Unexpected data type.")));
396  }
397 
398  return p;
399 }
400 
402 {
403  OGRFieldDefn* fieldDef = new OGRFieldDefn(p->getName().c_str(), OFTInteger);
404  switch(p->getType())
405  {
406  case te::dt::INT32_TYPE:
407  return fieldDef;
408  break;
409 
410  case te::dt::ARRAY_TYPE:
411  {
412  te::dt::ArrayProperty* at = static_cast<te::dt::ArrayProperty*>(p);
413  int elementType = at->getElementType()->getType();
414 
415  if(elementType == te::dt::INT32_TYPE)
416  fieldDef->SetType(OFTIntegerList);
417  else if(elementType == te::dt::STRING_TYPE)
418  fieldDef->SetType(OFTStringList);
419  else if(elementType == te::dt::DOUBLE_TYPE)
420  fieldDef->SetType(OFTRealList);
421  else
422  throw(te::common::Exception(TE_TR("Unsupported data type by OGR.")));
423  break;
424  }
425 
426  case te::dt::STRING_TYPE:
427  fieldDef->SetType(OFTString);
428  fieldDef->SetWidth(static_cast<int>(static_cast<te::dt::StringProperty*>(p)->size()));
429  break;
430 
431  case te::dt::DOUBLE_TYPE:
432  fieldDef->SetType(OFTReal);
433  break;
434 
436  fieldDef->SetType(OFTReal);
437  fieldDef->SetPrecision(static_cast<te::dt::NumericProperty*>(p)->getScale());
438  break;
439 
441  fieldDef->SetType(OFTBinary);
442  break;
443 
445  {
446  const te::dt::DateTimeProperty* dp = static_cast<const te::dt::DateTimeProperty*>(p);
447  te::dt::DateTimeType elementType = dp->getSubType();
448  if(elementType == te::dt::DATE)
449  fieldDef->SetType(OFTDate);
450  else if(elementType == te::dt::TIME_DURATION)
451  fieldDef->SetType(OFTTime);
452  else if(elementType == te::dt::TIME_INSTANT)
453  fieldDef->SetType(OFTDateTime);
454  else
455  throw(te::common::Exception(TE_TR("Unsupported data type by OGR.")));
456  break;
457  }
458 
459  default:
460  throw(te::common::Exception(TE_TR("Unsupported data type by OGR.")));
461  }
462 
463  return fieldDef;
464 }
465 
466 te::gm::GeomType te::gpkg::Convert2TerraLib(OGRwkbGeometryType ogrGeomType)
467 {
468  switch(ogrGeomType)
469  {
470  case wkbPoint:
471  return te::gm::MultiPointType;
472 
473  case wkbLineString:
475 
476  case wkbPolygon:
478 
479  case wkbMultiPoint:
480  return te::gm::MultiPointType;
481 
482  case wkbMultiLineString:
484 
485  case wkbMultiPolygon:
487 
488  case wkbGeometryCollection:
490 
491  case wkbLinearRing:
492  return te::gm::LineStringType;
493 
494  case wkbPoint25D:
495  return te::gm::PointMType;
496 
497  case wkbLineString25D:
499 
500  case wkbPolygon25D:
502 
503  case wkbMultiPoint25D:
505 
506  case wkbMultiLineString25D:
508 
509  case wkbMultiPolygon25D:
511 
512  case wkbGeometryCollection25D:
514 
515  case wkbMultiSurface:
517 
518  case wkbUnknown:
519  return te::gm::GeometryType;
520 
521  default:
523  }
524 }
525 
526 OGRwkbGeometryType te::gpkg::Convert2OGR(te::gm::GeomType geomType)
527 {
528  switch(geomType)
529  {
531  return wkbUnknown;
532 
533  case te::gm::PointType:
534  return wkbPoint;
535 
537  return wkbLineString;
538 
539  case te::gm::PolygonType:
540  return wkbPolygon;
541 
543  return wkbMultiPoint;
544 
546  return wkbMultiLineString;
547 
549  return wkbMultiPolygon;
550 
552  return wkbGeometryCollection;
553 
554  case te::gm::PointZType:
555  case te::gm::PointMType:
556  case te::gm::PointZMType:
557  return wkbPoint25D;
558 
562  return wkbLineString25D;
563 
567  return wkbPolygon25D;
568 
572  return wkbMultiPoint25D;
573 
577  return wkbMultiLineString25D;
578 
582  return wkbMultiPolygon25D;
583 
587  return wkbGeometryCollection25D;
588 
593  return wkbMultiPolygon25D;
594 
595  case te::gm::TINType:
596  case te::gm::TINZType:
597  case te::gm::TINMType:
598  case te::gm::TINZMType:
599  return wkbMultiPolygon25D;
600 
605 
606  default:
607  throw(te::common::Exception(TE_TR("Unsupported geometry type by OGR Driver.")));
608  }
609 }
610 
611 std::string te::gpkg::GetDriverName(const std::string& path)
612 {
613  boost::filesystem::path mpath(path.c_str());
614 
615  std::string ext = mpath.extension().string();
616 
617  if(ext == ".shp" || ext == ".SHP")
618  return std::string("ESRI Shapefile");
619 
620  if(ext == ".mif" || ext == ".MIF")
621  return std::string("Mapinfo File");
622 
623  if(ext == ".kml" || ext == ".KML")
624  return std::string("KML");
625 
626  if(ext == ".geojson" || ext == ".GEOJSON")
627  return std::string("GeoJSON");
628 
629  if(ext == ".gml" || ext == ".GML")
630  return std::string("GML");
631 
632  if(ext == ".dxf" || ext == ".DXF")
633  return std::string("DXF");
634 
635  if(ext == ".dgn" || ext == ".DGN")
636  return std::string("DGN");
637 
638  return "";
639 }
640 
641 std::vector<std::string> te::gpkg::GetOGRDrivers(bool filterCreate)
642 {
643  std::vector<std::string> drivernames;
644 
645  int ndrivers = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount();
646 
647  for (int i = 0; i < ndrivers; ++i)
648  {
649  GDALDriver* driver = GetGDALDriverManager()->GetDriver(i);
650  //if (filterCreate && !driver->GetMetadataItem(ODrCCreateDataSource))
651  if (filterCreate && !OGR_Dr_TestCapability(driver, ODrCCreateDataSource))
652  continue;
653  drivernames.push_back(driver->GetDescription());
654  }
655 
656  return drivernames;
657 }
658 
659 std::string te::gpkg::GetOGRConnectionInfo(const std::map<std::string, std::string>& connInfo)
660 {
661  std::map<std::string, std::string>::const_iterator it = connInfo.find("URI");
662 
663  if(it != connInfo.end())
664  return it->second;
665 
666  it = connInfo.find("SOURCE");
667 
668  if(it != connInfo.end())
669  return it->second;
670 
671  throw te::common::Exception(TE_TR("Invalid data source connection information!."));
672 }
673 
674 std::string te::gpkg::RemoveSpatialSql(const std::string& sql)
675 {
676  // Try find AND
677  std::size_t pos = sql.find("AND Intersection");
678 
679  // Try find without AND
680  if(pos == std::string::npos)
681  pos = sql.find("WHERE Intersection");
682 
683  if(pos == std::string::npos)
684  return sql;
685 
686  std::string newQuery;
687 
688  std::size_t pos2 = sql.find("))", pos);
689  newQuery = sql.substr(0, pos);
690  newQuery += sql.substr(pos2 + 2);
691 
692  return newQuery;
693 }
694 
695 void te::gpkg::createGeopackage(std::string outFileName)
696 {
697  const char *gpkgFormat = "GPKG";
698 
699  GDALDriver *gpkgDriver;
700 
701  gpkgDriver = GetGDALDriverManager()->GetDriverByName(gpkgFormat);
702 
703  char **papszOptions = NULL;
704 
705  GDALDataset *poDstDS;
706  poDstDS = gpkgDriver->Create(outFileName.c_str(), 0, 0, 0, GDT_Unknown, papszOptions);
707  GDALClose((GDALDatasetH)poDstDS);
708 }
709 
710 void te::gpkg::copyToGeopackage(te::rst::Raster* raster, std::string outFileName)
711 {
712  te::gdal::Raster* gdalRaster = dynamic_cast<te::gdal::Raster*>(raster);
713 
714  const char *gpkgFormat = "GPKG";
715  GDALDriver *gpkgDriver;
716  gpkgDriver = GetGDALDriverManager()->GetDriverByName(gpkgFormat);
717 
718  char **papszOptions = NULL;
719  papszOptions = CSLSetNameValue(papszOptions, "APPEND_SUBDATASET", "YES");
720  papszOptions = CSLSetNameValue(papszOptions, "TILING_SCHEME", "GoogleMapsCompatible");
721  papszOptions = CSLSetNameValue(papszOptions, "ZOOM_LEVEL_STRATEGY", "LOWER");
722 
723  GDALDataset *poDstDS = gpkgDriver->CreateCopy(outFileName.c_str(), gdalRaster->getGDALDataset(), FALSE, papszOptions, NULL, NULL);;
724 
725  unsigned int levels = gdalRaster->getMultiResLevelsCount();
726  if (levels > 0)
727  {
728  boost::scoped_array< int > overviewsIndexes(new int[levels]);
729 
730  for (unsigned int overViewIdx = 1; overViewIdx <= levels; ++overViewIdx)
731  {
732  /*
733  Power of two overview factors(2, 4, 8, 16, ...) should be favored to be conformant
734  with the baseline GeoPackage specification as mentioned in gdal documentation.
735  */
736  unsigned int index = (unsigned int)std::pow(2, overViewIdx);
737  overviewsIndexes[(overViewIdx - 1)] = index;
738  }
739 
740  CPLErr returnValue = poDstDS->BuildOverviews("NEAREST", (int)levels, overviewsIndexes.get(), 0, NULL, NULL, NULL);
741  poDstDS->FlushCache();
742  }
743 
744  CSLDestroy(papszOptions);
745  GDALClose((GDALDatasetH)poDstDS);
746 }
GDALDataset * getGDALDataset() const
Returns the raster GDAL handler.
void setTitle(const std::string &title)
It sets a human descriptive title for the DataSetType.
Definition: DataSetType.h:137
TERRAMOBILEPLUGINSDLLEXPORT void copyToGeopackage(te::rst::Raster *raster, std::string outFileName)
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
This class represents Raster data.
A class that models the description of a dataset.
Definition: DataSetType.h:72
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
std::size_t getWkbSize() const _NOEXCEPT_OP(true)
It returns the size required by a WKB representation for this geometric object.
It models a property definition.
Definition: Property.h:59
TERRAMOBILEPLUGINSDLLEXPORT std::vector< std::string > GetOGRDrivers(bool filterCreate=false)
It returns the list of OGR Drivers available.
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.
An abstract class for raster data strucutures.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
static te::dt::TimeDuration dt(20, 30, 50, 11)
TERRAMOBILEPLUGINSDLLEXPORT std::string GetOGRConnectionInfo(const std::map< std::string, std::string > &connInfo)
unsigned int getMultiResLevelsCount() const
Returns the current number of multi-resolution pyramid levels.
TERRAMOBILEPLUGINSDLLEXPORT OGRGeometry * Convert2OGR(const te::gm::Geometry *teGeom)
It converts the TerraLib Geometry to OGR Geometry.
te::gm::Polygon * p
TERRAMOBILEPLUGINSDLLEXPORT std::string RemoveSpatialSql(const std::string &sql)
TERRAMOBILEPLUGINSDLLEXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry.
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.
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.
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.
std::string GetDriverName(const std::string &path)
It tries extract the driver name used by OGR Library based on the given path.
DateTimeType
The subtype of date and time type, based on ISO 8621.
TERRAMOBILEPLUGINSDLLEXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection.
TERRAMOBILEPLUGINSDLLEXPORT OGRSpatialReference * Convert2OGRProjection(int srid)
It converts the TerraLib Projection to OGR Projection.
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)
TEOGREXPORT OGRSpatialReference * Convert2OGRProjection(int srid)
It converts the TerraLib Projection to OGR Projection.
TERRAMOBILEPLUGINSDLLEXPORT void createGeopackage(std::string outFileName)
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