Skip to content

Commit

Permalink
Feature #8725: Fix dpi bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuarte47 committed Oct 24, 2013
1 parent 40b5b1e commit 81afd87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,13 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
// Enable the simplification of the geometries before fetch the features using the current map2pixel context.
if ( mSimplifyDrawing && !(featureRequest.flags() & QgsFeatureRequest::NoGeometry) )
{
QPainter* p = rendererContext.painter();
float dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;

featureRequest.setFlags( featureRequest.flags() | QgsFeatureRequest::SimplifyGeometries );
featureRequest.setCoordinateTransform( rendererContext.coordinateTransform() );
featureRequest.setMapToPixel( &rendererContext.mapToPixel() );
featureRequest.setMapToPixelTol( mSimplifyDrawingTol );
featureRequest.setMapToPixelTol( mSimplifyDrawingTol * 72.0f/dpi );
}

QgsFeatureIterator fit = getFeatures( featureRequest );
Expand Down
5 changes: 3 additions & 2 deletions src/providers/ogr/qgsogrfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ bool QgsOgrSimplifiedFeatureIterator::simplifyOgrGeometry( const QgsFeatureReque
{
OGRLineString* lineString = (OGRLineString*)geometry;

int numPoints = lineString->getNumPoints();
if ( (isaLinearRing && numPoints<=5) || (!isaLinearRing && numPoints<=2) ) return false;

OGREnvelope env;
geometry->getEnvelope(&env );
QgsRectangle envelope( env.MinX, env.MinY, env.MaxX, env.MaxY );
Expand Down Expand Up @@ -384,8 +387,6 @@ bool QgsOgrSimplifiedFeatureIterator::simplifyOgrGeometry( const QgsFeatureReque
else
{
QGis::GeometryType geometryType = isaLinearRing ? QGis::Polygon : QGis::Line;

int numPoints = lineString->getNumPoints();
int numSimplifiedPoints = 0;

OGRRawPoint* points = mallocPoints( numPoints );
Expand Down

0 comments on commit 81afd87

Please sign in to comment.