mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-30 00:29:39 -05:00
rename other canbeGeneralizedByMapBoundingBox methods to isGeneralizableByMapBoundingBox
This commit is contained in:
parent
d9e8a940b9
commit
5e26fbd6eb
@ -17,9 +17,9 @@ class QgsAbstractGeometrySimplifier
|
||||
// MapToPixel simplification helper methods
|
||||
public:
|
||||
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
|
||||
static bool canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
|
||||
static bool isGeneralizableByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
|
||||
//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance
|
||||
static bool canbeGeneralizedByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
|
||||
static bool isGeneralizableByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -22,30 +22,22 @@ QgsAbstractGeometrySimplifier::~QgsAbstractGeometrySimplifier()
|
||||
}
|
||||
|
||||
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
|
||||
bool QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol )
|
||||
bool QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol )
|
||||
{
|
||||
return ( envelope.xMaximum() - envelope.xMinimum() ) < mapToPixelTol && ( envelope.yMaximum() - envelope.yMinimum() ) < mapToPixelTol;
|
||||
}
|
||||
|
||||
//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance
|
||||
bool QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol )
|
||||
bool QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol )
|
||||
{
|
||||
double xmin = std::numeric_limits<double>::max(), x, y;
|
||||
double ymin = std::numeric_limits<double>::max();
|
||||
double xmax = -std::numeric_limits<double>::max();
|
||||
double ymax = -std::numeric_limits<double>::max();
|
||||
QgsRectangle r;
|
||||
r.setMinimal();
|
||||
|
||||
for ( int i = 0, numPoints = points.size(); i < numPoints; ++i )
|
||||
{
|
||||
x = points[i].x();
|
||||
y = points[i].y();
|
||||
|
||||
if ( xmin > x ) xmin = x;
|
||||
if ( ymin > y ) ymin = y;
|
||||
if ( xmax < x ) xmax = x;
|
||||
if ( ymax < y ) ymax = y;
|
||||
r.combineExtentWith( points[i].x(), points[i].y() );
|
||||
}
|
||||
return canbeGeneralizedByDeviceBoundingBox( QgsRectangle( xmin, ymin, xmax, ymax ), mapToPixelTol );
|
||||
return isGeneralizableByDeviceBoundingBox( r, mapToPixelTol );
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -35,9 +35,9 @@ class CORE_EXPORT QgsAbstractGeometrySimplifier
|
||||
// MapToPixel simplification helper methods
|
||||
public:
|
||||
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
|
||||
static bool canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
|
||||
static bool isGeneralizableByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
|
||||
//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance
|
||||
static bool canbeGeneralizedByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
|
||||
static bool isGeneralizableByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -258,7 +258,10 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
|
||||
p->setPen( context.selected() ? mSelPen : mPen );
|
||||
|
||||
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
|
||||
if ( points.size() <= 2 && ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||
if ( points.size() <= 2 &&
|
||||
( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) &&
|
||||
QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) &&
|
||||
( p->renderHints() & QPainter::Antialiasing ) )
|
||||
{
|
||||
p->setRenderHint( QPainter::Antialiasing, false );
|
||||
p->drawPolyline( points );
|
||||
|
||||
@ -427,7 +427,10 @@ void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points,
|
||||
}
|
||||
|
||||
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
|
||||
if ( points.size() <= 5 && ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||
if ( points.size() <= 5 &&
|
||||
( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) &&
|
||||
QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) &&
|
||||
( p->renderHints() & QPainter::Antialiasing ) )
|
||||
{
|
||||
p->setRenderHint( QPainter::Antialiasing, false );
|
||||
p->drawRect( points.boundingRect() );
|
||||
|
||||
@ -131,10 +131,12 @@ QgsPoint* QgsOgrMapToPixelSimplifier::getEnvelopePoints( const QgsRectangle& env
|
||||
//! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context
|
||||
bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometryType, double* xptr, int xStride, double* yptr, int yStride, int pointCount, int& pointSimplifiedCount )
|
||||
{
|
||||
bool canbeGeneralizable = ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry );
|
||||
bool isGeneralizable = ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry );
|
||||
|
||||
pointSimplifiedCount = pointCount;
|
||||
if ( geometryType == QGis::Point || geometryType == QGis::UnknownGeometry ) return false;
|
||||
if ( geometryType == QGis::Point || geometryType == QGis::UnknownGeometry )
|
||||
return false;
|
||||
|
||||
pointSimplifiedCount = 0;
|
||||
|
||||
double map2pixelTol = mTolerance * mTolerance; //-> Use mappixelTol for 'LengthSquare' calculations.
|
||||
@ -150,7 +152,10 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometr
|
||||
memcpy( &x, xsourcePtr, sizeof( double ) ); xsourcePtr += xStride;
|
||||
memcpy( &y, ysourcePtr, sizeof( double ) ); ysourcePtr += yStride;
|
||||
|
||||
if ( i == 0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol || ( geometryType == QGis::Line && ( i == 1 || i >= numPoints - 2 ) ) )
|
||||
if ( i == 0 ||
|
||||
!isGeneralizable ||
|
||||
calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol ||
|
||||
( geometryType == QGis::Line && ( i == 1 || i >= numPoints - 2 ) ) )
|
||||
{
|
||||
memcpy( xtargetPtr, &x, sizeof( double ) ); lastX = x; xtargetPtr += xStride;
|
||||
memcpy( ytargetPtr, &y, sizeof( double ) ); lastY = y; ytargetPtr += yStride;
|
||||
@ -184,7 +189,7 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( OGRGeometryH geometry, boo
|
||||
QgsRectangle envelope( env.MinX, env.MinY, env.MaxX, env.MaxY );
|
||||
|
||||
// Can replace the geometry by its BBOX ?
|
||||
if (( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) && canbeGeneralizedByMapBoundingBox( envelope ) )
|
||||
if (( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) && isGeneralizableByMapBoundingBox( envelope ) )
|
||||
{
|
||||
QgsPoint* points = getEnvelopePoints( envelope, numPoints, isaLinearRing );
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user