Skip to content
Permalink
Browse files

another fix for gml wkb assembly (fixes #14315)

  • Loading branch information
jef-n committed Feb 16, 2016
1 parent 1ffccf0 commit d2679d6dbd80498fa9545dbb26ce7ad48a70df1c
Showing with 15 additions and 19 deletions.
  1. +0 −2 src/core/geometry/qgsgeometry.cpp
  2. +14 −14 src/core/qgsgml.cpp
  3. +1 −3 src/core/qgsgml.h
@@ -235,8 +235,6 @@ QgsGeometry* QgsGeometry::fromRect( const QgsRectangle& rect )

void QgsGeometry::fromWkb( unsigned char *wkb, int length )
{
Q_UNUSED( length );

detach( false );

if ( d->geometry )
@@ -377,10 +377,10 @@ void QgsGml::endElement( const XML_Char* el )
else if ( theParseMode == feature && localName == mTypeName )
{
Q_ASSERT( mCurrentFeature );
if ( mCurrentWKBSize > 0 )
if ( mCurrentWKB.size() > 0 )
{
QgsGeometry *g = new QgsGeometry();
g->fromWkb( mCurrentWKB, mCurrentWKBSize );
g->fromWkb( mCurrentWKB, mCurrentWKB.size() );
mCurrentFeature->setGeometry( g );
mCurrentWKB = QgsWkbPtr( nullptr, 0 );
}
@@ -767,10 +767,10 @@ int QgsGml::getRingWKB( QgsWkbPtr &wkbPtr, const QList<QgsPoint>& ringCoordinate

int QgsGml::createMultiLineFromFragments()
{
mCurrentWKBSize = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
mCurrentWKB = QgsWkbPtr( new unsigned char[mCurrentWKBSize], mCurrentWKBSize );
int size = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
mCurrentWKB = QgsWkbPtr( new unsigned char[size], size );

QgsWkbPtr wkbPtr( mCurrentWKB, mCurrentWKBSize );
QgsWkbPtr wkbPtr( mCurrentWKB );

wkbPtr << mEndian << QGis::WKBMultiLineString << mCurrentWKBFragments.constBegin()->size();

@@ -790,8 +790,8 @@ int QgsGml::createMultiLineFromFragments()

int QgsGml::createMultiPointFromFragments()
{
mCurrentWKBSize = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
mCurrentWKB = QgsWkbPtr( new unsigned char[mCurrentWKBSize], mCurrentWKBSize );
int size = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
mCurrentWKB = QgsWkbPtr( new unsigned char[size], size );

QgsWkbPtr wkbPtr( mCurrentWKB );
wkbPtr << mEndian << QGis::WKBMultiPoint << mCurrentWKBFragments.constBegin()->size();
@@ -812,8 +812,8 @@ int QgsGml::createMultiPointFromFragments()

int QgsGml::createPolygonFromFragments()
{
mCurrentWKBSize = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
mCurrentWKB = QgsWkbPtr( new unsigned char[mCurrentWKBSize], mCurrentWKBSize );
int size = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
mCurrentWKB = QgsWkbPtr( new unsigned char[size], size );

QgsWkbPtr wkbPtr( mCurrentWKB );
wkbPtr << mEndian << QGis::WKBPolygon << mCurrentWKBFragments.constBegin()->size();
@@ -833,12 +833,12 @@ int QgsGml::createPolygonFromFragments()

int QgsGml::createMultiPolygonFromFragments()
{
mCurrentWKBSize = 0;
mCurrentWKBSize += 1 + 2 * sizeof( int );
mCurrentWKBSize += totalWKBFragmentSize();
mCurrentWKBSize += mCurrentWKBFragments.size() * ( 1 + 2 * sizeof( int ) ); //fragments are just the rings
int size = 0;
size += 1 + 2 * sizeof( int );
size += totalWKBFragmentSize();
size += mCurrentWKBFragments.size() * ( 1 + 2 * sizeof( int ) ); //fragments are just the rings

mCurrentWKB = QgsWkbPtr( new unsigned char[mCurrentWKBSize], mCurrentWKBSize );
mCurrentWKB = QgsWkbPtr( new unsigned char[size], size );

QgsWkbPtr wkbPtr( mCurrentWKB );
wkbPtr << ( char ) mEndian << QGis::WKBMultiPolygon << mCurrentWKBFragments.size();
@@ -170,7 +170,7 @@ class CORE_EXPORT QgsGml : public QObject
int getRingWKB( QgsWkbPtr &wkbPtr, 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
* mCurrentWKB. The function deletes the memory in
* mCurrentWKBFragments. Returns 0 in case of success.
*/
int createMultiLineFromFragments();
@@ -226,8 +226,6 @@ class CORE_EXPORT QgsGml : public QObject
int mFeatureCount;
/** The total WKB for a feature*/
QgsWkbPtr mCurrentWKB;
/** 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 multipoints and multilines and

0 comments on commit d2679d6

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