QgsLineStringV2* QgsGeometryImport::linestringFromPolyline( const QgsPolyline& polyline ) { QgsLineStringV2* line = new QgsLineStringV2(); QList<QgsPointV2> points; QgsPolyline::const_iterator it = polyline.constBegin(); for ( ; it != polyline.constEnd(); ++it ) { points.append( QgsPointV2( it->x(), it->y() ) ); } line->setPoints( points ); return line; }
std::unique_ptr<QgsLineString> QgsGeometryFactory::linestringFromPolyline( const QgsPolyline &polyline ) { QVector< double > x; x.reserve( polyline.size() ); QVector< double > y; y.reserve( polyline.size() ); QgsPolyline::const_iterator it = polyline.constBegin(); for ( ; it != polyline.constEnd(); ++it ) { x << it->x(); y << it->y(); } std::unique_ptr< QgsLineString > line( new QgsLineString( x, y ) ); return line; }