another fix for gml wkb assembly (fixes #14315)

This commit is contained in:
Juergen E. Fischer 2016-02-16 22:12:32 +01:00
parent 1ffccf05c9
commit d2679d6dbd
3 changed files with 15 additions and 19 deletions

View File

@ -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 )

View File

@ -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();

View File

@ -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