| 1 |
/****************************************************************************** |
| 2 |
* |
| 3 |
* Project: OpenGIS Simple Features Reference Implementation |
| 4 |
* Purpose: Various FileGDB OGR Datasource utility functions |
| 5 |
* Author: Ragi Yaser Burhum, [email protected] |
| 6 |
* |
| 7 |
****************************************************************************** |
| 8 |
* Copyright (c) 2010, Ragi Yaser Burhum |
| 9 |
* |
| 10 |
* SPDX-License-Identifier: MIT |
| 11 |
****************************************************************************/ |
| 12 |
|
| 13 |
#ifndef FGDB_UTILS_H_INCLUDED |
| 14 |
#define FGDB_UTILS_H_INCLUDED |
| 15 |
|
| 16 |
#include "ogr_fgdb.h" |
| 17 |
#include <iostream> |
| 18 |
#include <string> |
| 19 |
#include "cpl_minixml.h" |
| 20 |
|
| 21 |
std::wstring StringToWString(const std::string &s); |
| 22 |
std::string WStringToString(const std::wstring &s); |
| 23 |
|
| 24 |
// |
| 25 |
// GDB API to OGR Geometry Mapping |
| 26 |
// |
| 27 |
|
| 28 |
// Type mapping |
| 29 |
bool GDBToOGRGeometry(const std::string &geoType, bool hasZ, bool hasM, |
| 30 |
OGRwkbGeometryType *pOut); |
| 31 |
bool OGRGeometryToGDB(OGRwkbGeometryType ogrType, std::string *gdbType, |
| 32 |
bool *hasZ, bool *hasM); |
| 33 |
|
| 34 |
bool GDBToOGRSpatialReference(const std::string &wkt, |
| 35 |
OGRSpatialReference **ppSR); |
| 36 |
|
| 37 |
// Feature mapping |
| 38 |
bool GDBGeometryToOGRGeometry(bool forceMulti, |
| 39 |
FileGDBAPI::ShapeBuffer *pGdbGeometry, |
| 40 |
OGRSpatialReference *pOGRSR, |
| 41 |
OGRGeometry **ppOutGeometry); |
| 42 |
|
| 43 |
// temporary version - until we can parse the full binary format |
| 44 |
bool GhettoGDBGeometryToOGRGeometry(bool forceMulti, |
| 45 |
FileGDBAPI::ShapeBuffer *pGdbGeometry, |
| 46 |
OGRSpatialReference *pOGRSR, |
| 47 |
OGRGeometry **ppOutGeometry); |
| 48 |
// |
| 49 |
// GDB API to OGR Field Mapping |
| 50 |
// |
| 51 |
bool OGRToGDBFieldType(OGRFieldType ogrType, OGRFieldSubType eSubType, |
| 52 |
std::string *gdbType); |
| 53 |
|
| 54 |
// |
| 55 |
// GDB Field Length |
| 56 |
// |
| 57 |
bool GDBFieldTypeToLengthInBytes(const std::string &gdbType, int &lengthOut); |
| 58 |
|
| 59 |
// |
| 60 |
// GDBAPI error to OGR |
| 61 |
// |
| 62 |
bool GDBErr(long hr, const std::string &desc, CPLErr errType = CE_Failure, |
| 63 |
const char *pszAddMsg = ""); |
| 64 |
bool GDBDebug(long hr, const std::string &desc); |
| 65 |
|
| 66 |
// |
| 67 |
// Utility for adding attributes to CPL nodes |
| 68 |
// |
| 69 |
void FGDB_CPLAddXMLAttribute(CPLXMLNode *node, const char *attrname, |
| 70 |
const char *attrvalue); |
| 71 |
|
| 72 |
// |
| 73 |
// Utility for escaping reserved words and cleaning field names |
| 74 |
// |
| 75 |
std::wstring FGDBLaunderName(const std::wstring &name); |
| 76 |
std::wstring FGDBEscapeUnsupportedPrefixes(const std::wstring &className); |
| 77 |
std::wstring FGDBEscapeReservedKeywords(const std::wstring &name); |
| 78 |
|
| 79 |
#endif |