27 #include "../common/Exception.h" 
   28 #include "../common/Globals.h" 
   29 #include "../common/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/Config.h" 
   47 #include <ogrsf_frmts.h> 
   48 #include <ogr_spatialref.h> 
   51 #include <boost/algorithm/string.hpp> 
   52 #include <boost/filesystem.hpp> 
   56   int wkbSize = ogrGeom->WkbSize();
 
   58   unsigned char* wkbArray = 
new unsigned char[wkbSize];
 
   60   ogrGeom->exportToWkb(wkbNDR, wkbArray);
 
   83   char* wkbArray = 
new char[size];
 
   89   OGRGeometry* ogrGeom = 0;
 
   91   OGRErr result = OGRGeometryFactory::createFromWkb((
unsigned char*)wkbArray, srs, &ogrGeom, static_cast<int>(size));
 
   95   if(result == OGRERR_NONE)
 
   98   if(result == OGRERR_NOT_ENOUGH_DATA)
 
  101   if(result == OGRERR_UNSUPPORTED_GEOMETRY_TYPE)
 
  104   if(result == OGRERR_CORRUPT_DATA)
 
  117   OGREnvelope* envOGR = 
new OGREnvelope();
 
  118   envOGR->MinX = env->
m_llx;
 
  119   envOGR->MinY = env->
m_lly;
 
  120   envOGR->MaxX = env->
m_urx;
 
  121   envOGR->MaxY = env->
m_ury;
 
  130   if(osrs->AutoIdentifyEPSG() != OGRERR_UNSUPPORTED_SRS) 
 
  131     return atoi(osrs->GetAuthorityCode(0));
 
  134   std::string straux(osrs->GetRoot()->GetChild(0)->GetValue());
 
  136   if (!boost::find_first(straux, 
"SIRGAS"))
 
  139   if (osrs->IsGeographic())
 
  143   if (boost::find_first(straux, 
"UTM "))
 
  145     double centralm = osrs->GetProjParm(SRS_PP_CENTRAL_MERIDIAN,-1);
 
  148     int zone = (int)(centralm/6 + 31);
 
  150     double fsnorth = osrs->GetProjParm(SRS_PP_FALSE_NORTHING,-1);
 
  153     else if (fsnorth == 0)
 
  161   OGRSpatialReference* osrs = 
new OGRSpatialReference();
 
  163   OGRErr error = osrs->importFromEPSG(srid);
 
  165   if(error != OGRERR_NONE)
 
  175   int nFields = featDef->GetFieldCount();
 
  177   for(
int i = 0; i < nFields; i++)
 
  179     OGRFieldDefn* fieldDef = featDef->GetFieldDefn(i); 
 
  184   OGRwkbGeometryType ogrGeomType = featDef->GetGeomType();
 
  186   if(ogrGeomType != wkbNone) 
 
  190     dt->
add(geomPropertyType);
 
  207   OGRFeatureDefn* featDef = 
new OGRFeatureDefn(dt->
getName().c_str());
 
  210   for(
unsigned int i = 0; i < props.size(); i++)
 
  229   std::string name = fieldDef->GetNameRef();
 
  230   switch(fieldDef->GetType())
 
  241       if(fieldDef->GetWidth() == 0)
 
  284   OGRFieldDefn* fieldDef = 
new OGRFieldDefn(p->
getName().c_str(), OFTInteger);
 
  297         fieldDef->SetType(OFTIntegerList);
 
  299         fieldDef->SetType(OFTStringList);
 
  301         fieldDef->SetType(OFTRealList);
 
  308       fieldDef->SetType(OFTString);
 
  309       fieldDef->SetWidth(static_cast<int>(static_cast<te::dt::StringProperty*>(p)->size()));
 
  313       fieldDef->SetType(OFTReal);
 
  317       fieldDef->SetType(OFTReal);
 
  318       fieldDef->SetPrecision(static_cast<te::dt::NumericProperty*>(p)->getScale());
 
  322       fieldDef->SetType(OFTBinary);
 
  330         fieldDef->SetType(OFTDate);
 
  332         fieldDef->SetType(OFTTime);
 
  334         fieldDef->SetType(OFTDateTime);
 
  363     case wkbMultiLineString:
 
  366     case wkbMultiPolygon:
 
  369     case wkbGeometryCollection:
 
  378     case wkbLineString25D:
 
  384     case wkbMultiPoint25D:
 
  387     case wkbMultiLineString25D:
 
  390     case wkbMultiPolygon25D:
 
  393     case wkbGeometryCollection25D:
 
  415       return wkbLineString;
 
  421       return wkbMultiPoint;
 
  424       return wkbMultiLineString;
 
  427       return wkbMultiPolygon;
 
  430       return wkbGeometryCollection;
 
  436       return wkbLineString25D;
 
  439       return  wkbPolygon25D;
 
  442       return wkbMultiPoint25D;
 
  445       return wkbMultiLineString25D;
 
  448       return wkbMultiPolygon25D;
 
  451       return wkbGeometryCollection25D;
 
  460   boost::filesystem::path mpath(path.c_str());
 
  462   std::string ext = mpath.extension().string();
 
  464   if(ext == 
".shp" || ext == 
".SHP")
 
  465     return std::string(
"ESRI Shapefile");
 
  467   if(ext == 
".mif" || ext == 
".MIF")
 
  468     return std::string(
"Mapinfo File");
 
  470   if(ext == 
".kml" || ext == 
".KML")
 
  471     return std::string(
"KML");
 
  473   if(ext == 
".geojson" || ext == 
".GEOJSON")
 
  474     return std::string(
"GeoJSON");
 
  476   if(ext == 
".gml" || ext == 
".GML")
 
  477     return std::string(
"GML");
 
  479   if(ext == 
".dxf" || ext == 
".DXF")
 
  480     return std::string(
"DXF");
 
  482   if(ext == 
".dgn" || ext == 
".DGN")
 
  483     return std::string(
"DGN");
 
  491   std::vector<std::string> drivernames;
 
  493   int ndrivers = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount();
 
  495   for (
int i = 0; i < ndrivers; ++i)
 
  497     OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i);
 
  498     if (filterCreate && !driver->TestCapability(ODrCCreateDataSource))
 
  500     drivernames.push_back(driver->GetName());
 
  508   std::map<std::string, std::string>::const_iterator it = connInfo.find(
"URI");
 
  510   if(it != connInfo.end())
 
  513   it = connInfo.find(
"SOURCE");
 
  515   if(it != connInfo.end())
 
TEOGREXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection. 
 
The type for variable-length multidimensional arrays. 
 
int getSRID() const 
It returns the Spatial Reference System ID associated to this geometric object. 
 
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
 
An atomic property like an integer or double. 
 
std::size_t getWkbSize() const 
It returns the size required by a WKB representation for this geometric object. 
 
void getWkb(char *wkb, te::common::MachineByteOrder byteOrder) const 
It serializes the geometry to a WKB representation into the specified buffer. 
 
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
 
std::string GetDriverName(const std::string &path)
It tries extract the driver name used by OGR Library based on the given path. 
 
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. 
 
The type for string types: FIXED_STRING, VAR_STRING or STRING. 
 
DateTimeType getSubType() const 
It returns the date time property sub type. 
 
const std::string & getName() const 
It returns the property name. 
 
void add(Constraint *c)
It adds a new constraint. 
 
static Geometry * read(const char *wkb)
It returns a valid geometry from a given WKB. 
 
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib. 
 
Property * getElementType() const 
It returns the type of array elements. 
 
TEOGREXPORT std::vector< std::string > GetOGRDrivers(bool filterCreate=false)
It returns the list of OGR Drivers available. 
 
GeomType getGeometryType() const 
It returns the geometry subtype allowed for the property. 
 
double m_lly
Lower left corner y-coordinate. 
 
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian). 
 
Utility functions for the data access module. 
 
TEOGREXPORT OGRGeometry * Convert2OGR(const te::gm::Geometry *teGeom)
It converts the TerraLib Geometry to OGR Geometry. 
 
bool hasGeom() const 
It returns true if the DataSetType has at least one geometry property; otherwise, it returns false...
 
double m_ury
Upper right corner y-coordinate. 
 
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards. 
 
const std::vector< Property * > & getProperties() const 
It returns the list of properties describing the CompositeProperty. 
 
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code. 
 
#define TR_OGR(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
 
double m_urx
Upper right corner x-coordinate. 
 
#define TE_SRS_SIRGAS2000
 
DateTimeType
The subtype of date and time type. 
 
A class that models the description of a dataset. 
 
TEOGREXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry. 
 
It models a property definition. 
 
double m_llx
Lower left corner x-coordinate. 
 
TEOGREXPORT std::string GetOGRConnectionInfo(const std::map< std::string, std::string > &connInfo)
 
int getType() const 
It returns the property data type. 
 
void setTitle(const std::string &title)
It sets a human descriptive title for the DataSetType. 
 
TEOGREXPORT OGRSpatialReference * Convert2OGRProjection(int srid)
It converts the TerraLib Projection to OGR Projection. 
 
An Envelope defines a 2D rectangular region.