Skip to content

Commit

Permalink
QgsGml: append wkb fragments to the last set not the first (fixes #7991)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 30, 2013
1 parent 059c2c0 commit f3d79a8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsapplication.cpp
Expand Up @@ -283,7 +283,7 @@ void QgsApplication::setPrefixPath( const QString thePrefixPath, bool useDefault
ABISYM( mPrefixPath ).chop( 4 );
}
#endif
if ( useDefaultPaths )
if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
{
setPluginPath( ABISYM( mPrefixPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
setPkgDataPath( ABISYM( mPrefixPath ) + "/" + QString( QGIS_DATA_SUBDIR ) );
Expand Down
30 changes: 12 additions & 18 deletions src/core/qgsgml.cpp
Expand Up @@ -223,28 +223,22 @@ void QgsGml::startElement( const XML_Char* el, const XML_Char** attr )
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Polygon" )
{
QList<unsigned char*> wkbList;
QList<int> wkbSizeList;
mCurrentWKBFragments.push_back( wkbList );
mCurrentWKBFragmentSizes.push_back( wkbSizeList );
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
mCurrentWKBFragmentSizes.push_back( QList<int>() );
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPoint" )
{
mParseModeStack.push( QgsGml::multiPoint );
//we need one nested list for intermediate WKB
QList<unsigned char*> wkbList;
QList<int> wkbSizeList;
mCurrentWKBFragments.push_back( wkbList );
mCurrentWKBFragmentSizes.push_back( wkbSizeList );
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
mCurrentWKBFragmentSizes.push_back( QList<int>() );
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiLineString" )
{
mParseModeStack.push( QgsGml::multiLine );
//we need one nested list for intermediate WKB
QList<unsigned char*> wkbList;
QList<int> wkbSizeList;
mCurrentWKBFragments.push_back( wkbList );
mCurrentWKBFragmentSizes.push_back( wkbSizeList );
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
mCurrentWKBFragmentSizes.push_back( QList<int>() );
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPolygon" )
{
Expand Down Expand Up @@ -381,8 +375,8 @@ void QgsGml::endElement( const XML_Char* el )
}
if ( !mCurrentWKBFragments.isEmpty() )
{
mCurrentWKBFragments.begin()->push_back( wkb );
mCurrentWKBFragmentSizes.begin()->push_back( wkbSize );
mCurrentWKBFragments.last().push_back( wkb );
mCurrentWKBFragmentSizes.last().push_back( wkbSize );
}
else
{
Expand Down Expand Up @@ -428,8 +422,8 @@ void QgsGml::endElement( const XML_Char* el )
}
if ( !mCurrentWKBFragments.isEmpty() )
{
mCurrentWKBFragments.begin()->push_back( wkb );
mCurrentWKBFragmentSizes.begin()->push_back( wkbSize );
mCurrentWKBFragments.last().push_back( wkb );
mCurrentWKBFragmentSizes.last().push_back( wkbSize );
}
else
{
Expand All @@ -456,8 +450,8 @@ void QgsGml::endElement( const XML_Char* el )
}
if ( !mCurrentWKBFragments.isEmpty() )
{
mCurrentWKBFragments.begin()->push_back( wkb );
mCurrentWKBFragmentSizes.begin()->push_back( wkbSize );
mCurrentWKBFragments.last().push_back( wkb );
mCurrentWKBFragmentSizes.last().push_back( wkbSize );
}
else
{
Expand Down
33 changes: 24 additions & 9 deletions src/core/qgsgml.h
Expand Up @@ -34,7 +34,10 @@
class QgsRectangle;
class QgsCoordinateReferenceSystem;

/**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*/
/**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 */
class CORE_EXPORT QgsGml: public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -117,26 +120,33 @@ class CORE_EXPORT QgsGml: public QObject
/**Reads attribute srsName="EpsgCrsId:..."
@param epsgNr result
@param attr attribute strings
@return 0 in case of success*/
@return 0 in case of success
*/
int readEpsgFromAttribute( int& epsgNr, const XML_Char** attr ) const;
/**Reads attribute as string
@param attributeName
@param attr
@return attribute value or an empty string if no such attribute*/
@return attribute value or an empty string if no such attribute
*/
QString readAttribute( const QString& attributeName, const XML_Char** attr ) const;
/**Creates a rectangle from a coordinate string.
@return 0 in case of success*/
int createBBoxFromCoordinateString( QgsRectangle &bb, const QString& coordString ) const;
/**Creates a set of points from a coordinate string.
@param points list that will contain the created points
@param coordString the text containing the coordinates
@return 0 in case of success*/
@return 0 in case of success
*/
int pointsFromCoordinateString( QList<QgsPoint>& points, const QString& coordString ) const;

int getPointWKB( unsigned char** wkb, int* size, const QgsPoint& ) const;
int getLineWKB( unsigned char** wkb, int* size, const QList<QgsPoint>& lineCoordinates ) const;
int getRingWKB( unsigned char** wkb, int* size, const QList<QgsPoint>& ringCoordinates ) const;
/**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.*/
/**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.
*/
int createMultiLineFromFragments();
int createMultiPointFromFragments();
int createPolygonFromFragments();
Expand All @@ -146,9 +156,11 @@ class CORE_EXPORT QgsGml: public QObject

/**Returns pointer to main window or 0 if it does not exist*/
QWidget* findMainWindow() const;
/**This function evaluates the layer bounding box from the features and sets it to mExtent.
Less efficient compared to reading the bbox from the provider, so it is only done if the wfs server
does not provider extent information.*/
/**This function evaluates the layer bounding box from the features and
* sets it to mExtent. Less efficient compared to reading the bbox from
* the provider, so it is only done if the wfs server does not provider
* extent information.
*/
void calculateExtentFromFeatures();

/** Get safely (if empty) top from mode stack */
Expand Down Expand Up @@ -191,7 +203,10 @@ class CORE_EXPORT QgsGml: public QObject
/**The total WKB size for a feature*/
int mCurrentWKBSize;
QgsRectangle mCurrentExtent;
/**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*/
/**WKB intermediate storage during parsing. For points and lines, no
* intermediate WKB is stored at all. For multipoints and multilines and
* polygons, only one nested list is used. For multipolygons, both nested lists
* are used*/
QList< QList<unsigned char*> > mCurrentWKBFragments;
/**Similar to mCurrentWKB, but only the size*/
QList< QList<int> > mCurrentWKBFragmentSizes;
Expand Down

0 comments on commit f3d79a8

Please sign in to comment.