More efficiency improvements for map to pixel simplification

Refs #17809
This commit is contained in:
Nyall Dawson 2018-02-09 16:19:52 +10:00
parent db12f006d9
commit b60489db49

View File

@ -91,10 +91,7 @@ static QgsGeometry generalizeWkbGeometryByBoundingBox(
// Write the generalized geometry // Write the generalized geometry
if ( geometryType == QgsWkbTypes::LineString ) if ( geometryType == QgsWkbTypes::LineString )
{ {
QgsLineString *lineString = new QgsLineString(); return QgsGeometry( qgis::make_unique< QgsLineString >( QVector<double>() << x1 << x2, QVector<double>() << y1 << y2 ) );
lineString->addVertex( QgsPoint( x1, y1 ) );
lineString->addVertex( QgsPoint( x2, y2 ) );
return QgsGeometry( lineString );
} }
else else
{ {
@ -127,9 +124,9 @@ QgsGeometry QgsMapToPixelSimplifier::simplifyGeometry(
// Write the geometry // Write the geometry
if ( flatType == QgsWkbTypes::LineString || flatType == QgsWkbTypes::CircularString ) if ( flatType == QgsWkbTypes::LineString || flatType == QgsWkbTypes::CircularString )
{ {
const QgsCurve &srcCurve = dynamic_cast<const QgsCurve &>( geometry );
const int numPoints = srcCurve.numPoints(); const int numPoints = srcCurve.numPoints();
const QgsCurve &srcCurve = dynamic_cast<const QgsCurve &>( geometry );
std::unique_ptr<QgsCurve> output; std::unique_ptr<QgsCurve> output;
QVector< double > lineStringX; QVector< double > lineStringX;