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
|
/******************************************************************************
* $Id: ogr_mdb.h 21557 2011-01-22 23:42:14Z rouault $
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Private definitions for MDB driver.
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
******************************************************************************
* Copyright (c) 2011, Even Rouault, <even dot rouault at mines dash paris dot org>
*
* 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 _OGR_MDB_H_INCLUDED
#define _OGR_MDB_H_INCLUDED
#include <jni.h>
#include <vector>
#include "ogrsf_frmts.h"
#include "cpl_error.h"
#include "cpl_string.h"
/************************************************************************/
/* OGRMDBJavaEnv */
/************************************************************************/
class OGRMDBJavaEnv
{
public:
OGRMDBJavaEnv();
~OGRMDBJavaEnv();
int Init();
JavaVM *jvm;
JNIEnv *env;
int bCalledFromJava;
int ExceptionOccured();
jclass byteArray_class;
jclass file_class;
jmethodID file_constructor;
jclass database_class;
jmethodID database_open;
jmethodID database_close;
jmethodID database_getTableNames;
jmethodID database_getTable;
jclass table_class;
jmethodID table_getColumns;
jmethodID table_iterator;
jmethodID table_getRowCount;
jclass column_class;
jmethodID column_getName;
jmethodID column_getType;
jmethodID column_getLength;
jmethodID column_isVariableLength;
jclass datatype_class;
jmethodID datatype_getValue;
jclass list_class;
jmethodID list_iterator;
jclass set_class;
jmethodID set_iterator;
jclass map_class;
jmethodID map_get;
jclass iterator_class;
jmethodID iterator_hasNext;
jmethodID iterator_next;
jclass object_class;
jmethodID object_toString;
jmethodID object_getClass;
jclass boolean_class;
jmethodID boolean_booleanValue;
jclass byte_class;
jmethodID byte_byteValue;
jclass short_class;
jmethodID short_shortValue;
jclass integer_class;
jmethodID integer_intValue;
jclass float_class;
jmethodID float_floatValue;
jclass double_class;
jmethodID double_doubleValue;
};
/************************************************************************/
/* OGRMDBDatabase */
/************************************************************************/
class OGRMDBTable;
class OGRMDBDatabase
{
OGRMDBJavaEnv* env;
jobject database;
OGRMDBDatabase();
public:
static OGRMDBDatabase* Open(OGRMDBJavaEnv* env, const char* pszName);
~OGRMDBDatabase();
std::vector<CPLString> apoTableNames;
int FetchTableNames();
OGRMDBTable* GetTable(const char* pszTableName);
};
/************************************************************************/
/* OGRMDBTable */
/************************************************************************/
class OGRMDBTable
{
OGRMDBJavaEnv* env;
OGRMDBDatabase* poDB;
jobject table;
jobject table_iterator_obj;
jobject row;
jobject GetColumnVal(int iCol);
CPLString osTableName;
std::vector<CPLString> apoColumnNames;
std::vector<jstring> apoColumnNameObjects;
std::vector<int> apoColumnTypes;
std::vector<int> apoColumnLengths;
public:
OGRMDBTable(OGRMDBJavaEnv* env, OGRMDBDatabase* poDB, jobject table, const char* pszTableName);
~OGRMDBTable();
OGRMDBDatabase* GetDB() { return poDB; }
const char* GetName() { return osTableName.c_str(); }
int GetColumnCount() { return (int)apoColumnNames.size(); }
int GetColumnIndex(const char* pszColName, int bEmitErrorIfNotFound = FALSE);
const char* GetColumnName(int iIndex) { return apoColumnNames[iIndex].c_str(); }
int GetColumnType(int iIndex) { return apoColumnTypes[iIndex]; }
int GetColumnLength(int iIndex) { return apoColumnLengths[iIndex]; }
void DumpTable();
int FetchColumns();
int GetRowCount();
int GetNextRow();
void ResetReading();
char* GetColumnAsString(int iCol);
int GetColumnAsInt(int iCol);
double GetColumnAsDouble(int iCol);
GByte* GetColumnAsBinary(int iCol, int* pnBytes);
};
typedef enum
{
MDB_Boolean = 0x01,
MDB_Byte = 0x02,
MDB_Short = 0x03,
MDB_Int = 0x04,
MDB_Money = 0x05,
MDB_Float = 0x06,
MDB_Double = 0x07,
MDB_ShortDateTime = 0x08,
MDB_Binary = 0x09,
MDB_Text = 0x0A,
MDB_OLE = 0x0B,
MDB_Memo = 0x0C,
MDB_Unknown = 0x0D,
MDB_GUID = 0x0F,
MDB_Numeric = 0x10
} MDBType;
typedef enum
{
MDB_GEOM_NONE,
MDB_GEOM_PGEO,
MDB_GEOM_GEOMEDIA
} MDBGeometryType;
/************************************************************************/
/* OGRMDBLayer */
/************************************************************************/
class OGRMDBDataSource;
class OGRMDBLayer : public OGRLayer
{
protected:
OGRMDBTable* poMDBTable;
MDBGeometryType eGeometryType;
OGRFeatureDefn *poFeatureDefn;
// Layer spatial reference system, and srid.
OGRSpatialReference *poSRS;
int nSRSId;
int iNextShapeId;
OGRMDBDataSource *poDS;
int iGeomColumn;
char *pszGeomColumn;
char *pszFIDColumn;
int *panFieldOrdinals;
int bHasExtent;
OGREnvelope sExtent;
void LookupSRID( int );
public:
OGRMDBLayer(OGRMDBDataSource* poDS, OGRMDBTable* poMDBTable);
virtual ~OGRMDBLayer();
CPLErr BuildFeatureDefn();
CPLErr Initialize( const char *pszTableName,
const char *pszGeomCol,
int nShapeType,
double dfExtentLeft,
double dfExtentRight,
double dfExtentBottom,
double dfExtentTop,
int nSRID,
int bHasZ );
CPLErr Initialize( const char *pszTableName,
const char *pszGeomCol,
OGRSpatialReference* poSRS );
virtual void ResetReading();
virtual int GetFeatureCount( int bForce );
virtual OGRFeature *GetNextRawFeature();
virtual OGRFeature *GetNextFeature();
virtual OGRFeature *GetFeature( long nFeatureId );
OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
virtual OGRSpatialReference *GetSpatialRef();
virtual int TestCapability( const char * );
virtual const char *GetFIDColumn();
virtual const char *GetGeometryColumn();
virtual OGRErr GetExtent( OGREnvelope *psExtent, int bForce );
};
/************************************************************************/
/* OGRMDBDataSource */
/************************************************************************/
class OGRMDBDataSource : public OGRDataSource
{
OGRMDBLayer **papoLayers;
int nLayers;
OGRMDBLayer **papoLayersInvisible;
int nLayersWithInvisible;
char *pszName;
OGRMDBJavaEnv env;
OGRMDBDatabase* poDB;
int OpenGDB(OGRMDBTable* poGDB_GeomColumns);
int OpenGeomediaWarehouse(OGRMDBTable* poGAliasTable);
OGRSpatialReference* GetGeomediaSRS(const char* pszGCoordSystemTable,
const char* pszGCoordSystemGUID);
public:
OGRMDBDataSource();
~OGRMDBDataSource();
int Open( const char *, int bUpdate, int bTestOpen );
int OpenTable( const char *pszTableName,
const char *pszGeomCol,
int bUpdate );
const char *GetName() { return pszName; }
int GetLayerCount() { return nLayers; }
OGRLayer *GetLayer( int );
OGRLayer *GetLayerByName( const char* pszLayerName );
int TestCapability( const char * );
};
/************************************************************************/
/* OGRMDBDriver */
/************************************************************************/
class OGRMDBDriver : public OGRSFDriver
{
public:
~OGRMDBDriver();
const char *GetName();
OGRDataSource *Open( const char *, int );
int TestCapability( const char * );
};
#endif /* ndef _OGR_MDB_H_INCLUDED */
|