[Gdal-dev] ogr gml reader needs an update
Peter Rushforth
peter.rushforth at gmail.com
Wed May 24 22:04:22 EDT 2006
Hi Frank,
I have made the following updates:
gmlreader.h
-added m_nWidth class member to GMLPropertyDefn
-added getter and setter for m_nWidth member
gmlpropertydefn.cpp
-modified member function AnalysePropertyValue() to set the m_szWidth
member via SetWidth method in the case of a string value
gmlfeatureclass.cpp
-added code to set property definition width member to value of Width
element found in .gfs file
The system does create the correctly populated Width element in the .gfs file,
but the m_szWidth member is ignored by the ogr2ogr system when it comes
to creating the output layer. Could you point out where I need to look to make
that change please?
Cheers,
Peter
-------------- next part --------------
/**********************************************************************
* $Id: gmlfeatureclass.cpp,v 1.5 2003/09/11 20:01:21 warmerda Exp $
*
* Project: GML Reader
* Purpose: Implementation of GMLFeatureClass.
* Author: Frank Warmerdam, warmerdam at 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.
**********************************************************************
*
* $Log: gmlfeatureclass.cpp,v $
* Revision 1.5 2003/09/11 20:01:21 warmerda
* removed unused variable
*
* Revision 1.4 2003/05/21 03:48:35 warmerda
* Expand tabs
*
* Revision 1.3 2002/03/06 20:07:35 warmerda
* added tracking of extents, feature count and extrainfo
*
* Revision 1.2 2002/01/24 17:37:33 warmerda
* added to/from XML support
*
* Revision 1.1 2002/01/04 19:46:30 warmerda
* New
*
*
**********************************************************************/
#include "gmlreader.h"
#include "cpl_conv.h"
/************************************************************************/
/* GMLFeatureClass() */
/************************************************************************/
GMLFeatureClass::GMLFeatureClass( const char *pszName )
{
m_pszName = CPLStrdup( pszName );
m_pszElementName = NULL;
m_pszGeometryElement = NULL;
m_nPropertyCount = 0;
m_papoProperty = NULL;
m_bSchemaLocked = FALSE;
m_pszExtraInfo = NULL;
m_bHaveExtents = FALSE;
m_nFeatureCount = -1; // unknown
}
/************************************************************************/
/* ~GMLFeatureClass() */
/************************************************************************/
GMLFeatureClass::~GMLFeatureClass()
{
CPLFree( m_pszName );
CPLFree( m_pszElementName );
CPLFree( m_pszGeometryElement );
for( int i = 0; i < m_nPropertyCount; i++ )
delete m_papoProperty[i];
CPLFree( m_papoProperty );
}
/************************************************************************/
/* GetProperty(int) */
/************************************************************************/
GMLPropertyDefn *GMLFeatureClass::GetProperty( int iIndex ) const
{
if( iIndex < 0 || iIndex >= m_nPropertyCount )
return NULL;
else
return m_papoProperty[iIndex];
}
/************************************************************************/
/* GetPropertyIndex() */
/************************************************************************/
int GMLFeatureClass::GetPropertyIndex( const char *pszName ) const
{
for( int i = 0; i < m_nPropertyCount; i++ )
if( EQUAL(pszName,m_papoProperty[i]->GetName()) )
return i;
return -1;
}
/************************************************************************/
/* AddProperty() */
/************************************************************************/
int GMLFeatureClass::AddProperty( GMLPropertyDefn *poDefn )
{
CPLAssert( GetProperty(poDefn->GetName()) == NULL );
m_nPropertyCount++;
m_papoProperty = (GMLPropertyDefn **)
CPLRealloc( m_papoProperty, sizeof(void*) * m_nPropertyCount );
m_papoProperty[m_nPropertyCount-1] = poDefn;
return m_nPropertyCount-1;
}
/************************************************************************/
/* SetElementName() */
/************************************************************************/
void GMLFeatureClass::SetElementName( const char *pszElementName )
{
CPLFree( m_pszElementName );
m_pszElementName = CPLStrdup( pszElementName );
}
/************************************************************************/
/* GetElementName() */
/************************************************************************/
const char *GMLFeatureClass::GetElementName() const
{
if( m_pszElementName == NULL )
return m_pszName;
else
return m_pszElementName;
}
/************************************************************************/
/* SetGeometryElement() */
/************************************************************************/
void GMLFeatureClass::SetGeometryElement( const char *pszElement )
{
CPLFree( m_pszGeometryElement );
m_pszGeometryElement = CPLStrdup( pszElement );
}
/************************************************************************/
/* GetFeatureCount() */
/************************************************************************/
int GMLFeatureClass::GetFeatureCount()
{
return m_nFeatureCount;
}
/************************************************************************/
/* SetFeatureCount() */
/************************************************************************/
void GMLFeatureClass::SetFeatureCount( int nNewCount )
{
m_nFeatureCount = nNewCount;
}
/************************************************************************/
/* GetExtraInfo() */
/************************************************************************/
const char *GMLFeatureClass::GetExtraInfo()
{
return m_pszExtraInfo;
}
/************************************************************************/
/* SetExtraInfo() */
/************************************************************************/
void GMLFeatureClass::SetExtraInfo( const char *pszExtraInfo )
{
CPLFree( m_pszExtraInfo );
m_pszExtraInfo = NULL;
if( pszExtraInfo != NULL )
m_pszExtraInfo = CPLStrdup( pszExtraInfo );
}
/************************************************************************/
/* SetExtents() */
/************************************************************************/
void GMLFeatureClass::SetExtents( double dfXMin, double dfXMax,
double dfYMin, double dfYMax )
{
m_dfXMin = dfXMin;
m_dfXMax = dfXMax;
m_dfYMin = dfYMin;
m_dfYMax = dfYMax;
m_bHaveExtents = TRUE;
}
/************************************************************************/
/* GetExtents() */
/************************************************************************/
int GMLFeatureClass::GetExtents( double *pdfXMin, double *pdfXMax,
double *pdfYMin, double *pdfYMax )
{
if( m_bHaveExtents )
{
*pdfXMin = m_dfXMin;
*pdfXMax = m_dfXMax;
*pdfYMin = m_dfYMin;
*pdfYMax = m_dfYMax;
}
return m_bHaveExtents;
}
/************************************************************************/
/* InitializeFromXML() */
/************************************************************************/
int GMLFeatureClass::InitializeFromXML( CPLXMLNode *psRoot )
{
/* -------------------------------------------------------------------- */
/* Do some rudimentary checking that this is a well formed */
/* node. */
/* -------------------------------------------------------------------- */
if( psRoot == NULL
|| psRoot->eType != CXT_Element
|| !EQUAL(psRoot->pszValue,"GMLFeatureClass") )
{
CPLError( CE_Failure, CPLE_AppDefined,
"GMLFeatureClass::InitializeFromXML() called on %s node!",
psRoot->pszValue );
return FALSE;
}
if( CPLGetXMLValue( psRoot, "Name", NULL ) == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"GMLFeatureClass has no <Name> element." );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Collect base info. */
/* -------------------------------------------------------------------- */
CPLFree( m_pszName );
m_pszName = CPLStrdup( CPLGetXMLValue( psRoot, "Name", NULL ) );
SetElementName( CPLGetXMLValue( psRoot, "ElementPath", m_pszName ) );
const char *pszGPath = CPLGetXMLValue( psRoot, "GeometryElementPath", "" );
if( strlen( pszGPath ) > 0 )
SetGeometryElement( pszGPath );
/* -------------------------------------------------------------------- */
/* Collect dataset specific info. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psDSI = CPLGetXMLNode( psRoot, "DatasetSpecificInfo" );
if( psDSI != NULL )
{
const char *pszValue;
pszValue = CPLGetXMLValue( psDSI, "FeatureCount", NULL );
if( pszValue != NULL )
SetFeatureCount( atoi(pszValue) );
// Eventually we should support XML subtrees.
pszValue = CPLGetXMLValue( psDSI, "ExtraInfo", NULL );
if( pszValue != NULL )
SetExtraInfo( pszValue );
if( CPLGetXMLValue( psDSI, "ExtentXMin", NULL ) != NULL
&& CPLGetXMLValue( psDSI, "ExtentXMax", NULL ) != NULL
&& CPLGetXMLValue( psDSI, "ExtentYMin", NULL ) != NULL
&& CPLGetXMLValue( psDSI, "ExtentYMax", NULL ) != NULL )
{
SetExtents( atof(CPLGetXMLValue( psDSI, "ExtentXMin", "0.0" )),
atof(CPLGetXMLValue( psDSI, "ExtentXMax", "0.0" )),
atof(CPLGetXMLValue( psDSI, "ExtentYMin", "0.0" )),
atof(CPLGetXMLValue( psDSI, "ExtentYMax", "0.0" )) );
}
}
/* -------------------------------------------------------------------- */
/* Collect property definitions. */
/* -------------------------------------------------------------------- */
for( CPLXMLNode *psThis = psRoot->psChild;
psThis != NULL; psThis = psThis->psNext )
{
if( EQUAL(psThis->pszValue, "PropertyDefn") )
{
const char *pszName = CPLGetXMLValue( psThis, "Name", NULL );
const char *pszType = CPLGetXMLValue( psThis, "Type", "Untyped" );
GMLPropertyDefn *poPDefn;
if( pszName == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"GMLFeatureClass %s has a PropertyDefn without a <Name>..",
m_pszName );
return FALSE;
}
poPDefn = new GMLPropertyDefn(
pszName, CPLGetXMLValue( psThis, "ElementPath", NULL ) );
if( EQUAL(pszType,"Untyped") )
poPDefn->SetType( GMLPT_Untyped );
else if( EQUAL(pszType,"String") )
{
poPDefn->SetType( GMLPT_String );
poPDefn->SetWidth( atoi( CPLGetXMLValue( psThis, "Width", "0" ) ) );
}
else if( EQUAL(pszType,"Integer") )
poPDefn->SetType( GMLPT_Integer );
else if( EQUAL(pszType,"Real") )
poPDefn->SetType( GMLPT_Real );
else if( EQUAL(pszType,"Complex") )
poPDefn->SetType( GMLPT_Complex );
else
{
CPLError( CE_Failure, CPLE_AppDefined,
"Unrecognised property type %s.",
pszType );
return FALSE;
}
AddProperty( poPDefn );
}
}
return TRUE;
}
/************************************************************************/
/* SerializeToXML() */
/************************************************************************/
CPLXMLNode *GMLFeatureClass::SerializeToXML()
{
CPLXMLNode *psRoot;
int iProperty;
/* -------------------------------------------------------------------- */
/* Set feature class and core information. */
/* -------------------------------------------------------------------- */
psRoot = CPLCreateXMLNode( NULL, CXT_Element, "GMLFeatureClass" );
CPLCreateXMLElementAndValue( psRoot, "Name", GetName() );
CPLCreateXMLElementAndValue( psRoot, "ElementPath", GetElementName() );
if( GetGeometryElement() != NULL && strlen(GetGeometryElement()) > 0 )
CPLCreateXMLElementAndValue( psRoot, "GeometryElementPath",
GetGeometryElement() );
/* -------------------------------------------------------------------- */
/* Write out dataset specific information. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psDSI;
if( m_bHaveExtents || m_nFeatureCount != -1 || m_pszExtraInfo != NULL )
{
psDSI = CPLCreateXMLNode( psRoot, CXT_Element, "DatasetSpecificInfo" );
if( m_nFeatureCount != -1 )
{
char szValue[128];
sprintf( szValue, "%d", m_nFeatureCount );
CPLCreateXMLElementAndValue( psDSI, "FeatureCount", szValue );
}
if( m_bHaveExtents )
{
char szValue[128];
sprintf( szValue, "%.5f", m_dfXMin );
CPLCreateXMLElementAndValue( psDSI, "ExtentXMin", szValue );
sprintf( szValue, "%.5f", m_dfXMax );
CPLCreateXMLElementAndValue( psDSI, "ExtentXMax", szValue );
sprintf( szValue, "%.5f", m_dfYMin );
CPLCreateXMLElementAndValue( psDSI, "ExtentYMin", szValue );
sprintf( szValue, "%.5f", m_dfYMax );
CPLCreateXMLElementAndValue( psDSI, "ExtentYMax", szValue );
}
if( m_pszExtraInfo )
CPLCreateXMLElementAndValue( psDSI, "ExtraInfo", m_pszExtraInfo );
}
/* -------------------------------------------------------------------- */
/* emit property information. */
/* -------------------------------------------------------------------- */
for( iProperty = 0; iProperty < GetPropertyCount(); iProperty++ )
{
GMLPropertyDefn *poPDefn = GetProperty( iProperty );
CPLXMLNode *psPDefnNode;
const char *pszTypeName;
psPDefnNode = CPLCreateXMLNode( psRoot, CXT_Element, "PropertyDefn" );
CPLCreateXMLElementAndValue( psPDefnNode, "Name",
poPDefn->GetName() );
CPLCreateXMLElementAndValue( psPDefnNode, "ElementPath",
poPDefn->GetSrcElement() );
switch( poPDefn->GetType() )
{
case GMLPT_Untyped:
pszTypeName = "Untyped";
break;
case GMLPT_String:
pszTypeName = "String";
break;
case GMLPT_Integer:
pszTypeName = "Integer";
break;
case GMLPT_Real:
pszTypeName = "Real";
break;
case GMLPT_Complex:
pszTypeName = "Complex";
break;
}
CPLCreateXMLElementAndValue( psPDefnNode, "Type", pszTypeName );
if( EQUAL(pszTypeName,"String") )
{
char szMaxLength[48];
sprintf(szMaxLength, "%d", poPDefn->GetWidth());
CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szMaxLength );
}
}
return psRoot;
}
-------------- next part --------------
/**********************************************************************
* $Id: gmlpropertydefn.cpp,v 1.2 2004/01/19 16:54:44 warmerda Exp $
*
* Project: GML Reader
* Purpose: Implementation of GMLPropertyDefn
* Author: Frank Warmerdam, warmerdam at 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.
**********************************************************************
*
* $Log: gmlpropertydefn.cpp,v $
* Revision 1.2 2004/01/19 16:54:44 warmerda
* added logic to capture field types
*
* Revision 1.1 2002/01/04 19:46:30 warmerda
* New
*
*
**********************************************************************/
#include "gmlreader.h"
#include "cpl_conv.h"
/************************************************************************/
/* GMLPropertyDefn */
/************************************************************************/
GMLPropertyDefn::GMLPropertyDefn( const char *pszName,
const char *pszSrcElement )
{
m_pszName = CPLStrdup( pszName );
if( pszSrcElement != NULL )
m_pszSrcElement = CPLStrdup( pszSrcElement );
else
m_pszSrcElement = NULL;
m_eType = GMLPT_Untyped;
m_nWidth = 0;
}
/************************************************************************/
/* ~GMLPropertyDefn() */
/************************************************************************/
GMLPropertyDefn::~GMLPropertyDefn()
{
CPLFree( m_pszName );
CPLFree( m_pszSrcElement );
}
/************************************************************************/
/* SetSrcElement() */
/************************************************************************/
void GMLPropertyDefn::SetSrcElement( const char *pszSrcElement )
{
CPLFree( m_pszSrcElement );
if( pszSrcElement != NULL )
m_pszSrcElement = CPLStrdup( pszSrcElement );
else
m_pszSrcElement = NULL;
}
/************************************************************************/
/* AnalysePropertyValue() */
/* */
/* Examine the passed property value, and see if we need to */
/* make the field type more specific, or more general. */
/************************************************************************/
void GMLPropertyDefn::AnalysePropertyValue( const char *pszValue )
{
/* -------------------------------------------------------------------- */
/* We can't get more general than string, so at this point just */
/* give up on changing. */
/* -------------------------------------------------------------------- */
if( m_eType == GMLPT_String )
{
/* grow the Width to the length of the string passed in */
int nWidth;
nWidth = strlen(pszValue);
if ( m_nWidth < nWidth )
SetWidth( nWidth );
return;
}
/* -------------------------------------------------------------------- */
/* If it is a zero length string, just return. We can't deduce */
/* much from this. */
/* -------------------------------------------------------------------- */
if( *pszValue == '\0' )
return;
/* -------------------------------------------------------------------- */
/* Does the string consist entirely of numeric values? */
/* -------------------------------------------------------------------- */
int bIsReal = FALSE;
for(; *pszValue != '\0'; pszValue++ )
{
if( isdigit( *pszValue) || *pszValue == '-' || *pszValue == '+'
|| isspace( *pszValue ) )
/* do nothing */;
else if( *pszValue == '.' || *pszValue == 'D' || *pszValue == 'd'
|| *pszValue == 'E' || *pszValue == 'e' )
bIsReal = TRUE;
else
{
m_eType = GMLPT_String;
return;
}
}
if( m_eType == GMLPT_Untyped || m_eType == GMLPT_Integer )
{
if( bIsReal )
m_eType = GMLPT_Real;
else
m_eType = GMLPT_Integer;
}
}
-------------- next part --------------
/******************************************************************************
* $Id: gmlreader.h,v 1.9 2005/01/27 04:05:35 fwarmerdam Exp $
*
* Project: GML Reader
* Purpose: Public Declarations for OGR free GML Reader code.
* Author: Frank Warmerdam, warmerdam at 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.
******************************************************************************
*
* $Log: gmlreader.h,v $
* Revision 1.9 2005/01/27 04:05:35 fwarmerdam
* added ParseXSD
*
* Revision 1.8 2004/01/19 16:54:44 warmerda
* added logic to capture field types
*
* Revision 1.7 2003/05/21 03:48:35 warmerda
* Expand tabs
*
* Revision 1.6 2002/03/06 20:08:02 warmerda
* added tracking of extents, feature count and extrainfo
*
* Revision 1.5 2002/01/25 21:23:21 warmerda
* handle IGMLReader destructor properly in gmlreader.cpp
*
* Revision 1.4 2002/01/25 21:17:34 warmerda
* provided IGMLReader destructor implementation
*
* Revision 1.3 2002/01/25 20:38:01 warmerda
* added prescan and resetreading methods
*
* Revision 1.2 2002/01/24 17:39:08 warmerda
* added xml serialization and geometry support
*
* Revision 1.1 2002/01/04 19:46:30 warmerda
* New
*/
#ifndef _GMLREADER_H_INCLUDED
#define _GMLREADER_H_INCLUDED
#include "cpl_port.h"
#include "cpl_minixml.h"
typedef enum {
GMLPT_Untyped = 0,
GMLPT_String = 1,
GMLPT_Integer = 2,
GMLPT_Real = 3,
GMLPT_Complex = 4
} GMLPropertyType;
/************************************************************************/
/* GMLPropertyDefn */
/************************************************************************/
class CPL_DLL GMLPropertyDefn
{
char *m_pszName;
GMLPropertyType m_eType;
int m_nWidth;
char *m_pszSrcElement;
public:
GMLPropertyDefn( const char *pszName, const char *pszSrcElement=NULL );
~GMLPropertyDefn();
const char *GetName() { return m_pszName; } const
GMLPropertyType GetType() { return m_eType; } const
void SetType( GMLPropertyType eType ) { m_eType = eType; }
void SetWidth( int nWidth) { m_nWidth = nWidth; }
int GetWidth() { return m_nWidth; }
void SetSrcElement( const char *pszSrcElement );
const char *GetSrcElement() { return m_pszSrcElement; }
void AnalysePropertyValue( const char * );
};
/************************************************************************/
/* GMLFeatureClass */
/************************************************************************/
class CPL_DLL GMLFeatureClass
{
char *m_pszName;
char *m_pszElementName;
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;
public:
GMLFeatureClass( const char *pszName = "" );
~GMLFeatureClass();
const char *GetElementName() const;
void SetElementName( const char *pszElementName );
const char *GetGeometryElement() const { return m_pszGeometryElement; }
void SetGeometryElement( const char *pszElementName );
const char *GetName() { return m_pszName; } const
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 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 );
void SetExtents( double dfXMin, double dfXMax,
double dFYMin, double dfYMax );
int GetExtents( double *pdfXMin, double *pdfXMax,
double *pdFYMin, double *pdfYMax );
CPLXMLNode *SerializeToXML();
int InitializeFromXML( CPLXMLNode * );
};
/************************************************************************/
/* GMLFeature */
/************************************************************************/
class CPL_DLL GMLFeature
{
GMLFeatureClass *m_poClass;
char *m_pszFID;
int m_nPropertyCount;
char **m_papszProperty;
char *m_pszGeometry;
public:
GMLFeature( GMLFeatureClass * );
~GMLFeature();
GMLFeatureClass*GetClass() const { return m_poClass; }
void SetGeometryDirectly( char * );
const char *GetGeometry() const { return m_pszGeometry; }
void SetProperty( int i, const char *pszValue );
void SetProperty( const char *pszName, const char *pszValue )
{ SetProperty( m_poClass->GetPropertyIndex(pszName), pszValue ); }
const char *GetProperty( int i ) const;
const char *GetProperty( const char *pszName ) const
{ return GetProperty( m_poClass->GetPropertyIndex(pszName) ); }
const char *GetFID() const { return m_pszFID; }
void SetFID( const char *pszFID );
void Dump( FILE *fp );
};
/************************************************************************/
/* 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 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 ParseXSD( const char *pszFile ) = 0;
virtual int PrescanForSchema( int bGetExtents = TRUE ) = 0;
};
IGMLReader *CreateGMLReader();
#endif /* _GMLREADER_H_INCLUDED */
More information about the Gdal-dev
mailing list