Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix srsDimension parsing in GML
- Loading branch information
Showing
with
16 additions
and
5 deletions.
-
+13
−4
src/core/qgsgml.cpp
-
+3
−1
src/core/qgsgml.h
|
@@ -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; |
|
|