mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Reduce wkb parsing
This commit is contained in:
parent
123a60e651
commit
c423d64a8e
@ -187,7 +187,7 @@ class QgsSymbolV2
|
||||
* Creates a point in screen coordinates from a wkb string in map
|
||||
* coordinates
|
||||
*/
|
||||
static const unsigned char* _getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb );
|
||||
static void _getPoint( QPointF& pt /Out/, QgsRenderContext& context, const QgsPoint& point );
|
||||
/**
|
||||
* Creates a line string in screen coordinates from a wkb string in map
|
||||
* coordinates
|
||||
|
@ -104,25 +104,6 @@ QgsSymbolV2::QgsSymbolV2( SymbolType type, const QgsSymbolLayerV2List& layers )
|
||||
}
|
||||
}
|
||||
|
||||
const unsigned char* QgsSymbolV2::_getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb )
|
||||
{
|
||||
QgsConstWkbPtr wkbPtr( wkb + 1 );
|
||||
unsigned int wkbType;
|
||||
wkbPtr >> wkbType >> pt.rx() >> pt.ry();
|
||||
|
||||
if (( QgsWKBTypes::Type )wkbType == QgsWKBTypes::Point25D || ( QgsWKBTypes::Type )wkbType == QgsWKBTypes::PointZ )
|
||||
wkbPtr += sizeof( double );
|
||||
|
||||
if ( context.coordinateTransform() )
|
||||
{
|
||||
double z = 0; // dummy variable for coordiante transform
|
||||
context.coordinateTransform()->transformInPlace( pt.rx(), pt.ry(), z );
|
||||
}
|
||||
|
||||
context.mapToPixel().transformInPlace( pt.rx(), pt.ry() );
|
||||
|
||||
return wkbPtr;
|
||||
}
|
||||
|
||||
const unsigned char* QgsSymbolV2::_getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent )
|
||||
{
|
||||
@ -690,26 +671,15 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
|
||||
context.setGeometry( geom->geometry() );
|
||||
|
||||
//convert curve types to normal point/line/polygon ones
|
||||
switch ( QgsWKBTypes::flatType( geom->geometry()->wkbType() ) )
|
||||
if ( geom->geometry()->hasCurvedSegments() )
|
||||
{
|
||||
case QgsWKBTypes::CurvePolygon:
|
||||
case QgsWKBTypes::CircularString:
|
||||
case QgsWKBTypes::CompoundCurve:
|
||||
case QgsWKBTypes::MultiSurface:
|
||||
case QgsWKBTypes::MultiCurve:
|
||||
QgsAbstractGeometryV2* g = geom->geometry()->segmentize();
|
||||
if ( !g )
|
||||
{
|
||||
QgsAbstractGeometryV2* g = geom->geometry()->segmentize();
|
||||
if ( !g )
|
||||
{
|
||||
return;
|
||||
}
|
||||
segmentizedGeometry = new QgsGeometry( g );
|
||||
deleteSegmentizedGeometry = true;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
segmentizedGeometry = new QgsGeometry( g );
|
||||
deleteSegmentizedGeometry = true;
|
||||
}
|
||||
|
||||
switch ( QgsWKBTypes::flatType( segmentizedGeometry->geometry()->wkbType() ) )
|
||||
@ -722,8 +692,10 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
|
||||
QgsDebugMsg( "point can be drawn only with marker symbol!" );
|
||||
break;
|
||||
}
|
||||
_getPoint( pt, context, segmentizedGeometry->asWkb() );
|
||||
|
||||
_getPoint( pt, context, segmentizedGeometry->asPoint() );
|
||||
( static_cast<QgsMarkerSymbolV2*>( this ) )->renderPoint( pt, &feature, context, layer, selected );
|
||||
|
||||
if ( context.testFlag( QgsRenderContext::DrawSymbolBounds ) )
|
||||
{
|
||||
//draw debugging rect
|
||||
@ -769,14 +741,11 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
|
||||
break;
|
||||
}
|
||||
|
||||
QgsConstWkbPtr wkbPtr( segmentizedGeometry->asWkb() + 1 + sizeof( int ) );
|
||||
unsigned int num;
|
||||
wkbPtr >> num;
|
||||
const unsigned char* ptr = wkbPtr;
|
||||
QgsMultiPoint multiPoint = segmentizedGeometry->asMultiPoint();
|
||||
|
||||
for ( unsigned int i = 0; i < num; ++i )
|
||||
Q_FOREACH ( const QgsPoint& point, multiPoint )
|
||||
{
|
||||
ptr = QgsConstWkbPtr( _getPoint( pt, context, ptr ) );
|
||||
_getPoint( pt, context, point );
|
||||
static_cast<QgsMarkerSymbolV2*>( this )->renderPoint( pt, &feature, context, layer, selected );
|
||||
}
|
||||
}
|
||||
@ -888,8 +857,7 @@ QgsSymbolV2RenderContext::QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymb
|
||||
mSelected( selected ),
|
||||
mRenderHints( renderHints ),
|
||||
mFeature( f ),
|
||||
mFields( fields ),
|
||||
mExpressionContext( c.expressionContext() )
|
||||
mFields( fields )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include "qgsmapunitscale.h"
|
||||
#include "qgsgeometry.h"
|
||||
|
||||
class QColor;
|
||||
class QImage;
|
||||
@ -242,15 +243,24 @@ class CORE_EXPORT QgsSymbolV2
|
||||
QgsSymbolV2( SymbolType type, const QgsSymbolLayerV2List& layers ); // can't be instantiated
|
||||
|
||||
/**
|
||||
* Creates a point in screen coordinates from a wkb string in map
|
||||
* coordinates
|
||||
* Creates a point in screen coordinates from a QgsPoint in map coordinates
|
||||
*/
|
||||
static const unsigned char* _getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb );
|
||||
static inline void _getPoint( QPointF& pt, QgsRenderContext& context, const QgsPoint& point )
|
||||
{
|
||||
if ( context.coordinateTransform() )
|
||||
pt = context.coordinateTransform()->transform( point ).toQPointF();
|
||||
else
|
||||
pt = point.toQPointF();
|
||||
|
||||
context.mapToPixel().transformInPlace( pt.rx(), pt.ry() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a line string in screen coordinates from a wkb string in map
|
||||
* coordinates
|
||||
*/
|
||||
static const unsigned char* _getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
|
||||
|
||||
/**
|
||||
* Creates a polygon in screen coordinates from a wkb string in map
|
||||
* coordinates
|
||||
@ -303,8 +313,6 @@ class CORE_EXPORT QgsSymbolV2RenderContext
|
||||
QgsRenderContext& renderContext() { return mRenderContext; }
|
||||
const QgsRenderContext& renderContext() const { return mRenderContext; }
|
||||
|
||||
const QgsExpressionContext& expressionContext() const { return mExpressionContext; }
|
||||
|
||||
/** Sets the original value variable value for data defined symbology
|
||||
* @param value value for original value variable. This usually represents the symbol property value
|
||||
* before any data defined overrides have been applied.
|
||||
@ -354,7 +362,6 @@ class CORE_EXPORT QgsSymbolV2RenderContext
|
||||
int mRenderHints;
|
||||
const QgsFeature* mFeature; //current feature
|
||||
const QgsFields* mFields;
|
||||
QgsExpressionContext mExpressionContext;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user