24 #include "wxgis/datasource/datasource.h"
27 #include "gdal_priv.h"
28 #include "ogrsf_frmts.h"
30 #if GDAL_VERSION_NUM >= 2000000
31 #define OGRCompatibleDataSource GDALDataset
32 #define OGRCompatibleClose(x) GDALClose(x)
33 #define OGRCompatibleDriver GDALDriver
34 #define GetOGRCompatibleDriverByName(x) GetGDALDriverManager()->GetDriverByName( x )
35 #define CreateOGRCompatibleDataSource(path, options) Create( path, 0, 0, 0, GDT_Unknown, options );
36 #define GetOGRCompatibleDriverName GetDescription
37 #define GetOGRCompatibleDatasourceName GetDriverName
39 #define OGRCompatibleDataSource OGRDataSource
40 #define OGRCompatibleClose(x) OGRDataSource::DestroyDataSource(x)
41 #define OGRCompatibleDriver OGRSFDriver
42 #define GetOGRCompatibleDriverByName(x) dynamic_cast<OGRSFDriver*>(OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(x))
43 #define CreateOGRCompatibleDataSource(path, options) CreateDataSource( path, options )
44 #define GetOGRCompatibleDriverName GetName
45 #define GetOGRCompatibleDatasourceName GetName
46 #endif // GDAL_VERSION_NUM
48 #define wxGISEQUAL(a,b) ( (const char*)a == NULL ? 0 : EQUAL(a,b) )
67 operator OGRSpatialReference*()
const;
68 OGRSpatialReference* Clone(
void)
const;
69 OGRSpatialReference* operator->(
void)
const;
71 wxString ExportAsWKT()
const;
74 virtual wxObjectRefData *CreateRefData()
const;
75 virtual wxObjectRefData *CloneRefData(
const wxObjectRefData *data)
const;
98 virtual void Validate();
99 virtual bool IsValid(
void)
const;
101 OGRSpatialReference *m_poSRS;
106 WX_DECLARE_USER_EXPORTED_OBJARRAY(
wxGISGeometry, wxGISGeometryArray, WXDLLIMPEXP_GIS_DS);
108 WX_DECLARE_USER_EXPORTED_OBJARRAY(
wxGISFeature, wxGISFeatureArray, WXDLLIMPEXP_GIS_DS);
121 wxGISFeature(OGRFeature *poFeature = NULL,
const wxFontEncoding &oEncoding = wxLocale::GetSystemEncoding(),
bool bRecodeToSystem =
false);
126 bool operator != (
const wxGISFeature& obj)
const {
return !(*
this == obj); };
127 operator OGRFeature*()
const;
130 const char* GetFieldAsChar(
int nField)
const;
131 OGRField* GetRawField(
int nField)
const;
132 wxString GetFieldAsString(
int nField)
const;
133 wxString GetFieldAsString(
const wxString &sFieldName)
const;
134 wxDateTime GetFieldAsDateTime(
int nField)
const;
135 wxDateTime GetFieldAsDateTime(
const wxString &sFieldName)
const;
136 double GetFieldAsDouble(
int nField)
const;
137 double GetFieldAsDouble (
const wxString &sFieldName)
const;
138 wxArrayString GetFieldAsStringList(
int nField)
const;
139 wxArrayString GetFieldAsStringList(
const wxString &sFieldName)
const;
140 wxArrayDouble GetFieldAsDoubleList(
int nIndex)
const;
141 wxArrayDouble GetFieldAsDoubleList(
const wxString &sFieldName)
const;
142 wxArrayInt GetFieldAsIntegerList(
int nIndex)
const;
143 wxArrayInt GetFieldAsIntegerList(
const wxString &sFieldName)
const;
145 int GetFieldAsInteger(
int nIndex)
const;
146 int GetFieldAsInteger(
const wxString &sFieldName)
const;
148 int GetFieldIndex(
const wxString &sFieldName)
const;
149 wxString GetFieldName(
int nIndex)
const;
150 int GetFieldCount(
void)
const;
151 long GetFID(
void)
const;
153 OGRErr SetFID(
long nFID);
154 void SetField(
int nIndex,
int nValue);
155 void SetField(
int nIndex, OGRField* psField);
156 void SetField(
int nIndex,
double dfValue);
157 void SetField(
int nIndex,
const wxString &sValue);
158 void SetField(
int nIndex,
const char* pszStr);
159 void SetField (
int nIndex,
const wxArrayInt &anValues);
160 void SetField (
int nIndex,
const wxArrayDouble &adfValues);
161 void SetField(
int nIndex,
const wxArrayString &asValues);
162 void SetField(
int nIndex,
const wxDateTime &dt);
163 void SetField(
const wxString &sFieldName,
int nValue);
164 void SetField(
const wxString &sFieldName,
double dfValue);
165 void SetField(
const wxString &sFieldName,
const wxString &sValue);
166 void SetField (
const wxString &sFieldName,
const wxArrayInt &anValues);
167 void SetField (
const wxString &sFieldName,
const wxArrayDouble &adfValues);
168 void SetField(
const wxString &sFieldName,
const wxArrayString &asValues);
169 void SetField(
int nIndex,
int nYear,
int nMonth,
int nDay,
int nHour = 0,
int nMinute = 0,
int nSecond = 0,
int nTZFlag = 0);
170 void SetField(
const wxString &sFieldName,
int nYear,
int nMonth,
int nDay,
int nHour = 0,
int nMinute = 0,
int nSecond = 0,
int nTZFlag = 0);
173 void SetStyleString(
const wxString &sStyle);
174 void StealGeometry(
void);
175 void SetEncoding(
const wxFontEncoding &eEnc,
bool bRecodeToSystem =
false);
177 inline wxString EncodeString(
const char* psz, wxFontEncoding oEncoding)
const
181 if (oEncoding <= wxFONTENCODING_DEFAULT)
183 return wxString(psz, wxConvLocal);
185 else if (oEncoding == wxFONTENCODING_UTF8)
187 return wxString::FromUTF8(psz);
189 else if (oEncoding == wxFONTENCODING_UTF7)
191 return wxString(psz, wxConvUTF7);
193 else if (oEncoding == wxFONTENCODING_UTF16)
195 return wxString(psz, wxMBConvUTF16());
197 else if (oEncoding == wxFONTENCODING_UTF32)
199 return wxString(psz, wxMBConvUTF32());
201 else if (oEncoding == wxFONTENCODING_ISO8859_1)
203 return wxString(psz, wxConvISO8859_1);
205 else if (wxLocale::GetSystemEncoding() == oEncoding)
207 return wxString(psz, wxConvLocal);
211 wxString sOut = wxString(psz, wxCSConv(oEncoding));
214 sOut = wxString(psz, wxConvLocal);
219 return wxEmptyString;
222 inline const char* EncodeString(
const wxString &sStr, wxFontEncoding oEncoding)
const
226 if (oEncoding <= wxFONTENCODING_DEFAULT)
228 return sStr.mb_str(wxConvLocal);
230 else if (oEncoding == wxFONTENCODING_UTF8)
232 return sStr.mb_str(wxConvUTF8);
234 else if (oEncoding == wxFONTENCODING_UTF7)
236 return sStr.mb_str(wxConvUTF7);
238 else if (oEncoding == wxFONTENCODING_UTF16)
240 return sStr.mb_str(wxMBConvUTF16());
242 else if (oEncoding == wxFONTENCODING_UTF32)
244 return sStr.mb_str(wxMBConvUTF32());
246 else if (oEncoding == wxFONTENCODING_ISO8859_1)
248 return sStr.mb_str(wxConvISO8859_1);
250 else if (wxLocale::GetSystemEncoding() == oEncoding)
252 return sStr.mb_str(wxConvLocal);
256 const char* pszOut = sStr.mb_str(wxCSConv(oEncoding));
257 if (strlen(pszOut) == 0)
259 pszOut = sStr.mb_str(wxConvLocal);
269 int GetFieldAsDateTime(
int nIndex,
int *pnYear,
int *pnMonth,
int *pnDay,
int *pnHour,
int *pnMinute,
int *pnSecond,
int *pnTZFlag)
const;
270 void SetField(
int nIndex,
char **papszValues);
271 OGRErr SetGeometry(OGRGeometry* pGeom);
273 virtual wxObjectRefData *CreateRefData()
const;
274 virtual wxObjectRefData *CloneRefData(
const wxObjectRefData *data)
const;
288 wxGISFeatureRefData(OGRFeature *poFeature = NULL,
const wxFontEncoding &oEncoding = wxLocale::GetSystemEncoding(),
bool bRecodeToSystem =
false)
290 m_poFeature = poFeature;
291 m_oEncoding = oEncoding;
292 m_bRecodeToSystem = bRecodeToSystem;
298 OGRFeature::DestroyFeature(m_poFeature);
304 m_poFeature = data.m_poFeature;
305 m_oEncoding = data.m_oEncoding;
306 m_bRecodeToSystem = data.m_bRecodeToSystem;
311 return m_poFeature == data.m_poFeature;
314 void SetEncoding(
const wxFontEncoding &eEnc,
bool bRecodeToSystem =
false)
317 m_bRecodeToSystem = bRecodeToSystem;
321 OGRFeature *m_poFeature;
322 wxFontEncoding m_oEncoding;
323 bool m_bRecodeToSystem;
337 wxGISGeometry(OGRGeometry *poGeom = NULL,
bool bOwnGeom =
true);
342 bool operator != (
const wxGISGeometry& obj)
const {
return !(*
this == obj); };
343 operator OGRGeometry*()
const;
345 OGREnvelope GetEnvelope(
void)
const;
346 OGRGeometry* Copy(
void)
const;
347 OGRGeometry* Steal(
void);
348 OGRPoint* GetCentroid(
void);
356 wxGISGeometry Buffer(
double dfBuff,
int nQuadSegs = 30)
const;
358 bool Project(OGRCoordinateTransformation*
const poCT);
359 OGRwkbGeometryType GetType()
const;
362 virtual wxObjectRefData *CreateRefData()
const;
363 virtual wxObjectRefData *CloneRefData(
const wxObjectRefData *data)
const;
380 m_bOwnGeom = bOwnGeom;
385 if (m_bOwnGeom && NULL != m_poGeom)
386 OGRGeometryFactory::destroyGeometry(m_poGeom);
392 m_poGeom = data.m_poGeom;
393 m_bOwnGeom = data.m_bOwnGeom;
398 return m_poGeom == data.m_poGeom;
402 OGRGeometry *m_poGeom;
406 extern WXDLLIMPEXP_DATA_GIS_DS(
wxGISGeometry) wxNullGeometry;
Definition: gdalinh.h:373
Definition: gdalinh.h:333
Definition: gdalinh.h:117
Definition: gdalinh.h:284