mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Merge pull request #4898 from tcoupin/master
Fix srsDimension parsing in GML, fixes #15721
This commit is contained in:
commit
b8616ec513
@ -480,6 +480,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char *el, const XML_Char **a
|
||||
const int nsLen = ( pszSep ) ? ( int )( pszSep - el ) : 0;
|
||||
const int localNameLen = ( pszSep ) ? ( int )( elLen - nsLen ) - 1 : elLen;
|
||||
ParseMode parseMode( mParseModeStack.isEmpty() ? None : mParseModeStack.top() );
|
||||
int elDimension = 0;
|
||||
|
||||
// Figure out if the GML namespace is GML_NAMESPACE or GML32_NAMESPACE
|
||||
if ( !mGMLNameSpaceURIPtr && pszSep )
|
||||
@ -538,14 +539,14 @@ void QgsGmlStreamingParser::startElement( const XML_Char *el, const XML_Char **a
|
||||
mParseModeStack.push( QgsGmlStreamingParser::PosList );
|
||||
mCoorMode = QgsGmlStreamingParser::PosList;
|
||||
mStringCash.clear();
|
||||
if ( mDimension == 0 )
|
||||
if ( elDimension == 0 )
|
||||
{
|
||||
QString srsDimension = readAttribute( QStringLiteral( "srsDimension" ), attr );
|
||||
bool ok;
|
||||
int dimension = srsDimension.toInt( &ok );
|
||||
if ( ok )
|
||||
{
|
||||
mDimension = dimension;
|
||||
elDimension = dimension;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -803,7 +804,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char *el, const XML_Char **a
|
||||
if ( !mGeometryString.empty() )
|
||||
isGeom = true;
|
||||
|
||||
if ( mDimension == 0 && isGeom )
|
||||
if ( elDimension == 0 && isGeom )
|
||||
{
|
||||
// srsDimension can also be set on the top geometry element
|
||||
// e.g. https://data.linz.govt.nz/services;key=XXXXXXXX/wfs?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=data.linz.govt.nz:layer-524
|
||||
@ -812,10 +813,16 @@ void QgsGmlStreamingParser::startElement( const XML_Char *el, const XML_Char **a
|
||||
int dimension = srsDimension.toInt( &ok );
|
||||
if ( ok )
|
||||
{
|
||||
mDimension = dimension;
|
||||
elDimension = dimension;
|
||||
}
|
||||
}
|
||||
|
||||
if ( elDimension != 0 )
|
||||
{
|
||||
mDimension = elDimension;
|
||||
}
|
||||
mDimensionStack.push( mDimension );
|
||||
|
||||
if ( mEpsg == 0 && isGeom )
|
||||
{
|
||||
if ( readEpsgFromAttribute( mEpsg, attr ) != 0 )
|
||||
@ -842,6 +849,8 @@ void QgsGmlStreamingParser::endElement( const XML_Char *el )
|
||||
const int localNameLen = ( pszSep ) ? ( int )( elLen - nsLen ) - 1 : elLen;
|
||||
ParseMode parseMode( mParseModeStack.isEmpty() ? None : mParseModeStack.top() );
|
||||
|
||||
mDimension = mDimensionStack.isEmpty() ? 0 : mDimensionStack.top() ;
|
||||
|
||||
const bool isGMLNS = ( nsLen == mGMLNameSpaceURI.size() && mGMLNameSpaceURIPtr && memcmp( el, mGMLNameSpaceURIPtr, nsLen ) == 0 );
|
||||
|
||||
if ( parseMode == Coordinate && isGMLNS && LOCALNAME_EQUALS( "coordinates" ) )
|
||||
|
@ -298,7 +298,9 @@ class CORE_EXPORT QgsGmlStreamingParser
|
||||
QString mCoordinateSeparator;
|
||||
//! Tuple separator for coordinate strings. Usually " "
|
||||
QString mTupleSeparator;
|
||||
//! Number of dimensions in pos or posList
|
||||
//! Keep track about number of dimensions in pos or posList
|
||||
QStack<int> mDimensionStack;
|
||||
//! Number of dimensions in pos or posList for the current geometry
|
||||
int mDimension;
|
||||
//! Coordinates mode, coordinate or posList
|
||||
ParseMode mCoorMode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user