Skip to content

Commit 5a6dc99

Browse files
committed
Feature #8725: Fix dpi bug
1 parent 134def2 commit 5a6dc99

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/core/qgsvectorlayer.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,13 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
696696
// Enable the simplification of the geometries before fetch the features using the current map2pixel context.
697697
if ( mSimplifyDrawing && !(featureRequest.flags() & QgsFeatureRequest::NoGeometry) )
698698
{
699+
QPainter* p = rendererContext.painter();
700+
float dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
701+
699702
featureRequest.setFlags( featureRequest.flags() | QgsFeatureRequest::SimplifyGeometries );
700703
featureRequest.setCoordinateTransform( rendererContext.coordinateTransform() );
701704
featureRequest.setMapToPixel( &rendererContext.mapToPixel() );
702-
featureRequest.setMapToPixelTol( mSimplifyDrawingTol );
705+
featureRequest.setMapToPixelTol( mSimplifyDrawingTol * 72.0f/dpi );
703706
}
704707

705708
QgsFeatureIterator fit = getFeatures( featureRequest );

src/providers/ogr/qgsogrfeatureiterator.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ bool QgsOgrSimplifiedFeatureIterator::simplifyOgrGeometry( const QgsFeatureReque
345345
{
346346
OGRLineString* lineString = (OGRLineString*)geometry;
347347

348+
int numPoints = lineString->getNumPoints();
349+
if ( (isaLinearRing && numPoints<=5) || (!isaLinearRing && numPoints<=2) ) return false;
350+
348351
OGREnvelope env;
349352
geometry->getEnvelope(&env );
350353
QgsRectangle envelope( env.MinX, env.MinY, env.MaxX, env.MaxY );
@@ -384,8 +387,6 @@ bool QgsOgrSimplifiedFeatureIterator::simplifyOgrGeometry( const QgsFeatureReque
384387
else
385388
{
386389
QGis::GeometryType geometryType = isaLinearRing ? QGis::Polygon : QGis::Line;
387-
388-
int numPoints = lineString->getNumPoints();
389390
int numSimplifiedPoints = 0;
390391

391392
OGRRawPoint* points = mallocPoints( numPoints );

0 commit comments

Comments
 (0)