| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /*************************************************************************** | ||
| qgsgeometrysimplifier.cpp | ||
| --------------------- | ||
| begin : December 2013 | ||
| copyright : (C) 2013 by Alvaro Huarte | ||
| email : http://wiki.osgeo.org/wiki/Alvaro_Huarte | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include <limits> | ||
| #include "qgsgeometrysimplifier.h" | ||
|
|
||
| //! 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 ) | ||
| { | ||
| 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 ) | ||
| { | ||
| 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(); | ||
|
|
||
| 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; | ||
| } | ||
| return canbeGeneralizedByDeviceBoundingBox( QgsRectangle( xmin, ymin, xmax, ymax ), mapToPixelTol ); | ||
| } | ||
|
|
||
| /***************************************************************************/ | ||
| /** | ||
| * Implementation of GeometrySimplifier using the Douglas-Peucker algorithm | ||
| */ | ||
| QgsTopologyPreservingSimplifier::QgsTopologyPreservingSimplifier( double tolerance ) : mTolerance( tolerance ) | ||
| { | ||
| } | ||
| QgsTopologyPreservingSimplifier::~QgsTopologyPreservingSimplifier() | ||
| { | ||
| } | ||
|
|
||
| //! Returns a simplified version the specified geometry | ||
| QgsGeometry* QgsTopologyPreservingSimplifier::simplify( QgsGeometry* geometry ) | ||
| { | ||
| return geometry->simplify( mTolerance ); | ||
| } | ||
|
|
||
| //! Simplifies the specified geometry | ||
| bool QgsTopologyPreservingSimplifier::simplifyGeometry( QgsGeometry* geometry ) | ||
| { | ||
| QgsGeometry* g = geometry->simplify( mTolerance ); | ||
|
|
||
| if ( g ) | ||
| { | ||
| size_t wkbSize = g->wkbSize(); | ||
| unsigned char* wkb = (unsigned char*)malloc( wkbSize ); | ||
| memcpy( wkb, g->asWkb(), wkbSize ); | ||
| geometry->fromWkb( wkb, wkbSize ); | ||
| delete g; | ||
|
|
||
| return true; | ||
| } | ||
| return false; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /*************************************************************************** | ||
| qgsgeometrysimplifier.h | ||
| --------------------- | ||
| begin : December 2013 | ||
| copyright : (C) 2013 by Alvaro Huarte | ||
| email : http://wiki.osgeo.org/wiki/Alvaro_Huarte | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef QGSGEOMETRYSIMPLIFIER_H | ||
| #define QGSGEOMETRYSIMPLIFIER_H | ||
|
|
||
| #include "qgsgeometry.h" | ||
|
|
||
| /** | ||
| * Abstract base class for simplify geometries using a specific algorithm | ||
| */ | ||
| class CORE_EXPORT QgsAbstractGeometrySimplifier | ||
| { | ||
| public: | ||
| //! Returns a simplified version the specified geometry | ||
| virtual QgsGeometry* simplify( QgsGeometry* geometry ) = 0; | ||
| //! Simplifies the specified geometry | ||
| virtual bool simplifyGeometry( QgsGeometry* geometry ) = 0; | ||
|
|
||
| // 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 ); | ||
| //! 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 ); | ||
| }; | ||
|
|
||
| /***************************************************************************/ | ||
| /** | ||
| * Implementation of GeometrySimplifier using the Douglas-Peucker algorithm | ||
| * | ||
| * Simplifies a geometry, ensuring that the result is a valid geometry having the same dimension and number of components as the input. | ||
| * The simplification uses a maximum distance difference algorithm similar to the one used in the Douglas-Peucker algorithm. | ||
| */ | ||
| class CORE_EXPORT QgsTopologyPreservingSimplifier : public QgsAbstractGeometrySimplifier | ||
| { | ||
| public: | ||
| QgsTopologyPreservingSimplifier( double tolerance ); | ||
| virtual ~QgsTopologyPreservingSimplifier(); | ||
|
|
||
| private: | ||
| //! Distance tolerance for the simplification | ||
| double mTolerance; | ||
|
|
||
| public: | ||
| //! Returns a simplified version the specified geometry | ||
| virtual QgsGeometry* simplify( QgsGeometry* geometry ); | ||
| //! Simplifies the specified geometry | ||
| virtual bool simplifyGeometry( QgsGeometry* geometry ); | ||
| }; | ||
|
|
||
| #endif // QGSGEOMETRYSIMPLIFIER_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /*************************************************************************** | ||
| qgsmaptopixelgeometrysimplifier.h | ||
| --------------------- | ||
| begin : December 2013 | ||
| copyright : (C) 2013 by Alvaro Huarte | ||
| email : http://wiki.osgeo.org/wiki/Alvaro_Huarte | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H | ||
| #define QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H | ||
|
|
||
| #include "qgsgeometry.h" | ||
| #include "qgscoordinatetransform.h" | ||
| #include "qgsmaptopixel.h" | ||
|
|
||
| #include "qgsgeometrysimplifier.h" | ||
|
|
||
| /** | ||
| * Implementation of GeometrySimplifier using the "MapToPixel" algorithm | ||
| * | ||
| * Simplifies a geometry removing points within of the maximum distance difference that defines the MapToPixel info of a RenderContext request. | ||
| * This class enables simplify the geometries to be rendered in a MapCanvas target to speed up the vector drawing. | ||
| */ | ||
| class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier | ||
| { | ||
| public: | ||
| QgsMapToPixelSimplifier( int simplifyFlags, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapToPixel, float mapToPixelTol ); | ||
| virtual ~QgsMapToPixelSimplifier(); | ||
|
|
||
| //! Applicable simplification flags | ||
| enum SimplifyFlag | ||
| { | ||
| NoFlags = 0, //!< No simplification can be applied | ||
| SimplifyGeometry = 1, //!< The geometries can be simplified using the current map2pixel context state | ||
| SimplifyEnvelope = 2, //!< The geometries can be fully simplified by its BoundingBox | ||
| }; | ||
|
|
||
| private: | ||
| //! Simplify the WKB-geometry using the specified tolerance | ||
| static bool simplifyWkbGeometry( int simplifyFlags, QGis::WkbType wkbType, unsigned char* sourceWkb, size_t sourceWkbSize, unsigned char* targetWkb, size_t& targetWkbSize, const QgsRectangle& envelope, float map2pixelTol, bool writeHeader = true, bool isaLinearRing = false ); | ||
|
|
||
| protected: | ||
| //! Current simplification flags | ||
| int mSimplifyFlags; | ||
|
|
||
| //! For transformation between coordinate systems from current layer to map target. Can be 0 if on-the-fly reprojection is not used | ||
| const QgsCoordinateTransform* mMapCoordTransform; | ||
| //! For transformation between map coordinates and device coordinates | ||
| const QgsMapToPixel* mMapToPixel; | ||
| //! Factor tolterance to apply in transformation between map coordinates and device coordinates | ||
| float mMapToPixelTol; | ||
|
|
||
| //! Returns the squared 2D-distance of the vector defined by the two points specified | ||
| static float calculateLengthSquared2D( double x1, double y1, double x2, double y2 ); | ||
| //! Returns the MapTolerance for transform between map coordinates and device coordinates | ||
| static float calculateViewPixelTolerance( const QgsRectangle& boundingRect, const QgsCoordinateTransform* ct, const QgsMapToPixel* mapToPixel ); | ||
|
|
||
| public: | ||
| int simplifyFlags() const { return mSimplifyFlags; } | ||
| void setSimplifyFlags( int simplifyFlags ) { mSimplifyFlags = simplifyFlags; } | ||
|
|
||
| const QgsCoordinateTransform* coordinateTransform() const { return mMapCoordTransform; } | ||
| void setCoordinateTransform( const QgsCoordinateTransform* ct ) { mMapCoordTransform = ct; } | ||
|
|
||
| const QgsMapToPixel* mapToPixel() const { return mMapToPixel; } | ||
| void setMapToPixel( const QgsMapToPixel* mtp ) { mMapToPixel = mtp; } | ||
|
|
||
| float mapToPixelTol() const { return mMapToPixelTol; } | ||
| void setMapToPixelTol( float map2pixelTol ) { mMapToPixelTol = map2pixelTol; } | ||
|
|
||
| //! Returns a simplified version the specified geometry | ||
| virtual QgsGeometry* simplify( QgsGeometry* geometry ); | ||
| //! Simplifies the specified geometry | ||
| virtual bool simplifyGeometry( QgsGeometry* geometry ); | ||
|
|
||
| // MapToPixel simplification helper methods | ||
| public: | ||
|
|
||
| //! Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context | ||
| static bool canbeGeneralizedByMapBoundingBox( const QgsRectangle& envelope, | ||
| const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapToPixel, float mapToPixelTol = 1.0f ); | ||
|
|
||
| //! Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context | ||
| inline bool canbeGeneralizedByMapBoundingBox( const QgsRectangle& envelope ) const { return canbeGeneralizedByMapBoundingBox( envelope, mMapCoordTransform, mMapToPixel, mMapToPixelTol ); } | ||
|
|
||
| //! Simplifies the geometry when is applied the specified map2pixel context | ||
| static bool simplifyGeometry( QgsGeometry* geometry, | ||
| int simplifyFlags, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapToPixel, float mapToPixelTol = 1.0f ); | ||
|
|
||
| }; | ||
|
|
||
| #endif // QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| /*************************************************************************** | ||
| qgsogrmaptopixelgeometrysimplifier.cpp | ||
| --------------------- | ||
| begin : December 2013 | ||
| copyright : (C) 2013 by Alvaro Huarte | ||
| email : http://wiki.osgeo.org/wiki/Alvaro_Huarte | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "qgsogrmaptopixelgeometrysimplifier.h" | ||
| #include "qgsogrprovider.h" | ||
|
|
||
| QgsOgrMapToPixelSimplifier::QgsOgrMapToPixelSimplifier( int simplifyFlags, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapTolPixel, float mapToPixelTol ) : QgsMapToPixelSimplifier( simplifyFlags, coordinateTransform, mapTolPixel, mapToPixelTol ) | ||
| { | ||
| mPointBufferCount = 512; | ||
| mPointBufferPtr = (OGRRawPoint*)OGRMalloc( mPointBufferCount * sizeof(OGRRawPoint) ); | ||
| } | ||
| QgsOgrMapToPixelSimplifier::~QgsOgrMapToPixelSimplifier() | ||
| { | ||
| if ( mPointBufferPtr ) | ||
| { | ||
| OGRFree( mPointBufferPtr ); | ||
| mPointBufferPtr = NULL; | ||
| } | ||
| } | ||
|
|
||
| //! Returns a point buffer of the specified size | ||
| OGRRawPoint* QgsOgrMapToPixelSimplifier::mallocPoints( int numPoints ) | ||
| { | ||
| if ( mPointBufferPtr && mPointBufferCount < numPoints ) | ||
| { | ||
| OGRFree( mPointBufferPtr ); | ||
| mPointBufferPtr = NULL; | ||
| } | ||
| if ( mPointBufferPtr==NULL ) | ||
| { | ||
| mPointBufferCount = numPoints; | ||
| mPointBufferPtr = (OGRRawPoint*)OGRMalloc( mPointBufferCount * sizeof(OGRRawPoint) ); | ||
| } | ||
| return mPointBufferPtr; | ||
| } | ||
|
|
||
| ////////////////////////////////////////////////////////////////////////////////////////////// | ||
| // Helper simplification methods | ||
|
|
||
| //! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context | ||
| bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometryType, const QgsRectangle& envelope, double* xptr, int xStride, double* yptr, int yStride, int pointCount, int& pointSimplifiedCount) | ||
| { | ||
| bool canbeGeneralizable = ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry ); | ||
|
|
||
| pointSimplifiedCount = pointCount; | ||
| if ( geometryType == QGis::Point || geometryType == QGis::UnknownGeometry ) return false; | ||
| pointSimplifiedCount = 0; | ||
|
|
||
| double map2pixelTol = mMapToPixelTol * QgsMapToPixelSimplifier::calculateViewPixelTolerance( envelope, mMapCoordTransform, mMapToPixel ); | ||
| map2pixelTol *= map2pixelTol; //-> Use mappixelTol for 'LengthSquare' calculations. | ||
| double x,y, lastX=0, lastY=0; | ||
|
|
||
| char* xsourcePtr = (char*)xptr; | ||
| char* ysourcePtr = (char*)yptr; | ||
| char* xtargetPtr = (char*)xptr; | ||
| char* ytargetPtr = (char*)yptr; | ||
|
|
||
| for ( int i = 0, numPoints = geometryType==QGis::Polygon ? pointCount-1 : pointCount; i < numPoints; ++i ) | ||
| { | ||
| 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 ) | ||
| { | ||
| memcpy( xtargetPtr, &x, sizeof( double ) ); lastX = x; xtargetPtr += xStride; | ||
| memcpy( ytargetPtr, &y, sizeof( double ) ); lastY = y; ytargetPtr += yStride; | ||
| pointSimplifiedCount++; | ||
| } | ||
| } | ||
| if ( geometryType == QGis::Polygon ) | ||
| { | ||
| memcpy( xtargetPtr, xptr, sizeof( double ) ); | ||
| memcpy( ytargetPtr, yptr, sizeof( double ) ); | ||
| pointSimplifiedCount++; | ||
| } | ||
| return pointSimplifiedCount!=pointCount; | ||
| } | ||
|
|
||
| //! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context | ||
| bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( OGRGeometry* geometry, bool isaLinearRing ) | ||
| { | ||
| OGRwkbGeometryType wkbGeometryType = wkbFlatten( geometry->getGeometryType() ); | ||
|
|
||
| // Simplify the geometry rewriting temporally its WKB-stream for saving calloc's. | ||
| if ( wkbGeometryType == wkbLineString ) | ||
| { | ||
| 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 ); | ||
|
|
||
| // Can replace the geometry by its BBOX ? | ||
| if ( (mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope) && canbeGeneralizedByMapBoundingBox( envelope ) ) | ||
| { | ||
| OGRRawPoint* points = NULL; | ||
| int numPoints = 0; | ||
|
|
||
| double x1 = envelope.xMinimum(); | ||
| double y1 = envelope.yMinimum(); | ||
| double x2 = envelope.xMaximum(); | ||
| double y2 = envelope.yMaximum(); | ||
|
|
||
| if ( isaLinearRing ) | ||
| { | ||
| numPoints = 5; | ||
| points = mallocPoints( numPoints ); | ||
| points[0].x = x1; points[0].y = y1; | ||
| points[1].x = x2; points[1].y = y1; | ||
| points[2].x = x2; points[2].y = y2; | ||
| points[3].x = x1; points[3].y = y2; | ||
| points[4].x = x1; points[4].y = y1; | ||
| } | ||
| else | ||
| { | ||
| numPoints = 2; | ||
| points = mallocPoints( numPoints ); | ||
| points[0].x = x1; points[0].y = y1; | ||
| points[1].x = x2; points[1].y = y2; | ||
| } | ||
| lineString->setPoints( numPoints, points ); | ||
| lineString->flattenTo2D(); | ||
| return true; | ||
| } | ||
| else | ||
| if ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry ) | ||
| { | ||
| QGis::GeometryType geometryType = isaLinearRing ? QGis::Polygon : QGis::Line; | ||
| int numSimplifiedPoints = 0; | ||
|
|
||
| OGRRawPoint* points = mallocPoints( numPoints ); | ||
| double* xptr = (double*)points; | ||
| double* yptr = xptr+1; | ||
| lineString->getPoints( points ); | ||
|
|
||
| if ( simplifyOgrGeometry( geometryType, envelope, xptr, 16, yptr, 16, numPoints, numSimplifiedPoints ) ) | ||
| { | ||
| lineString->setPoints( numSimplifiedPoints, points ); | ||
| lineString->flattenTo2D(); | ||
| } | ||
| return numSimplifiedPoints!=numPoints; | ||
| } | ||
| } | ||
| else | ||
| if ( wkbGeometryType == wkbPolygon ) | ||
| { | ||
| OGRPolygon* polygon = (OGRPolygon*)geometry; | ||
| bool result = simplifyOgrGeometry( polygon->getExteriorRing(), true ); | ||
|
|
||
| for ( int i = 0, numInteriorRings = polygon->getNumInteriorRings(); i < numInteriorRings; ++i ) | ||
| { | ||
| result |= simplifyOgrGeometry( polygon->getInteriorRing(i), true ); | ||
| } | ||
| if ( result ) polygon->flattenTo2D(); | ||
| return result; | ||
| } | ||
| else | ||
| if ( wkbGeometryType == wkbMultiLineString || wkbGeometryType == wkbMultiPolygon ) | ||
| { | ||
| OGRGeometryCollection* collection = (OGRGeometryCollection*)geometry; | ||
| bool result = false; | ||
|
|
||
| for ( int i = 0, numGeometries = collection->getNumGeometries(); i < numGeometries; ++i ) | ||
| { | ||
| result |= simplifyOgrGeometry( collection->getGeometryRef(i), wkbGeometryType==wkbMultiPolygon ); | ||
| } | ||
| if ( result ) collection->flattenTo2D(); | ||
| return result; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| ////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| //! Simplifies the specified geometry | ||
| bool QgsOgrMapToPixelSimplifier::simplifyGeometry( OGRGeometry* geometry ) | ||
| { | ||
| OGRwkbGeometryType wkbGeometryType = QgsOgrProvider::ogrWkbSingleFlatten( geometry->getGeometryType() ); | ||
|
|
||
| if ( wkbGeometryType == wkbLineString || wkbGeometryType == wkbPolygon ) | ||
| { | ||
| return simplifyOgrGeometry( geometry, wkbGeometryType==wkbPolygon ); | ||
| } | ||
| return false; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /*************************************************************************** | ||
| qgsogrmaptopixelgeometrysimplifier.h | ||
| --------------------- | ||
| begin : December 2013 | ||
| copyright : (C) 2013 by Alvaro Huarte | ||
| email : http://wiki.osgeo.org/wiki/Alvaro_Huarte | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef QGSOGRMAPTOPIXELGEOMETRYSIMPLIFIER_H | ||
| #define QGSOGRMAPTOPIXELGEOMETRYSIMPLIFIER_H | ||
|
|
||
| #include "qgsmaptopixelgeometrysimplifier.h" | ||
| #include <ogr_geometry.h> | ||
|
|
||
| /** | ||
| * OGR implementation of GeometrySimplifier using the "MapToPixel" algorithm | ||
| * | ||
| * Simplifies a geometry removing points within of the maximum distance difference that defines the MapToPixel info of a RenderContext request. | ||
| * This class enables simplify the geometries to be rendered in a MapCanvas target to speed up the vector drawing. | ||
| */ | ||
| class QgsOgrMapToPixelSimplifier : public QgsMapToPixelSimplifier | ||
| { | ||
| public: | ||
| QgsOgrMapToPixelSimplifier( int simplifyFlags, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapToPixel, float mapToPixelTol ); | ||
| virtual ~QgsOgrMapToPixelSimplifier(); | ||
|
|
||
| private: | ||
| //! Point memory buffer for optimize the simplification process | ||
| OGRRawPoint* mPointBufferPtr; | ||
| //! Current Point memory buffer size | ||
| int mPointBufferCount; | ||
|
|
||
| //! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context | ||
| bool simplifyOgrGeometry( QGis::GeometryType geometryType, const QgsRectangle& envelope, double* xptr, int xStride, double* yptr, int yStride, int pointCount, int& pointSimplifiedCount); | ||
| //! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context | ||
| bool simplifyOgrGeometry( OGRGeometry* geometry, bool isaLinearRing ); | ||
|
|
||
| //! Returns a point buffer of the specified size | ||
| OGRRawPoint* mallocPoints( int numPoints ); | ||
|
|
||
| public: | ||
| //! Simplifies the specified geometry | ||
| bool simplifyGeometry( OGRGeometry* geometry ); | ||
| }; | ||
|
|
||
| #endif // QGSOGRMAPTOPIXELGEOMETRYSIMPLIFIER_H |