Skip to content

Commit f3d79a8

Browse files
committed
QgsGml: append wkb fragments to the last set not the first (fixes #7991)
1 parent 059c2c0 commit f3d79a8

File tree

3 files changed

+37
-28
lines changed

3 files changed

+37
-28
lines changed

src/core/qgsapplication.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void QgsApplication::setPrefixPath( const QString thePrefixPath, bool useDefault
283283
ABISYM( mPrefixPath ).chop( 4 );
284284
}
285285
#endif
286-
if ( useDefaultPaths )
286+
if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
287287
{
288288
setPluginPath( ABISYM( mPrefixPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
289289
setPkgDataPath( ABISYM( mPrefixPath ) + "/" + QString( QGIS_DATA_SUBDIR ) );

src/core/qgsgml.cpp

+12-18
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,22 @@ void QgsGml::startElement( const XML_Char* el, const XML_Char** attr )
223223
}
224224
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Polygon" )
225225
{
226-
QList<unsigned char*> wkbList;
227-
QList<int> wkbSizeList;
228-
mCurrentWKBFragments.push_back( wkbList );
229-
mCurrentWKBFragmentSizes.push_back( wkbSizeList );
226+
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
227+
mCurrentWKBFragmentSizes.push_back( QList<int>() );
230228
}
231229
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPoint" )
232230
{
233231
mParseModeStack.push( QgsGml::multiPoint );
234232
//we need one nested list for intermediate WKB
235-
QList<unsigned char*> wkbList;
236-
QList<int> wkbSizeList;
237-
mCurrentWKBFragments.push_back( wkbList );
238-
mCurrentWKBFragmentSizes.push_back( wkbSizeList );
233+
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
234+
mCurrentWKBFragmentSizes.push_back( QList<int>() );
239235
}
240236
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiLineString" )
241237
{
242238
mParseModeStack.push( QgsGml::multiLine );
243239
//we need one nested list for intermediate WKB
244-
QList<unsigned char*> wkbList;
245-
QList<int> wkbSizeList;
246-
mCurrentWKBFragments.push_back( wkbList );
247-
mCurrentWKBFragmentSizes.push_back( wkbSizeList );
240+
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
241+
mCurrentWKBFragmentSizes.push_back( QList<int>() );
248242
}
249243
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPolygon" )
250244
{
@@ -381,8 +375,8 @@ void QgsGml::endElement( const XML_Char* el )
381375
}
382376
if ( !mCurrentWKBFragments.isEmpty() )
383377
{
384-
mCurrentWKBFragments.begin()->push_back( wkb );
385-
mCurrentWKBFragmentSizes.begin()->push_back( wkbSize );
378+
mCurrentWKBFragments.last().push_back( wkb );
379+
mCurrentWKBFragmentSizes.last().push_back( wkbSize );
386380
}
387381
else
388382
{
@@ -428,8 +422,8 @@ void QgsGml::endElement( const XML_Char* el )
428422
}
429423
if ( !mCurrentWKBFragments.isEmpty() )
430424
{
431-
mCurrentWKBFragments.begin()->push_back( wkb );
432-
mCurrentWKBFragmentSizes.begin()->push_back( wkbSize );
425+
mCurrentWKBFragments.last().push_back( wkb );
426+
mCurrentWKBFragmentSizes.last().push_back( wkbSize );
433427
}
434428
else
435429
{
@@ -456,8 +450,8 @@ void QgsGml::endElement( const XML_Char* el )
456450
}
457451
if ( !mCurrentWKBFragments.isEmpty() )
458452
{
459-
mCurrentWKBFragments.begin()->push_back( wkb );
460-
mCurrentWKBFragmentSizes.begin()->push_back( wkbSize );
453+
mCurrentWKBFragments.last().push_back( wkb );
454+
mCurrentWKBFragmentSizes.last().push_back( wkbSize );
461455
}
462456
else
463457
{

src/core/qgsgml.h

+24-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
class QgsRectangle;
3535
class QgsCoordinateReferenceSystem;
3636

37-
/**This class reads data from a WFS server or alternatively from a GML file. It uses the expat XML parser and an event based model to keep performance high. The parsing starts when the first data arrives, it does not wait until the request is finished*/
37+
/**This class reads data from a WFS server or alternatively from a GML file. It
38+
* uses the expat XML parser and an event based model to keep performance high.
39+
* The parsing starts when the first data arrives, it does not wait until the
40+
* request is finished */
3841
class CORE_EXPORT QgsGml: public QObject
3942
{
4043
Q_OBJECT
@@ -117,26 +120,33 @@ class CORE_EXPORT QgsGml: public QObject
117120
/**Reads attribute srsName="EpsgCrsId:..."
118121
@param epsgNr result
119122
@param attr attribute strings
120-
@return 0 in case of success*/
123+
@return 0 in case of success
124+
*/
121125
int readEpsgFromAttribute( int& epsgNr, const XML_Char** attr ) const;
122126
/**Reads attribute as string
123127
@param attributeName
124128
@param attr
125-
@return attribute value or an empty string if no such attribute*/
129+
@return attribute value or an empty string if no such attribute
130+
*/
126131
QString readAttribute( const QString& attributeName, const XML_Char** attr ) const;
127132
/**Creates a rectangle from a coordinate string.
128133
@return 0 in case of success*/
129134
int createBBoxFromCoordinateString( QgsRectangle &bb, const QString& coordString ) const;
130135
/**Creates a set of points from a coordinate string.
131136
@param points list that will contain the created points
132137
@param coordString the text containing the coordinates
133-
@return 0 in case of success*/
138+
@return 0 in case of success
139+
*/
134140
int pointsFromCoordinateString( QList<QgsPoint>& points, const QString& coordString ) const;
135141

136142
int getPointWKB( unsigned char** wkb, int* size, const QgsPoint& ) const;
137143
int getLineWKB( unsigned char** wkb, int* size, const QList<QgsPoint>& lineCoordinates ) const;
138144
int getRingWKB( unsigned char** wkb, int* size, const QList<QgsPoint>& ringCoordinates ) const;
139-
/**Creates a multiline from the information in mCurrentWKBFragments and mCurrentWKBFragmentSizes. Assign the result. The multiline is in mCurrentWKB and mCurrentWKBSize. The function deletes the memory in mCurrentWKBFragments. Returns 0 in case of success.*/
145+
/**Creates a multiline from the information in mCurrentWKBFragments and
146+
* mCurrentWKBFragmentSizes. Assign the result. The multiline is in
147+
* mCurrentWKB and mCurrentWKBSize. The function deletes the memory in
148+
* mCurrentWKBFragments. Returns 0 in case of success.
149+
*/
140150
int createMultiLineFromFragments();
141151
int createMultiPointFromFragments();
142152
int createPolygonFromFragments();
@@ -146,9 +156,11 @@ class CORE_EXPORT QgsGml: public QObject
146156

147157
/**Returns pointer to main window or 0 if it does not exist*/
148158
QWidget* findMainWindow() const;
149-
/**This function evaluates the layer bounding box from the features and sets it to mExtent.
150-
Less efficient compared to reading the bbox from the provider, so it is only done if the wfs server
151-
does not provider extent information.*/
159+
/**This function evaluates the layer bounding box from the features and
160+
* sets it to mExtent. Less efficient compared to reading the bbox from
161+
* the provider, so it is only done if the wfs server does not provider
162+
* extent information.
163+
*/
152164
void calculateExtentFromFeatures();
153165

154166
/** Get safely (if empty) top from mode stack */
@@ -191,7 +203,10 @@ class CORE_EXPORT QgsGml: public QObject
191203
/**The total WKB size for a feature*/
192204
int mCurrentWKBSize;
193205
QgsRectangle mCurrentExtent;
194-
/**WKB intermediate storage during parsing. For points and lines, no intermediate WKB is stored at all. For multipoins and multilines and polygons, only one nested list is used. For multipolygons, both nested lists are used*/
206+
/**WKB intermediate storage during parsing. For points and lines, no
207+
* intermediate WKB is stored at all. For multipoints and multilines and
208+
* polygons, only one nested list is used. For multipolygons, both nested lists
209+
* are used*/
195210
QList< QList<unsigned char*> > mCurrentWKBFragments;
196211
/**Similar to mCurrentWKB, but only the size*/
197212
QList< QList<int> > mCurrentWKBFragmentSizes;

0 commit comments

Comments
 (0)