1
/******************************************************************************
3
* Project: OpenGIS Simple Features Reference Implementation
4
* Purpose: Standard includes and class definitions ArcObjects OGR driver.
5
* Author: Ragi Yaser Burhum, ragi@burhum.com
7
******************************************************************************
8
* Copyright (c) 2009, Ragi Yaser Burhum
10
* Permission is hereby granted, free of charge, to any person obtaining a
11
* copy of this software and associated documentation files (the "Software"),
12
* to deal in the Software without restriction, including without limitation
13
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14
* and/or sell copies of the Software, and to permit persons to whom the
15
* Software is furnished to do so, subject to the following conditions:
17
* The above copyright notice and this permission notice shall be included
18
* in all copies or substantial portions of the Software.
20
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
* DEALINGS IN THE SOFTWARE.
27
****************************************************************************/
29
#ifndef _OGR_AO_H_INCLUDED
30
#define _OGR_AO_H_INCLUDED
32
#include "ogrsf_frmts.h"
35
#include "cpl_string.h"
41
#include <atlstr.h> //CString
45
// ArcGIS COM Includes
46
#import "C:\Program Files (x86)\ArcGIS\com\esriSystem.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE", "VARTYPE"), rename("min", "esrimin"), rename("max", "esrimax")
47
#import "C:\Program Files (x86)\ArcGIS\com\esriGeometry.olb" raw_interfaces_only, raw_native_types, named_guids, exclude("ISegment")
48
#import "C:\Program Files (x86)\ArcGIS\com\esriGeoDatabase.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
49
#import "C:\Program Files (x86)\ArcGIS\com\esriDataSourcesGDB.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
53
/************************************************************************/
55
/************************************************************************/
59
class AOLayer : public OGRLayer
66
bool Initialize(ITable* pTable);
68
const char* GetFIDFieldName() const { return m_strOIDFieldName.c_str(); }
69
const char* GetShapeFieldName() const { return m_strShapeFieldName.c_str(); }
71
virtual void ResetReading();
72
virtual OGRFeature* GetNextFeature();
73
virtual OGRFeature* GetFeature( long nFeatureId );
75
HRESULT GetTable(ITable** ppTable);
78
virtual OGRErr GetExtent( OGREnvelope *psExtent, int bForce );
79
virtual int GetFeatureCount( int bForce );
80
virtual OGRErr SetAttributeFilter( const char *pszQuery );
81
virtual void SetSpatialFilterRect (double dfMinX, double dfMinY, double dfMaxX, double dfMaxY);
82
virtual void SetSpatialFilter( OGRGeometry * );
85
virtual OGRErr CreateField( OGRFieldDefn *poFieldIn,
88
virtual OGRErr SetFeature( OGRFeature *poFeature );
89
virtual OGRErr CreateFeature( OGRFeature *poFeature );
90
virtual OGRErr DeleteFeature( long nFID );
92
OGRFeatureDefn * GetLayerDefn() { return m_pFeatureDefn; }
94
virtual OGRSpatialReference *GetSpatialRef() { return m_pSRS; }
96
virtual int TestCapability( const char * );
99
bool OGRFeatureFromAORow(IRow* pRow, OGRFeature** ppFeature);
100
void SwitchToAttributeOnlyFilter();
101
void SwitchToSpatialFilter();
104
OGRFeatureDefn* m_pFeatureDefn;
105
OGRSpatialReference* m_pSRS;
107
std::string m_strOIDFieldName;
108
std::string m_strShapeFieldName;
110
ICursorPtr m_ipCursor;
111
IQueryFilterPtr m_ipQF;
113
std::vector<long> m_OGRFieldToESRIField; //OGR Field Index to ESRI Field Index Mapping
115
//buffers are used for avoiding constant reallocation of temp memory
116
unsigned char* m_pBuffer;
117
long m_bufferSize; //in bytes
118
bool m_supressColumnMappingError;
122
/************************************************************************/
124
/************************************************************************/
125
class AODataSource : public OGRDataSource
130
virtual ~AODataSource();
133
int Open(IWorkspace* pWorkspace, const char *, int );
135
const char* GetName() { return m_pszName; }
136
int GetLayerCount() { return static_cast<int>(m_layers.size()); }
138
OGRLayer* GetLayer( int );
142
virtual OGRLayer* CreateLayer( const char *,
143
OGRSpatialReference* = NULL,
144
OGRwkbGeometryType = wkbUnknown,
148
virtual OGRErr DeleteLayer( int );
150
int TestCapability( const char * );
155
void EnumerateSpatialTables();
156
void OpenSpatialTable( const char* pszTableName );
159
bool LoadLayers(IEnumDataset* pEnumDataset);
162
std::vector <AOLayer*> m_layers;
163
IWorkspacePtr m_ipWorkspace;
167
/************************************************************************/
169
/************************************************************************/
171
class AODriver : public OGRSFDriver
180
const char *GetName();
181
virtual OGRDataSource *Open( const char *, int );
182
int TestCapability( const char * );
183
virtual OGRDataSource *CreateDataSource( const char *pszName, char ** = NULL);
185
void OpenWorkspace(std::string, IWorkspace** ppWorkspace);
188
bool m_licensedCheckedOut;
194
void CPL_DLL RegisterOGRao();
197
#endif /* ndef _OGR_PG_H_INCLUDED */