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
|
/******************************************************************************
* $Id: gmlreader.h 25120 2012-10-13 22:38:57Z rouault $
*
* Project: GML Reader
* Purpose: Public Declarations for OGR free GML Reader code.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2002, Frank Warmerdam
*
* 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 _GMLREADER_H_INCLUDED
#define _GMLREADER_H_INCLUDED
#include "cpl_port.h"
#include "cpl_vsi.h"
#include "cpl_minixml.h"
#include <vector>
typedef enum {
GMLPT_Untyped = 0,
GMLPT_String = 1,
GMLPT_Integer = 2,
GMLPT_Real = 3,
GMLPT_Complex = 4,
GMLPT_StringList = 5,
GMLPT_IntegerList = 6,
GMLPT_RealList = 7
} GMLPropertyType;
/************************************************************************/
/* GMLPropertyDefn */
/************************************************************************/
typedef struct
{
int nSubProperties;
char** papszSubProperties;
char* aszSubProperties[2]; /* Optimization in the case of nSubProperties == 1 */
} GMLProperty;
class CPL_DLL GMLPropertyDefn
{
char *m_pszName;
GMLPropertyType m_eType;
int m_nWidth;
int m_nPrecision;
char *m_pszSrcElement;
size_t m_nSrcElementLen;
int m_nIndex;
public:
GMLPropertyDefn( const char *pszName, const char *pszSrcElement=NULL );
~GMLPropertyDefn();
const char *GetName() const { return m_pszName; }
GMLPropertyType GetType() const { return m_eType; }
void SetType( GMLPropertyType eType ) { m_eType = eType; }
void SetWidth( int nWidth) { m_nWidth = nWidth; }
int GetWidth() const { return m_nWidth; }
void SetPrecision( int nPrecision) { m_nPrecision = nPrecision; }
int GetPrecision() const { return m_nPrecision; }
void SetSrcElement( const char *pszSrcElement );
const char *GetSrcElement() const { return m_pszSrcElement; }
size_t GetSrcElementLen() const { return m_nSrcElementLen; }
void SetAttributeIndex( int nIndex ) { m_nIndex = nIndex; }
int GetAttributeIndex() const { return m_nIndex; }
void AnalysePropertyValue( const GMLProperty* psGMLProperty );
static bool IsSimpleType( GMLPropertyType eType )
{ return eType == GMLPT_String || eType == GMLPT_Integer || eType == GMLPT_Real; }
};
/************************************************************************/
/* GMLFeatureClass */
/************************************************************************/
class CPL_DLL GMLFeatureClass
{
char *m_pszName;
char *m_pszElementName;
int n_nNameLen;
int n_nElementNameLen;
char *m_pszGeometryElement;
int m_nPropertyCount;
GMLPropertyDefn **m_papoProperty;
int m_bSchemaLocked;
int m_nFeatureCount;
char *m_pszExtraInfo;
int m_bHaveExtents;
double m_dfXMin;
double m_dfXMax;
double m_dfYMin;
double m_dfYMax;
int m_nGeometryType;
int m_nGeometryIndex;
char *m_pszSRSName;
int m_bSRSNameConsistent;
public:
GMLFeatureClass( const char *pszName = "" );
~GMLFeatureClass();
const char *GetElementName() const;
size_t GetElementNameLen() const;
void SetElementName( const char *pszElementName );
const char *GetGeometryElement() const { return m_pszGeometryElement; }
void SetGeometryElement( const char *pszElementName );
const char *GetName() const { return m_pszName; }
void SetName(const char* pszNewName);
int GetPropertyCount() const { return m_nPropertyCount; }
GMLPropertyDefn *GetProperty( int iIndex ) const;
int GetPropertyIndex( const char *pszName ) const;
GMLPropertyDefn *GetProperty( const char *pszName ) const
{ return GetProperty( GetPropertyIndex(pszName) ); }
int GetPropertyIndexBySrcElement( const char *pszElement, int nLen ) const;
int AddProperty( GMLPropertyDefn * );
int IsSchemaLocked() const { return m_bSchemaLocked; }
void SetSchemaLocked( int bLock ) { m_bSchemaLocked = bLock; }
const char *GetExtraInfo();
void SetExtraInfo( const char * );
int GetFeatureCount();
void SetFeatureCount( int );
int HasExtents() const { return m_bHaveExtents; }
void SetExtents( double dfXMin, double dfXMax,
double dFYMin, double dfYMax );
int GetExtents( double *pdfXMin, double *pdfXMax,
double *pdFYMin, double *pdfYMax );
int GetGeometryType() const { return m_nGeometryType; }
void SetGeometryType( int nNewType ) { m_nGeometryType = nNewType; }
int GetGeometryAttributeIndex() const { return m_nGeometryIndex; }
void SetGeometryAttributeIndex( int nGeometryIndex ) { m_nGeometryIndex = nGeometryIndex; }
void SetSRSName( const char* pszSRSName );
void MergeSRSName( const char* pszSRSName );
const char *GetSRSName() { return m_pszSRSName; }
CPLXMLNode *SerializeToXML();
int InitializeFromXML( CPLXMLNode * );
};
/************************************************************************/
/* GMLFeature */
/************************************************************************/
class CPL_DLL GMLFeature
{
GMLFeatureClass *m_poClass;
char *m_pszFID;
int m_nPropertyCount;
GMLProperty *m_pasProperties;
int m_nGeometryCount;
CPLXMLNode **m_papsGeometry; /* NULL-terminated. Alias to m_apsGeometry if m_nGeometryCount <= 1 */
CPLXMLNode *m_apsGeometry[2]; /* NULL-terminated */
// string list of named non-schema properties - used by NAS driver.
char **m_papszOBProperties;
public:
GMLFeature( GMLFeatureClass * );
~GMLFeature();
GMLFeatureClass*GetClass() const { return m_poClass; }
void SetGeometryDirectly( CPLXMLNode* psGeom );
void AddGeometry( CPLXMLNode* psGeom );
const CPLXMLNode* const * GetGeometryList() const { return m_papsGeometry; }
void SetPropertyDirectly( int i, char *pszValue );
const GMLProperty*GetProperty( int i ) const { return (i < m_nPropertyCount) ? &m_pasProperties[i] : NULL; }
const char *GetFID() const { return m_pszFID; }
void SetFID( const char *pszFID );
void Dump( FILE *fp );
// Out of Band property handling - special stuff like relations for NAS.
void AddOBProperty( const char *pszName, const char *pszValue );
const char *GetOBProperty( const char *pszName );
char **GetOBProperties();
};
/************************************************************************/
/* IGMLReader */
/************************************************************************/
class CPL_DLL IGMLReader
{
public:
virtual ~IGMLReader();
virtual int IsClassListLocked() const = 0;
virtual void SetClassListLocked( int bFlag ) = 0;
virtual void SetSourceFile( const char *pszFilename ) = 0;
virtual void SetFP( VSILFILE* fp ) { }
virtual const char* GetSourceFileName() = 0;
virtual int GetClassCount() const = 0;
virtual GMLFeatureClass *GetClass( int i ) const = 0;
virtual GMLFeatureClass *GetClass( const char *pszName ) const = 0;
virtual int AddClass( GMLFeatureClass *poClass ) = 0;
virtual void ClearClasses() = 0;
virtual GMLFeature *NextFeature() = 0;
virtual void ResetReading() = 0;
virtual int LoadClasses( const char *pszFile = NULL ) = 0;
virtual int SaveClasses( const char *pszFile = NULL ) = 0;
virtual int ResolveXlinks( const char *pszFile,
int* pbOutIsTempFile,
char **papszSkip = NULL,
const int bStrict = FALSE ) = 0;
virtual int HugeFileResolver( const char *pszFile,
int pbSqlitIsTempFile,
int iSqliteCacheMB ) = 0;
virtual int PrescanForSchema( int bGetExtents = TRUE ) = 0;
virtual int PrescanForTemplate( void ) = 0;
virtual int HasStoppedParsing() = 0;
virtual void SetGlobalSRSName( const char* pszGlobalSRSName ) {}
virtual const char* GetGlobalSRSName() = 0;
virtual int CanUseGlobalSRSName() = 0;
virtual int SetFilteredClassName(const char* pszClassName) = 0;
virtual const char* GetFilteredClassName() = 0;
virtual int IsSequentialLayers() const { return FALSE; }
};
IGMLReader *CreateGMLReader(int bUseExpatParserPreferably,
int bInvertAxisOrderIfLatLong,
int bConsiderEPSGAsURN,
int bGetSecondaryGeometryOption);
#endif /* _GMLREADER_H_INCLUDED */
|