-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathogr2ogr_lib.h
660 lines (537 loc) · 25.1 KB
/
ogr2ogr_lib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
/******************************************************************************
* Project: GDAL Utilities
* Purpose: GDAL Utilities Public Declarations.
* Author: Faza Mahamood, fazamhd at gmail dot com
*
* ****************************************************************************
* Copyright (c) 1998, Frank Warmerdam
* Copyright (c) 2007-2015, Even Rouault <even.rouault at spatialys.com>
* Copyright (c) 2015, Faza Mahamood
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef OGR2OGR_LIB_H_INCLUDED
#define OGR2OGR_LIB_H_INCLUDED
#include "gdal.h"
#include "gdal_priv.h"
#include "gdal_alg.h"
#include "ogr_api.h"
#include "ogr_feature.h"
#include "ogr_featurestyle.h"
#include "ogr_geometry.h"
#include "ogr_p.h"
#include "ogrsf_frmts.h"
#include "gdal_alg_priv.h"
/* Access modes */
typedef enum
{
ACCESS_CREATION,
ACCESS_UPDATE, /* open existing output datasource in update mode rather than trying to create a new one */
ACCESS_APPEND, /* append to existing layer instead of creating new */
ACCESS_OVERWRITE /* delete the output layer and recreate it empty */
} GDALVectorTranslateAccessMode;
struct GDALVectorTranslateOptionsForBinary
{
char* pszDataSource;
char* pszDestDataSource;
int bQuiet;
char** papszOpenOptions;
int bFormatExplicitlySet;
char* pszFormat;
GDALVectorTranslateAccessMode eAccessMode;
};
/************************************************************************/
/* OGR2OGRSpatialReferenceHolder */
/************************************************************************/
class OGR2OGRSpatialReferenceHolder
{
OGRSpatialReference* m_poSRS;
public:
OGR2OGRSpatialReferenceHolder() : m_poSRS(nullptr) {}
~OGR2OGRSpatialReferenceHolder() { if( m_poSRS) m_poSRS->Release(); }
void assignNoRefIncrease(OGRSpatialReference* poSRS) {
CPLAssert(m_poSRS == nullptr);
m_poSRS = poSRS;
}
OGRSpatialReference* get() { return m_poSRS; }
};
typedef enum
{
GEOMOP_NONE,
GEOMOP_SEGMENTIZE,
GEOMOP_SIMPLIFY_PRESERVE_TOPOLOGY,
} GeomOperation;
typedef enum
{
GTC_DEFAULT,
GTC_PROMOTE_TO_MULTI,
GTC_CONVERT_TO_LINEAR,
GTC_CONVERT_TO_CURVE,
} GeomTypeConversion;
#define GEOMTYPE_UNCHANGED -2
#define COORD_DIM_UNCHANGED -1
#define COORD_DIM_LAYER_DIM -2
#define COORD_DIM_XYM -3
typedef struct
{
OGRLayer * poSrcLayer;
GIntBig nFeaturesRead;
bool bPerFeatureCT;
OGRLayer *poDstLayer;
OGRCoordinateTransformation **papoCT; // size: poDstLayer->GetLayerDefn()->GetFieldCount();
char ***papapszTransformOptions; // size: poDstLayer->GetLayerDefn()->GetFieldCount();
int *panMap;
int iSrcZField;
int iSrcFIDField;
int iRequestedSrcGeomField;
bool bPreserveFID;
GIntBig nFeaturesOutOfClip, nFeaturesInsideClip, nFeaturesClipped, nFeaturesSkipClip;
time_t startTime;
} TargetLayerInfo;
typedef struct
{
OGRLayer *poSrcLayer;
TargetLayerInfo *psInfo;
} AssociatedLayers;
/************************************************************************/
/* GDALVectorTranslateOptions */
/************************************************************************/
/** Options for use with GDALVectorTranslate(). GDALVectorTranslateOptions* must be allocated and
* freed with GDALVectorTranslateOptionsNew() and GDALVectorTranslateOptionsFree() respectively.
*/
struct GDALVectorTranslateOptions
{
/*! try to fix invalid geometry */
bool bFixGeometries;
/*! continue after a failure, skipping the failed feature */
bool bSkipFailures;
/*! use layer level transaction. If set to FALSE, then it is interpreted as dataset level transaction. */
int nLayerTransaction;
/*! force the use of particular transaction type based on GDALVectorTranslate::nLayerTransaction */
bool bForceTransaction;
/*! group nGroupTransactions features per transaction (default 20000). Increase the value for better
performance when writing into DBMS drivers that have transaction support. nGroupTransactions can
be set to -1 to load the data into a single transaction */
int nGroupTransactions;
/*! If provided, only the feature with this feature id will be reported. Operates exclusive of
the spatial or attribute queries. Note: if you want to select several features based on their
feature id, you can also use the fact the 'fid' is a special field recognized by OGR SQL.
So GDALVectorTranslateOptions::pszWHERE = "fid in (1,3,5)" would select features 1, 3 and 5. */
GIntBig nFIDToFetch;
/*! allow or suppress progress monitor and other non-error output */
bool bQuiet;
/*! output file format name (default is ESRI Shapefile) */
char *pszFormat;
/*! list of layers of the source dataset which needs to be selected */
char **papszLayers;
/*! dataset creation option (format specific) */
char **papszDSCO;
/*! layer creation option (format specific) */
char **papszLCO;
/*! access modes */
GDALVectorTranslateAccessMode eAccessMode;
/*! It has the effect of adding, to existing target layers, the new fields found in source layers.
This option is useful when merging files that have non-strictly identical structures. This might
not work for output formats that don't support adding fields to existing non-empty layers. */
bool bAddMissingFields;
/*! It must be set to true to trigger reprojection, otherwise only SRS assignment is done. */
bool bTransform;
/*! output SRS. GDALVectorTranslateOptions::bTransform must be set to true to trigger reprojection,
otherwise only SRS assignment is done. */
char *pszOutputSRSDef;
/*! override source SRS */
char *pszSourceSRSDef;
bool bNullifyOutputSRS;
/*! If set to false, then field name matching between source and existing target layer is done
in a more relaxed way if the target driver has an implementation for it. */
bool bExactFieldNameMatch;
/*! an alternate name to the new layer */
char *pszNewLayerName;
/*! attribute query (like SQL WHERE) */
char *pszWHERE;
/*! name of the geometry field on which the spatial filter operates on. */
char *pszGeomField;
/*! list of fields from input layer to copy to the new layer. A field is skipped if
mentioned previously in the list even if the input layer has duplicate field names.
(Defaults to all; any field is skipped if a subsequent field with same name is
found.) Geometry fields can also be specified in the list. */
char **papszSelFields;
/*! SQL statement to execute. The resulting table/layer will be saved to the output. */
char *pszSQLStatement;
/*! SQL dialect. In some cases can be used to use (unoptimized) OGR SQL instead of the
native SQL of an RDBMS by using "OGRSQL". The "SQLITE" dialect can also be used with
any datasource. */
char *pszDialect;
/*! the geometry type for the created layer */
int eGType;
GeomTypeConversion eGeomTypeConversion;
/*! Geometric operation to perform */
GeomOperation eGeomOp;
/*! the parameter to geometric operation */
double dfGeomOpParam;
/*! list of field types to convert to a field of type string in the destination layer.
Valid types are: Integer, Integer64, Real, String, Date, Time, DateTime, Binary,
IntegerList, Integer64List, RealList, StringList. Special value "All" can be
used to convert all fields to strings. This is an alternate way to using the CAST
operator of OGR SQL, that may avoid typing a long SQL query. Note that this does
not influence the field types used by the source driver, and is only an afterwards
conversion. */
char **papszFieldTypesToString;
/*! list of field types and the field type after conversion in the destination layer.
("srctype1=dsttype1","srctype2=dsttype2",...).
Valid types are : Integer, Integer64, Real, String, Date, Time, DateTime, Binary,
IntegerList, Integer64List, RealList, StringList. Types can also include subtype
between parenthesis, such as Integer(Boolean), Real(Float32), ... Special value
"All" can be used to convert all fields to another type. This is an alternate way to
using the CAST operator of OGR SQL, that may avoid typing a long SQL query.
This is a generalization of GDALVectorTranslateOptions::papszFieldTypeToString. Note that this does not influence
the field types used by the source driver, and is only an afterwards conversion. */
char **papszMapFieldType;
/*! set field width and precision to 0 */
bool bUnsetFieldWidth;
/*! display progress on terminal. Only works if input layers have the "fast feature count"
capability */
bool bDisplayProgress;
/*! split geometries crossing the dateline meridian */
bool bWrapDateline;
/*! offset from dateline in degrees (default long. = +/- 10deg, geometries
within 170deg to -170deg will be split) */
double dfDateLineOffset;
/*! clip geometries when it is set to true */
bool bClipSrc;
OGRGeometryH hClipSrc;
/*! clip datasource */
char *pszClipSrcDS;
/*! select desired geometries using an SQL query */
char *pszClipSrcSQL;
/*! selected named layer from the source clip datasource */
char *pszClipSrcLayer;
/*! restrict desired geometries based on attribute query */
char *pszClipSrcWhere;
OGRGeometryH hClipDst;
/*! destination clip datasource */
char *pszClipDstDS;
/*! select desired geometries using an SQL query */
char *pszClipDstSQL;
/*! selected named layer from the destination clip datasource */
char *pszClipDstLayer;
/*! restrict desired geometries based on attribute query */
char *pszClipDstWhere;
/*! split fields of type StringList, RealList or IntegerList into as many fields
of type String, Real or Integer as necessary. */
bool bSplitListFields;
/*! limit the number of subfields created for each split field. */
int nMaxSplitListSubFields;
/*! produce one feature for each geometry in any kind of geometry collection in the
source file */
bool bExplodeCollections;
/*! uses the specified field to fill the Z coordinates of geometries */
char *pszZField;
/*! the list of field indexes to be copied from the source to the destination. The (n)th value
specified in the list is the index of the field in the target layer definition in which the
n(th) field of the source layer must be copied. Index count starts at zero. There must be
exactly as many values in the list as the count of the fields in the source layer.
We can use the "identity" option to specify that the fields should be transferred by using
the same order. This option should be used along with the
GDALVectorTranslateOptions::eAccessMode = ACCESS_APPEND option. */
char **papszFieldMap;
/*! force the coordinate dimension to nCoordDim (valid values are 2 or 3). This affects both
the layer geometry type, and feature geometries. */
int nCoordDim;
/*! destination dataset open option (format specific), only valid in update mode */
char **papszDestOpenOptions;
/*! If set to true, does not propagate not-nullable constraints to target layer if they exist
in source layer */
bool bForceNullable;
/*! If set to true, does not propagate default field values to target layer if they exist in
source layer */
bool bUnsetDefault;
/*! to prevent the new default behaviour that consists in, if the output driver has a FID layer
creation option and we are not in append mode, to preserve the name of the source FID column
and source feature IDs */
bool bUnsetFid;
/*! use the FID of the source features instead of letting the output driver to automatically
assign a new one. If not in append mode, this behaviour becomes the default if the output
driver has a FID layer creation option. In which case the name of the source FID column will
be used and source feature IDs will be attempted to be preserved. This behaviour can be
disabled by option GDALVectorTranslateOptions::bUnsetFid */
bool bPreserveFID;
/*! set it to false to disable copying of metadata from source dataset and layers into target dataset and
layers, when supported by output driver. */
bool bCopyMD;
/*! list of metadata key and value to set on the output dataset, when supported by output driver.
("META-TAG1=VALUE1","META-TAG2=VALUE2") */
char **papszMetadataOptions;
/*! override spatial filter SRS */
char *pszSpatSRSDef;
/*! size of the list GDALVectorTranslateOptions::pasGCPs */
int nGCPCount;
/*! list of ground control points to be added */
GDAL_GCP *pasGCPs;
/*! order of polynomial used for warping (1 to 3). The default is to select a polynomial
order based on the number of GCPs */
int nTransformOrder;
/*! spatial query extents, in the SRS of the source layer(s) (or the one specified with
GDALVectorTranslateOptions::pszSpatSRSDef). Only features whose geometry intersects the extents
will be selected. The geometries will not be clipped unless GDALVectorTranslateOptions::bClipSrc
is true. */
OGRGeometryH hSpatialFilter;
/*! the progress function to use */
GDALProgressFunc pfnProgress;
/*! pointer to the progress data variable */
void *pProgressData;
/*! Whether layer and feature native data must be transferred. */
bool bNativeData;
/*! Maximum number of features, or -1 if no limit. */
GIntBig nLimit;
};
class SetupTargetLayer
{
public:
GDALDataset *m_poSrcDS;
GDALDataset *m_poDstDS;
char **m_papszLCO;
OGRSpatialReference *m_poOutputSRS;
bool m_bNullifyOutputSRS;
char **m_papszSelFields;
bool m_bAppend;
bool m_bAddMissingFields;
int m_eGType;
GeomTypeConversion m_eGeomTypeConversion;
int m_nCoordDim;
bool m_bOverwrite;
char **m_papszFieldTypesToString;
char **m_papszMapFieldType;
bool m_bUnsetFieldWidth;
bool m_bExplodeCollections;
const char *m_pszZField;
char **m_papszFieldMap;
const char *m_pszWHERE;
bool m_bExactFieldNameMatch;
bool m_bQuiet;
bool m_bForceNullable;
bool m_bUnsetDefault;
bool m_bUnsetFid;
bool m_bPreserveFID;
bool m_bCopyMD;
bool m_bNativeData;
bool m_bNewDataSource;
TargetLayerInfo* Setup(OGRLayer * poSrcLayer,
const char *pszNewLayerName,
GDALVectorTranslateOptions *psOptions,
GIntBig& nTotalEventsDone);
};
class LayerTranslator
{
public:
GDALDataset *m_poSrcDS;
GDALDataset *m_poODS;
bool m_bTransform;
bool m_bWrapDateline;
CPLString m_osDateLineOffset;
OGRSpatialReference *m_poOutputSRS;
bool m_bNullifyOutputSRS;
OGRSpatialReference *m_poUserSourceSRS;
OGRCoordinateTransformation *m_poGCPCoordTrans;
int m_eGType;
GeomTypeConversion m_eGeomTypeConversion;
int m_nCoordDim;
GeomOperation m_eGeomOp;
double m_dfGeomOpParam;
OGRGeometry *m_poClipSrc;
OGRGeometry *m_poClipDst;
bool m_bExplodeCollections;
bool m_bNativeData;
GIntBig m_nLimit;
int Translate(OGRFeature* poFeatureIn,
TargetLayerInfo* psInfo,
GIntBig nCountLayerFeatures,
GIntBig* pnReadFeatureCount,
GIntBig& nTotalEventsDone,
GDALProgressFunc pfnProgress,
void *pProgressArg,
GDALVectorTranslateOptions *psOptions);
};
/************************************************************************/
/* GCPCoordTransformation() */
/* */
/* Apply GCP Transform to points */
/************************************************************************/
class GCPCoordTransformation : public OGRCoordinateTransformation
{
GCPCoordTransformation(const GCPCoordTransformation& other):
hTransformArg(GDALCloneTransformer(other.hTransformArg)),
bUseTPS(other.bUseTPS),
poSRS(other.poSRS)
{
if( poSRS)
poSRS->Reference();
}
public:
void *hTransformArg;
bool bUseTPS;
OGRSpatialReference* poSRS;
GCPCoordTransformation( int nGCPCount,
const GDAL_GCP *pasGCPList,
int nReqOrder,
OGRSpatialReference* poSRSIn) :
hTransformArg(nullptr),
bUseTPS(nReqOrder < 0),
poSRS(poSRSIn)
{
if( nReqOrder < 0 )
{
hTransformArg =
GDALCreateTPSTransformer( nGCPCount, pasGCPList, FALSE );
}
else
{
hTransformArg =
GDALCreateGCPTransformer( nGCPCount, pasGCPList, nReqOrder, FALSE );
}
if( poSRS)
poSRS->Reference();
}
OGRCoordinateTransformation* Clone() const override {
return new GCPCoordTransformation(*this);
}
bool IsValid() const { return hTransformArg != nullptr; }
virtual ~GCPCoordTransformation()
{
if( hTransformArg != nullptr )
{
GDALDestroyTransformer(hTransformArg);
}
if( poSRS)
poSRS->Dereference();
}
virtual OGRSpatialReference *GetSourceCS() override { return poSRS; }
virtual OGRSpatialReference *GetTargetCS() override { return poSRS; }
virtual int Transform( int nCount,
double *x, double *y, double *z,
double * /* t */,
int *pabSuccess ) override
{
if( bUseTPS )
return GDALTPSTransform( hTransformArg, FALSE,
nCount, x, y, z, pabSuccess );
else
return GDALGCPTransform( hTransformArg, FALSE,
nCount, x, y, z, pabSuccess );
}
virtual OGRCoordinateTransformation* GetInverse() const override { return nullptr; }
};
/************************************************************************/
/* OGRSplitListFieldLayer */
/************************************************************************/
typedef struct
{
int iSrcIndex;
OGRFieldType eType;
int nMaxOccurrences;
int nWidth;
} ListFieldDesc;
class OGRSplitListFieldLayer : public OGRLayer
{
OGRLayer *poSrcLayer;
OGRFeatureDefn *poFeatureDefn;
ListFieldDesc *pasListFields;
int nListFieldCount;
int nMaxSplitListSubFields;
OGRFeature *TranslateFeature(OGRFeature* poSrcFeature);
public:
OGRSplitListFieldLayer(OGRLayer* poSrcLayer,
int nMaxSplitListSubFields);
virtual ~OGRSplitListFieldLayer();
bool BuildLayerDefn(GDALProgressFunc pfnProgress,
void *pProgressArg);
virtual OGRFeature *GetNextFeature() override;
virtual OGRFeature *GetFeature(GIntBig nFID) override;
virtual OGRFeatureDefn *GetLayerDefn() override;
virtual void ResetReading() override { poSrcLayer->ResetReading(); }
virtual int TestCapability(const char*) override { return FALSE; }
virtual GIntBig GetFeatureCount( int bForce = TRUE ) override
{
return poSrcLayer->GetFeatureCount(bForce);
}
virtual OGRSpatialReference *GetSpatialRef() override
{
return poSrcLayer->GetSpatialRef();
}
virtual OGRGeometry *GetSpatialFilter() override
{
return poSrcLayer->GetSpatialFilter();
}
virtual OGRStyleTable *GetStyleTable() override
{
return poSrcLayer->GetStyleTable();
}
virtual void SetSpatialFilter( OGRGeometry *poGeom ) override
{
poSrcLayer->SetSpatialFilter(poGeom);
}
virtual void SetSpatialFilter( int iGeom, OGRGeometry *poGeom ) override
{
poSrcLayer->SetSpatialFilter(iGeom, poGeom);
}
virtual void SetSpatialFilterRect( double dfMinX, double dfMinY,
double dfMaxX, double dfMaxY ) override
{
poSrcLayer->SetSpatialFilterRect(dfMinX, dfMinY, dfMaxX, dfMaxY);
}
virtual void SetSpatialFilterRect( int iGeom,
double dfMinX, double dfMinY,
double dfMaxX, double dfMaxY ) override
{
poSrcLayer->SetSpatialFilterRect(iGeom, dfMinX, dfMinY, dfMaxX, dfMaxY);
}
virtual OGRErr SetAttributeFilter( const char *pszFilter ) override
{
return poSrcLayer->SetAttributeFilter(pszFilter);
}
};
// /*! Options for GDALVectorTranslate(). Opaque type */
// typedef struct GDALVectorTranslateOptions GDALVectorTranslateOptions;
//
// /** Opaque type */
// typedef struct GDALVectorTranslateOptionsForBinary GDALVectorTranslateOptionsForBinary;
GDALVectorTranslateOptions *GDALVectorTranslateOptionsNew(char** papszArgv, GDALVectorTranslateOptionsForBinary* psOptionsForBinary);
void GDALVectorTranslateOptionsFree( GDALVectorTranslateOptions *psOptions );
void GDALVectorTranslateOptionsSetProgress( GDALVectorTranslateOptions *psOptions,
GDALProgressFunc pfnProgress,
void *pProgressData );
GDALDatasetH GDALVectorTranslate( const char *pszDest, GDALDatasetH hDstDS, int nSrcCount,
GDALDatasetH *pahSrcDS,
const GDALVectorTranslateOptions *psOptions, int *pbUsageError );
GDALVectorTranslateOptions* GDALVectorTranslateOptionsClone(const GDALVectorTranslateOptions *psOptionsIn);
OGRGeometry* LoadGeometry( const char* pszDS, const char* pszSQL, const char* pszLyr, const char* pszWhere);
GDALDataset* GDALVectorTranslateCreateCopy(GDALDriver* poDriver, const char* pszDest, GDALDataset* poDS, const GDALVectorTranslateOptions* psOptions);
OGRLayer* GetLayerAndOverwriteIfNecessary(GDALDataset *poDstDS,
const char* pszNewLayerName,
bool bOverwrite,
bool* pbErrorOccurred,
bool* pbOverwriteActuallyDone);
void FreeTargetLayerInfo(TargetLayerInfo* psInfo);
void ApplySpatialFilter(OGRLayer* poLayer, OGRGeometry* poSpatialFilter,
OGRSpatialReference* poSpatSRS,
const char* pszGeomField,
OGRSpatialReference* poSourceSRS);
GDALVectorTranslateOptions *GDALVectorTranslateOptionsNew(char** papszArgv,
GDALVectorTranslateOptionsForBinary* psOptionsForBinary);
#endif /* OGR2OGR_LIB_H_INCLUDED */