20 #ifndef _IMGWRITEROGR_H_ 21 #define _IMGWRITEROGR_H_ 29 #include "ogrsf_frmts.h" 30 #include "ImgReaderGdal.h" 31 #include "ImgWriterGdal.h" 32 #include "ImgReaderOgr.h" 39 ImgWriterOgr(
const std::string& filename,
const std::string& imageType=
"ESRI Shapefile");
43 void open(
const std::string& filename,
ImgReaderOgr& imgReaderOgr);
44 void open(
const std::string& filename,
const std::string& imageType=
"ESRI Shapefile");
46 int ascii2ogr(
const std::string& filename,
const std::string &layername,
const std::vector<std::string>& fieldName,
const std::vector<OGRFieldType>& fieldType,
short colX=1,
short colY=2,
const std::string& theProjection=
"",
const OGRwkbGeometryType& eGType=wkbPoint,
const char fs=
' ');
47 OGRLayer* createLayer(
const std::string& layername=
"New layer",
const std::string& theProjection=
"",
const OGRwkbGeometryType& eGType=wkbUnknown,
char** papszOptions=NULL);
48 OGRLayer* copyLayer(OGRLayer* poSrcLayer,
const std::string& layername,
char** papszOptions=NULL);
49 void createField(
const std::string& fieldname,
const OGRFieldType& fieldType,
int theLayer=0);
50 OGRLayer* getLayer(
int layer=0)
const {
return m_datasource->GetLayer(layer);};
51 std::string getLayerName(
int layer=0){
return m_datasource->GetLayer(layer)->GetLayerDefn()->GetName();};
52 int getFields(std::vector<std::string>& fields,
int layer=0)
const;
53 int getFields(std::vector<OGRFieldDefn*>& fields,
int layer=0)
const;
54 void copyFields(
const ImgReaderOgr& imgReaderOgr,
int srcLayer=0,
int targetLayer=0);
55 void addLineString(std::vector<OGRPoint*>& points,
const std::string& fieldName,
const std::string& theId,
int layer=0);
56 void addRing(std::vector<OGRPoint*>& points,
const std::string& fieldName,
int theId,
int layer=0);
57 void addLineString(std::vector<OGRPoint*>& points,
const std::string& fieldName,
int theId,
int layer=0);
58 void addPoint(
double x,
double y,
const std::map<std::string,double>& pointAttributes, std::string fieldName,
const std::string& theId,
int layer=0);
59 void addPoint(
double x,
double y,
const std::map<std::string,double>& pointAttributes, std::string fieldName,
int theId,
int layer=0);
60 int addData(
ImgReaderGdal& imgReader,
int layer=0,
bool verbose=
false);
61 OGRFeature* createFeature(
int layer=0);
62 OGRErr createFeature(OGRFeature* theFeature,
int layer=0);
63 int getFieldCount(
int layer=0)
const;
64 int getFeatureCount(
int layer=0)
const;
65 #if GDAL_VERSION_MAJOR < 2 66 OGRDataSource* getDataSource(
void) {
return m_datasource;};
67 OGRSFDriver* getDriver(
void)
const {
return m_datasource->GetDriver();};
69 GDALDataset* getDataSource(
void) {
return m_datasource;};
70 GDALDriver* getDriver(
void)
const {
return m_datasource->GetDriver();};
74 void setCodec(
const std::string& imageType);
75 #if GDAL_VERSION_MAJOR < 2 76 void setCodec(OGRSFDriver *poDriver);
78 void setCodec(GDALDriver *poDriver);
83 std::string m_filename;
84 #if GDAL_VERSION_MAJOR < 2 85 OGRDataSource *m_datasource;
87 GDALDataset *m_datasource;
92 #endif // _IMGWRITEROGR_H_