Skip to content
Permalink
Browse files

Feature #8725: Fix dpi bug

  • Loading branch information
ahuarte47 committed Oct 24, 2013
1 parent 40b5b1e commit 81afd870da1b2adef40e902e851124aa12d3e659
Showing with 7 additions and 3 deletions.
  1. +4 −1 src/core/qgsvectorlayer.cpp
  2. +3 −2 src/providers/ogr/qgsogrfeatureiterator.cpp
@@ -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 );
@@ -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 );
@@ -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 );

0 comments on commit 81afd87

Please sign in to comment.
You can’t perform that action at this time.