Skip to content
Permalink
Browse files

QgsGml: append wkb fragments to the last set not the first (fixes #7991)

  • Loading branch information
jef-n committed Jun 30, 2013
1 parent 059c2c0 commit f3d79a88398f4c28e0377ddfb95d5c0a4abcc2bb
Showing with 37 additions and 28 deletions.
  1. +1 −1 src/core/qgsapplication.cpp
  2. +12 −18 src/core/qgsgml.cpp
  3. +24 −9 src/core/qgsgml.h
@@ -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 ) );
@@ -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" )
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
@@ -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();
@@ -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 */
@@ -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;

0 comments on commit f3d79a8

Please sign in to comment.
You can’t perform that action at this time.