Skip to content

Commit 5e26fbd

Browse files
committed
rename other canbeGeneralizedByMapBoundingBox methods to isGeneralizableByMapBoundingBox
1 parent d9e8a94 commit 5e26fbd

File tree

6 files changed

+27
-24
lines changed

6 files changed

+27
-24
lines changed

python/core/qgsgeometrysimplifier.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class QgsAbstractGeometrySimplifier
1717
// MapToPixel simplification helper methods
1818
public:
1919
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
20-
static bool canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
20+
static bool isGeneralizableByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
2121
//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance
22-
static bool canbeGeneralizedByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
22+
static bool isGeneralizableByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
2323
};
2424

2525
/***************************************************************************/

src/core/qgsgeometrysimplifier.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,22 @@ QgsAbstractGeometrySimplifier::~QgsAbstractGeometrySimplifier()
2222
}
2323

2424
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
25-
bool QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol )
25+
bool QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol )
2626
{
2727
return ( envelope.xMaximum() - envelope.xMinimum() ) < mapToPixelTol && ( envelope.yMaximum() - envelope.yMinimum() ) < mapToPixelTol;
2828
}
2929

3030
//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance
31-
bool QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol )
31+
bool QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol )
3232
{
33-
double xmin = std::numeric_limits<double>::max(), x, y;
34-
double ymin = std::numeric_limits<double>::max();
35-
double xmax = -std::numeric_limits<double>::max();
36-
double ymax = -std::numeric_limits<double>::max();
33+
QgsRectangle r;
34+
r.setMinimal();
3735

3836
for ( int i = 0, numPoints = points.size(); i < numPoints; ++i )
3937
{
40-
x = points[i].x();
41-
y = points[i].y();
42-
43-
if ( xmin > x ) xmin = x;
44-
if ( ymin > y ) ymin = y;
45-
if ( xmax < x ) xmax = x;
46-
if ( ymax < y ) ymax = y;
38+
r.combineExtentWith( points[i].x(), points[i].y() );
4739
}
48-
return canbeGeneralizedByDeviceBoundingBox( QgsRectangle( xmin, ymin, xmax, ymax ), mapToPixelTol );
40+
return isGeneralizableByDeviceBoundingBox( r, mapToPixelTol );
4941
}
5042

5143
/***************************************************************************/

src/core/qgsgeometrysimplifier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class CORE_EXPORT QgsAbstractGeometrySimplifier
3535
// MapToPixel simplification helper methods
3636
public:
3737
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
38-
static bool canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
38+
static bool isGeneralizableByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
3939
//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance
40-
static bool canbeGeneralizedByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
40+
static bool isGeneralizableByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
4141
};
4242

4343
/***************************************************************************/

src/core/symbology-ng/qgslinesymbollayerv2.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
258258
p->setPen( context.selected() ? mSelPen : mPen );
259259

260260
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
261-
if ( points.size() <= 2 && ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
261+
if ( points.size() <= 2 &&
262+
( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) &&
263+
QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) &&
264+
( p->renderHints() & QPainter::Antialiasing ) )
262265
{
263266
p->setRenderHint( QPainter::Antialiasing, false );
264267
p->drawPolyline( points );

src/core/symbology-ng/qgssymbollayerv2.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,10 @@ void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points,
427427
}
428428

429429
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
430-
if ( points.size() <= 5 && ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
430+
if ( points.size() <= 5 &&
431+
( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) &&
432+
QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) &&
433+
( p->renderHints() & QPainter::Antialiasing ) )
431434
{
432435
p->setRenderHint( QPainter::Antialiasing, false );
433436
p->drawRect( points.boundingRect() );

src/providers/ogr/qgsogrgeometrysimplifier.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ QgsPoint* QgsOgrMapToPixelSimplifier::getEnvelopePoints( const QgsRectangle& env
131131
//! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context
132132
bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometryType, double* xptr, int xStride, double* yptr, int yStride, int pointCount, int& pointSimplifiedCount )
133133
{
134-
bool canbeGeneralizable = ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry );
134+
bool isGeneralizable = ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry );
135135

136136
pointSimplifiedCount = pointCount;
137-
if ( geometryType == QGis::Point || geometryType == QGis::UnknownGeometry ) return false;
137+
if ( geometryType == QGis::Point || geometryType == QGis::UnknownGeometry )
138+
return false;
139+
138140
pointSimplifiedCount = 0;
139141

140142
double map2pixelTol = mTolerance * mTolerance; //-> Use mappixelTol for 'LengthSquare' calculations.
@@ -150,7 +152,10 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometr
150152
memcpy( &x, xsourcePtr, sizeof( double ) ); xsourcePtr += xStride;
151153
memcpy( &y, ysourcePtr, sizeof( double ) ); ysourcePtr += yStride;
152154

153-
if ( i == 0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol || ( geometryType == QGis::Line && ( i == 1 || i >= numPoints - 2 ) ) )
155+
if ( i == 0 ||
156+
!isGeneralizable ||
157+
calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol ||
158+
( geometryType == QGis::Line && ( i == 1 || i >= numPoints - 2 ) ) )
154159
{
155160
memcpy( xtargetPtr, &x, sizeof( double ) ); lastX = x; xtargetPtr += xStride;
156161
memcpy( ytargetPtr, &y, sizeof( double ) ); lastY = y; ytargetPtr += yStride;
@@ -184,7 +189,7 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( OGRGeometryH geometry, boo
184189
QgsRectangle envelope( env.MinX, env.MinY, env.MaxX, env.MaxY );
185190

186191
// Can replace the geometry by its BBOX ?
187-
if (( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) && canbeGeneralizedByMapBoundingBox( envelope ) )
192+
if (( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) && isGeneralizableByMapBoundingBox( envelope ) )
188193
{
189194
QgsPoint* points = getEnvelopePoints( envelope, numPoints, isaLinearRing );
190195

0 commit comments

Comments
 (0)