| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef _VECTOROGR_H_ |
| 22 |
#define _VECTOROGR_H_ |
| 23 |
|
| 24 |
#include <iostream> |
| 25 |
#include <fstream> |
| 26 |
#include <sstream> |
| 27 |
#include <memory> |
| 28 |
#include "algorithms/ConfusionMatrix.h" |
| 29 |
#include "algorithms/StatFactory.h" |
| 30 |
#include "apps/AppFactory.h" |
| 31 |
#include "ogr_feature.h" |
| 32 |
#include "ogrsf_frmts.h" |
| 33 |
#include "imageclasses/Jim.h" |
| 34 |
#include "cpl_string.h" |
| 35 |
|
| 36 |
|
| 37 |
enum JOIN_METHOD { INNER = 0, OUTER_LEFT = 1, OUTER_RIGHT = 2, OUTER_FULL = 3}; |
| 38 |
|
| 39 |
class Jim; |
| 40 |
class VectorOgr : public std::enable_shared_from_this<VectorOgr> |
| 41 |
{ |
| 42 |
public: |
| 43 |
|
| 44 |
VectorOgr(void); |
| 45 |
|
| 46 |
VectorOgr(const std::string& filename, const std::vector<std::string>& layernames=std::vector<std::string>(), bool noread=false, const std::vector<std::string>& ooptions=std::vector<std::string>()){ |
| 47 |
open(filename,layernames,noread,ooptions); |
| 48 |
} |
| 49 |
|
| 50 |
VectorOgr(app::AppFactory &app) : m_gds(NULL), m_access(GDAL_OF_READONLY){m_filename.clear();open(app);} |
| 51 |
|
| 52 |
VectorOgr(VectorOgr& other, app::AppFactory &app); |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
~VectorOgr(void); |
| 57 |
|
| 58 |
OGRErr copy(VectorOgr& other, app::AppFactory &app); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
static std::shared_ptr<VectorOgr> createVector() { |
| 67 |
return(std::make_shared<VectorOgr>()); |
| 68 |
}; |
| 69 |
static std::shared_ptr<VectorOgr> createVector(const std::string& filename, const std::vector<std::string>& layernames=std::vector<std::string>()) { |
| 70 |
std::shared_ptr<VectorOgr> pVector=std::make_shared<VectorOgr>(filename,layernames); |
| 71 |
return(pVector); |
| 72 |
}; |
| 73 |
static std::shared_ptr<VectorOgr> createVector(app::AppFactory &app){ |
| 74 |
std::shared_ptr<VectorOgr> pVector=std::make_shared<VectorOgr>(app); |
| 75 |
return(pVector); |
| 76 |
}; |
| 77 |
static std::shared_ptr<VectorOgr> createVector(VectorOgr& other,app::AppFactory &app){ |
| 78 |
std::shared_ptr<VectorOgr> pVector=std::make_shared<VectorOgr>(other,app); |
| 79 |
return(pVector); |
| 80 |
}; |
| 81 |
static OGRwkbGeometryType string2geotype(const std::string &typeString){ |
| 82 |
|
| 83 |
std::map<std::string,OGRwkbGeometryType> typeMap; |
| 84 |
typeMap["wkbUnknown"] = wkbUnknown; |
| 85 |
typeMap["wkbPoint"] = wkbPoint; |
| 86 |
typeMap["wkbLineString"] = wkbLineString; |
| 87 |
typeMap["wkbPolygon"] = wkbPolygon; |
| 88 |
typeMap["wkbMultiPoint"] = wkbMultiPoint; |
| 89 |
typeMap["wkbMultiLineString"] = wkbMultiLineString; |
| 90 |
typeMap["wkbMultiPolygon"] = wkbMultiPolygon; |
| 91 |
typeMap["wkbGeometryCollection"] = wkbGeometryCollection; |
| 92 |
typeMap["wkbCircularString"] = wkbCircularString; |
| 93 |
typeMap["wkbCompoundCurve"] = wkbCompoundCurve; |
| 94 |
typeMap["wkbCurvePolygon"] = wkbCurvePolygon; |
| 95 |
typeMap["wkbMultiCurve"] = wkbMultiCurve; |
| 96 |
typeMap["wkbMultiSurface"] = wkbMultiSurface; |
| 97 |
typeMap["wkbCurve"] = wkbCurve; |
| 98 |
typeMap["wkbSurface"] = wkbSurface; |
| 99 |
typeMap["wkbPolyhedralSurface"] = wkbPolyhedralSurface; |
| 100 |
typeMap["wkbTIN"] = wkbTIN; |
| 101 |
typeMap["wkbTriangle"] = wkbTriangle; |
| 102 |
typeMap["wkbNone"] = wkbNone; |
| 103 |
typeMap["wkbLinearRing"] = wkbLinearRing; |
| 104 |
typeMap["wkbCircularStringZ"] = wkbCircularStringZ; |
| 105 |
typeMap["wkbCompoundCurveZ"] = wkbCompoundCurveZ; |
| 106 |
typeMap["wkbCurvePolygonZ"] = wkbCurvePolygonZ; |
| 107 |
typeMap["wkbMultiCurveZ"] = wkbMultiCurveZ; |
| 108 |
typeMap["wkbMultiSurfaceZ"] = wkbMultiSurfaceZ; |
| 109 |
typeMap["wkbCurveZ"] = wkbCurveZ; |
| 110 |
typeMap["wkbSurfaceZ"] = wkbSurfaceZ; |
| 111 |
typeMap["wkbPolyhedralSurfaceZ"] = wkbPolyhedralSurfaceZ; |
| 112 |
typeMap["wkbTINZ"] = wkbTINZ; |
| 113 |
typeMap["wkbTriangleZ"] = wkbTriangleZ; |
| 114 |
typeMap["wkbPointM"] = wkbPointM; |
| 115 |
typeMap["wkbLineStringM"] = wkbLineStringM; |
| 116 |
typeMap["wkbPolygonM"] = wkbPolygonM; |
| 117 |
typeMap["wkbMultiPointM"] = wkbMultiPointM; |
| 118 |
typeMap["wkbMultiLineStringM"] = wkbMultiLineStringM; |
| 119 |
typeMap["wkbMultiPolygonM"] = wkbMultiPolygonM; |
| 120 |
typeMap["wkbGeometryCollectionM"] = wkbGeometryCollectionM; |
| 121 |
typeMap["wkbCircularStringM"] = wkbCircularStringM; |
| 122 |
typeMap["wkbCompoundCurveM"] = wkbCompoundCurveM; |
| 123 |
typeMap["wkbCurvePolygonM"] = wkbCurvePolygonM; |
| 124 |
typeMap["wkbMultiCurveM"] = wkbMultiCurveM; |
| 125 |
typeMap["wkbMultiSurfaceM"] = wkbMultiSurfaceM; |
| 126 |
typeMap["wkbCurveM"] = wkbCurveM; |
| 127 |
typeMap["wkbSurfaceM"] = wkbSurfaceM; |
| 128 |
typeMap["wkbPolyhedralSurfaceM"] = wkbPolyhedralSurfaceM; |
| 129 |
typeMap["wkbTINM"] = wkbTINM; |
| 130 |
typeMap["wkbTriangleM"] = wkbTriangleM; |
| 131 |
typeMap["wkbPointZM"] = wkbPointZM; |
| 132 |
typeMap["wkbLineStringZM"] = wkbLineStringZM; |
| 133 |
typeMap["wkbPolygonZM"] = wkbPolygonZM; |
| 134 |
typeMap["wkbMultiPointZM"] = wkbMultiPointZM; |
| 135 |
typeMap["wkbMultiLineStringZM"] = wkbMultiLineStringZM; |
| 136 |
typeMap["wkbMultiPolygonZM"] = wkbMultiPolygonZM; |
| 137 |
typeMap["wkbGeometryCollectionZM"] = wkbGeometryCollectionZM; |
| 138 |
typeMap["wkbCircularStringZM"] = wkbCircularStringZM; |
| 139 |
typeMap["wkbCompoundCurveZM"] = wkbCompoundCurveZM; |
| 140 |
typeMap["wkbCurvePolygonZM"] = wkbCurvePolygonZM; |
| 141 |
typeMap["wkbMultiCurveZM"] = wkbMultiCurveZM; |
| 142 |
typeMap["wkbMultiSurfaceZM"] = wkbMultiSurfaceZM; |
| 143 |
typeMap["wkbCurveZM"] = wkbCurveZM; |
| 144 |
typeMap["wkbSurfaceZM"] = wkbSurfaceZM; |
| 145 |
typeMap["wkbPolyhedralSurfaceZM"] = wkbPolyhedralSurfaceZM; |
| 146 |
typeMap["wkbTINZM"] = wkbTINZM; |
| 147 |
typeMap["wkbTriangleZM"] = wkbTriangleZM; |
| 148 |
typeMap["wkbPoint25D"] = wkbPoint25D; |
| 149 |
typeMap["wkbLineString25D"] = wkbLineString25D; |
| 150 |
typeMap["wkbPolygon25D"] = wkbPolygon25D; |
| 151 |
typeMap["wkbMultiPoint25D"] = wkbMultiPoint25D; |
| 152 |
typeMap["wkbMultiLineString25D"] = wkbMultiLineString25D; |
| 153 |
typeMap["wkbMultiPolygon25D"] = wkbMultiPolygon25D; |
| 154 |
typeMap["wkbGeometryCollection25D"] = wkbGeometryCollection25D; |
| 155 |
if(typeMap.count(typeString)) |
| 156 |
return(typeMap[typeString]); |
| 157 |
else |
| 158 |
return(wkbUnknown); |
| 159 |
} |
| 160 |
|
| 161 |
static JOIN_METHOD string2method(const std::string &method){ |
| 162 |
|
| 163 |
std::map<std::string,JOIN_METHOD> methodMap; |
| 164 |
methodMap["INNER"] = INNER; |
| 165 |
methodMap["inner"] = INNER; |
| 166 |
methodMap["OUTER_LEFT"] = OUTER_LEFT; |
| 167 |
methodMap["outer_left"] = OUTER_LEFT; |
| 168 |
methodMap["OUTER_RIGHT"] = OUTER_RIGHT; |
| 169 |
methodMap["outer_right"] = OUTER_RIGHT; |
| 170 |
methodMap["OUTER_FULL"] = OUTER_FULL; |
| 171 |
methodMap["outer_full"] = OUTER_FULL; |
| 172 |
if(methodMap.count(method)) |
| 173 |
return(methodMap[method]); |
| 174 |
else |
| 175 |
return(INNER); |
| 176 |
} |
| 177 |
|
| 178 |
void destroyAll(); |
| 179 |
void destroyEmptyFeatures(size_t ilayer=0); |
| 180 |
bool isEmpty(size_t ilayer=0); |
| 181 |
void destroyFeatures(size_t ilayer=0); |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
OGRErr open(const std::string& filename, const std::string& imageType, unsigned int access=GDAL_OF_UPDATE); |
| 186 |
|
| 187 |
OGRErr open(const std::string& filename, const std::vector<std::string>& layernames=std::vector<std::string>(), bool noread=false, const std::vector<std::string>& ooptions=std::vector<std::string>()); |
| 188 |
|
| 189 |
OGRErr open(const std::string& filename, const std::vector<std::string>& layernames, const std::string& imageType, const OGRwkbGeometryType& geometryType, OGRSpatialReference* theSRS=NULL, char** options=NULL); |
| 190 |
|
| 191 |
OGRErr open(const std::string& filename, const std::vector<std::string>& layernames, const std::string& imageType, const OGRwkbGeometryType& geometryType, const std::string& theProjection, char** options=NULL); |
| 192 |
|
| 193 |
OGRErr open(const std::string& filename, const std::vector<std::string>& layernames, const std::string& imageType, const std::string& geometryType=std::string(), const std::string& theProjection=std::string(), char** options=NULL); |
| 194 |
|
| 195 |
OGRErr open(app::AppFactory& app); |
| 196 |
|
| 197 |
void setCodec(const std::string& filename, const std::string& imageType); |
| 198 |
|
| 199 |
void close(void); |
| 200 |
|
| 201 |
std::string getProjection(size_t ilayer=0) const; |
| 202 |
|
| 203 |
const OGRSpatialReference getSpatialRef(size_t ilayer=0) const{ |
| 204 |
OGRSpatialReference thisSpatialRef(getProjection(ilayer).c_str()); |
| 205 |
return thisSpatialRef; |
| 206 |
} |
| 207 |
|
| 208 |
std::string getFileName() const {return m_filename;}; |
| 209 |
|
| 210 |
OGRErr pushLayer(const std::string& layername, const OGRSpatialReference* theSRS, const OGRwkbGeometryType& geometryType=wkbUnknown, char** papszOptions=NULL); |
| 211 |
|
| 212 |
OGRErr pushLayer(const std::string& layername, const std::string& theProjection=std::string(), const OGRwkbGeometryType& geometryType=wkbUnknown, char** papszOptions=NULL); |
| 213 |
|
| 214 |
OGRErr pushLayer(const std::string& layername, const std::string& theProjection, const std::string& geometryType, char** papszOptions=NULL); |
| 215 |
|
| 216 |
|
| 217 |
std::shared_ptr<VectorOgr> intersect(OGRPolygon *pGeom, app::AppFactory& app); |
| 218 |
std::shared_ptr<VectorOgr> intersect(const Jim& aJim, app::AppFactory& app); |
| 219 |
OGRErr intersect(OGRPolygon *pGeom, VectorOgr& ogrWriter, app::AppFactory& app); |
| 220 |
OGRErr intersect(const Jim& aJim, VectorOgr& ogrWriter, app::AppFactory& app); |
| 221 |
std::shared_ptr<VectorOgr> convexHull(app::AppFactory& app); |
| 222 |
OGRErr convexHull(VectorOgr& ogrWriter, app::AppFactory& app); |
| 223 |
|
| 224 |
unsigned int getAccess(){return m_access;}; |
| 225 |
|
| 226 |
OGRErr setAccess(unsigned int theAccess){m_access=theAccess; return(OGRERR_NONE);}; |
| 227 |
|
| 228 |
OGRErr setAccess(std::string accessString){ |
| 229 |
if(accessString=="GDAL_OF_READONLY"){ |
| 230 |
m_access=GDAL_OF_READONLY; |
| 231 |
} |
| 232 |
if(accessString=="GDAL_OF_UPDATE"){ |
| 233 |
m_access=GDAL_OF_UPDATE; |
| 234 |
} |
| 235 |
return(OGRERR_NONE); |
| 236 |
} |
| 237 |
|
| 238 |
size_t getGDSLayerCount() const { |
| 239 |
if(m_gds) |
| 240 |
return(m_gds->GetLayerCount()); |
| 241 |
else |
| 242 |
return(0); |
| 243 |
}; |
| 244 |
size_t getLayerCount() const { |
| 245 |
return(m_layer.size()); |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
}; |
| 251 |
std::string getLayerName(size_t ilayer=0) const {if(getLayer(ilayer)) return(getLayer(ilayer)->GetName());else return(std::string());}; |
| 252 |
#if GDAL_VERSION_MAJOR < 2 |
| 253 |
|
| 254 |
OGRDataSource* getDataset(){return m_gds;}; |
| 255 |
#else |
| 256 |
|
| 257 |
GDALDataset* getDataset(){return m_gds;}; |
| 258 |
#endif |
| 259 |
|
| 260 |
OGRLayer* getLayer(size_t ilayer=0) {if(m_layer.size()>ilayer) return(m_layer[ilayer]);else return(0);}; |
| 261 |
|
| 262 |
OGRLayer* getLayer(size_t ilayer=0) const {if(m_layer.size()>ilayer) return(m_layer[ilayer]);else return(0);}; |
| 263 |
|
| 264 |
OGRLayer* getLayer(std::string layername) { |
| 265 |
for(size_t ilayer=0;ilayer<getGDSLayerCount();++ilayer){ |
| 266 |
std::string currentLayername=getLayer(ilayer)->GetName(); |
| 267 |
if(currentLayername==layername) |
| 268 |
return(m_layer[ilayer]); |
| 269 |
else |
| 270 |
continue; |
| 271 |
} |
| 272 |
return(0); |
| 273 |
} |
| 274 |
|
| 275 |
OGRLayer* getLayer(std::string layername) const { |
| 276 |
for(size_t ilayer=0;ilayer<getGDSLayerCount();++ilayer){ |
| 277 |
std::string currentLayername=getLayer(ilayer)->GetName(); |
| 278 |
if(currentLayername==layername) |
| 279 |
return(m_layer[ilayer]); |
| 280 |
else |
| 281 |
continue; |
| 282 |
} |
| 283 |
return(0); |
| 284 |
} |
| 285 |
|
| 286 |
std::vector<OGRLayer*> getLayers(const std::vector<std::string>& layernames=std::vector<std::string>()){ |
| 287 |
if(layernames.size()){ |
| 288 |
std::vector<OGRLayer*> layers; |
| 289 |
for(size_t ilayer=0;ilayer<getGDSLayerCount();++ilayer){ |
| 290 |
std::string currentLayername=getLayer(ilayer)->GetName(); |
| 291 |
std::vector<std::string>::const_iterator it=find(layernames.begin(),layernames.end(),currentLayername); |
| 292 |
if(it==layernames.end()) |
| 293 |
continue; |
| 294 |
else |
| 295 |
layers.push_back(getLayer(ilayer)); |
| 296 |
} |
| 297 |
return(layers); |
| 298 |
} |
| 299 |
else |
| 300 |
return(m_layer); |
| 301 |
}; |
| 302 |
|
| 303 |
std::vector<OGRLayer*> getLayers(const std::vector<std::string>& layernames=std::vector<std::string>()) const { |
| 304 |
if(layernames.size()){ |
| 305 |
std::vector<OGRLayer*> layers; |
| 306 |
for(size_t ilayer=0;ilayer<getGDSLayerCount();++ilayer){ |
| 307 |
std::string currentLayername=getLayer(ilayer)->GetName(); |
| 308 |
std::vector<std::string>::const_iterator it=find(layernames.begin(),layernames.end(),currentLayername); |
| 309 |
if(it==layernames.end()) |
| 310 |
continue; |
| 311 |
else |
| 312 |
layers.push_back(getLayer(ilayer)); |
| 313 |
} |
| 314 |
return(layers); |
| 315 |
} |
| 316 |
else |
| 317 |
return(m_layer); |
| 318 |
}; |
| 319 |
|
| 320 |
OGRwkbGeometryType getGeometryType(size_t ilayer=0) {return(m_layer[ilayer]->GetGeomType());}; |
| 321 |
|
| 322 |
size_t getFeatureCount() const { |
| 323 |
size_t nfeatures=0; |
| 324 |
for(size_t ilayer=0;ilayer<getLayerCount();++ilayer) |
| 325 |
nfeatures+=getFeatureCount(ilayer); |
| 326 |
return(nfeatures); |
| 327 |
}; |
| 328 |
|
| 329 |
size_t getFeatureCount(size_t ilayer) const { |
| 330 |
if(m_features.size()<=ilayer){ |
| 331 |
std::ostringstream errorStream; |
| 332 |
errorStream << "Error: m_features not initialized for layer " << ilayer << std::endl; |
| 333 |
std::cerr << errorStream.str() << std::endl; |
| 334 |
throw(errorStream.str()); |
| 335 |
} |
| 336 |
return(m_features[ilayer].size()); |
| 337 |
}; |
| 338 |
|
| 339 |
OGRErr createField(const std::string& fieldname, const OGRFieldType& fieldType,size_t ilayer=0); |
| 340 |
|
| 341 |
OGRErr createField(OGRFieldDefn* poField,size_t ilayer=0); |
| 342 |
|
| 343 |
OGRErr copyFields(const VectorOgr& vectorOgr,const std::vector<std::string>& fieldnames=std::vector<std::string>(),size_t fromLayer=0, size_t toLayer=0); |
| 344 |
|
| 345 |
OGRErr write(const std::string& filename=std::string()); |
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
bool getExtent(double& ulx, double& uly, double& lrx, double& lry, OGRCoordinateTransformation *poCT=0) const; |
| 352 |
|
| 353 |
bool getExtent(double& ulx, double& uly, double& lrx, double& lry, size_t ilayer, OGRCoordinateTransformation *poCT=0) const; |
| 354 |
bool getExtent(OGRPolygon *bbPolygon, size_t ilayer, OGRCoordinateTransformation *poCT=0) const; |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
void getBoundingBox(double& ulx, double& uly, double& lrx, double& lry, OGRCoordinateTransformation *poCT=0) const{getExtent(ulx,uly,lrx,lry,poCT);}; |
| 359 |
void getBoundingBox(double& ulx, double& uly, double& lrx, double& lry, size_t ilayer, OGRCoordinateTransformation *poCT=0) const{getExtent(ulx,uly,lrx,lry,ilayer,poCT);}; |
| 360 |
|
| 361 |
void getBoundingBox(OGRPolygon *bbPolygon, size_t ilayer=0, OGRCoordinateTransformation *poCT=0) const{getExtent(bbPolygon,ilayer,poCT);}; |
| 362 |
|
| 363 |
double getUlx(OGRCoordinateTransformation *poCT=0) const{double ulx,uly,lrx,lry;getExtent(ulx,uly,lrx,lry,poCT);return(ulx);}; |
| 364 |
|
| 365 |
double getUly(OGRCoordinateTransformation *poCT=0) const{double ulx,uly,lrx,lry;getExtent(ulx,uly,lrx,lry,poCT);return(uly);}; |
| 366 |
|
| 367 |
double getLrx(OGRCoordinateTransformation *poCT=0) const{double ulx,uly,lrx,lry;getExtent(ulx,uly,lrx,lry,poCT);return(lrx);}; |
| 368 |
|
| 369 |
double getLry(OGRCoordinateTransformation *poCT=0) const{double ulx,uly,lrx,lry;getExtent(ulx,uly,lrx,lry,poCT);return(lry);}; |
| 370 |
|
| 371 |
double getUlx(size_t ilayer, OGRCoordinateTransformation *poCT=0) const{double ulx,uly,lrx,lry;getExtent(ulx,uly,lrx,lry,ilayer,poCT);return(ulx);}; |
| 372 |
|
| 373 |
double getUly(size_t ilayer, OGRCoordinateTransformation *poCT=0) const{double ulx,uly,lrx,lry;getExtent(ulx,uly,lrx,lry,ilayer,poCT);return(uly);}; |
| 374 |
|
| 375 |
double getLrx(size_t ilayer, OGRCoordinateTransformation *poCT=0) const{double ulx,uly,lrx,lry;getExtent(ulx,uly,lrx,lry,ilayer,poCT);return(lrx);}; |
| 376 |
|
| 377 |
double getLry(size_t ilayer, OGRCoordinateTransformation *poCT=0) const{double ulx,uly,lrx,lry;getExtent(ulx,uly,lrx,lry,ilayer,poCT);return(lry);}; |
| 378 |
|
| 379 |
OGRErr resize(size_t theSize, size_t ilayer=0){ |
| 380 |
m_features[ilayer].resize(theSize); |
| 381 |
return(OGRERR_NONE); |
| 382 |
}; |
| 383 |
|
| 384 |
OGRFeature* createFeature(size_t ilayer=0){OGRFeature* newFeature=OGRFeature::CreateFeature(getLayer(ilayer)->GetLayerDefn());return(newFeature);}; |
| 385 |
|
| 386 |
OGRErr pushFeature(OGRFeature *poFeature,size_t ilayer=0); |
| 387 |
|
| 388 |
OGRErr setFeature(unsigned int index, OGRFeature *poFeature,size_t ilayer=0); |
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
OGRErr setSpatialFilterRect(double ulx, double uly, double lrx, double lry, size_t ilayer=0){m_layer[ilayer]->SetSpatialFilterRect(ulx,lry,lrx,uly);return(OGRERR_NONE);}; |
| 393 |
|
| 394 |
OGRErr setSpatialFilter(OGRGeometry* spatialFilter=NULL, size_t ilayer=0){m_layer[ilayer]->SetSpatialFilter(spatialFilter);return(OGRERR_NONE);}; |
| 395 |
|
| 396 |
OGRErr setAttributeFilter(const std::string& attributeFilter, size_t ilayer=0){if(attributeFilter.size()) m_layer[ilayer]->SetAttributeFilter(attributeFilter.c_str());else m_layer[ilayer]->SetAttributeFilter(NULL);return(OGRERR_NONE);}; |
| 397 |
|
| 398 |
OGRFeature* cloneFeature(unsigned int index, size_t ilayer=0); |
| 399 |
|
| 400 |
OGRFeature* getFeatureRef(unsigned int index,size_t ilayer=0); |
| 401 |
|
| 402 |
OGRErr getFields(std::vector<OGRFieldDefn*>& fields, size_t ilayer=0) const; |
| 403 |
|
| 404 |
void getFieldNames(std::vector<std::string>& fields, size_t layer=0) const; |
| 405 |
|
| 406 |
|
| 407 |
OGRErr addPoint(double x, double y, const std::map<std::string,double>& pointAttributes, std::string fieldName, int theId, size_t ilayer=0); |
| 408 |
OGRErr addPoint(double x, double y, const std::map<std::string,double>& pointAttributes, size_t ilayer=0); |
| 409 |
size_t serialize(std::vector<unsigned char> &vbytes); |
| 410 |
void dumpOgr(app::AppFactory& app); |
| 411 |
std::shared_ptr<VectorOgr> merge(VectorOgr &ogrReader, app::AppFactory& app); |
| 412 |
void merge(VectorOgr &ogrReader, VectorOgr &ogrWriter,app::AppFactory& app); |
| 413 |
|
| 414 |
|
| 415 |
std::shared_ptr<VectorOgr> join(VectorOgr &ogrReader, app::AppFactory& app); |
| 416 |
|
| 417 |
OGRErr join(VectorOgr &ogrReader, VectorOgr &ogrWriter, app::AppFactory& app); |
| 418 |
|
| 419 |
OGRErr sortByLabel(std::map<std::string,Vector2d<float> > &mapPixels, const std::string& label="label", const std::vector<std::string>& bandNames=std::vector<std::string>()); |
| 420 |
|
| 421 |
void train(app::AppFactory& app); |
| 422 |
|
| 423 |
std::string trainMem(app::AppFactory& app); |
| 424 |
|
| 425 |
std::shared_ptr<VectorOgr> classify(app::AppFactory& app); |
| 426 |
|
| 427 |
void classify(VectorOgr& ogrWriter, app::AppFactory& app); |
| 428 |
|
| 429 |
std::shared_ptr<VectorOgr> getShared(){return(std::dynamic_pointer_cast<VectorOgr>(shared_from_this()));}; |
| 430 |
|
| 431 |
friend std::ostream& operator<<(std::ostream& theOstream, VectorOgr& theVector); |
| 432 |
|
| 433 |
static bool transform(OGRGeometry *pGeom, OGRCoordinateTransformation *poCT); |
| 434 |
|
| 435 |
static bool transform(OGREnvelope *pEnv, OGRCoordinateTransformation *poCT); |
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
unsigned int readFeatures(); |
| 450 |
unsigned int readFeatures(size_t ilayer); |
| 451 |
private: |
| 452 |
|
| 453 |
std::string trainSVM(app::AppFactory& app); |
| 454 |
|
| 455 |
std::shared_ptr<VectorOgr> classifySVM(app::AppFactory& app); |
| 456 |
|
| 457 |
void classifySVM(VectorOgr& ogrWriter, app::AppFactory& app); |
| 458 |
|
| 459 |
std::string trainANN(app::AppFactory& app); |
| 460 |
|
| 461 |
std::shared_ptr<VectorOgr> classifyANN(app::AppFactory& app); |
| 462 |
|
| 463 |
void classifyANN(VectorOgr& ogrWriter, app::AppFactory& app); |
| 464 |
|
| 465 |
std::string m_filename; |
| 466 |
unsigned int m_access; |
| 467 |
|
| 468 |
std::vector<OGRLayer*> m_layer; |
| 469 |
|
| 470 |
#if GDAL_VERSION_MAJOR < 2 |
| 471 |
OGRDataSource *m_gds; |
| 472 |
#else |
| 473 |
GDALDataset *m_gds; |
| 474 |
#endif |
| 475 |
|
| 476 |
|
| 477 |
std::vector<std::vector<OGRFeature*> > m_features; |
| 478 |
}; |
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
#endif |