Navigation Menu

Skip to content

Commit

Permalink
Tweak API
Browse files Browse the repository at this point in the history
Better to use QVector here, because the QgsLineString/QgsGeometry
methods all use QVector too, and we want to avoid unnecessary
list->vector conversions.
  • Loading branch information
nyalldawson committed Jan 8, 2019
1 parent 5df5c37 commit eaad71e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgsdistancearea.sip.in
Expand Up @@ -370,7 +370,7 @@ Datum of Australia Technical Manual", Chapter 4.
.. versionadded:: 3.0
%End

QList< QList< QgsPointXY > > geodesicLine( const QgsPointXY &p1, const QgsPointXY &p2, double interval, bool breakLine = false ) const;
QVector<QVector<QgsPointXY> > geodesicLine( const QgsPointXY &p1, const QgsPointXY &p2, double interval, bool breakLine = false ) const;
%Docstring
Calculates the geodesic line between ``p1`` and ``p2``, which represents the shortest path on the
ellipsoid between these two points.
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgsdistancearea.cpp
Expand Up @@ -532,11 +532,11 @@ double QgsDistanceArea::latitudeGeodesicCrossesDateLine( const QgsPointXY &pp1,
return lat;
}

QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1, const QgsPointXY &p2, const double interval, const bool breakLine ) const
QVector< QVector<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1, const QgsPointXY &p2, const double interval, const bool breakLine ) const
{
if ( !willUseEllipsoid() )
{
return QList< QList< QgsPointXY > >() << ( QList< QgsPointXY >() << p1 << p2 );
return QVector< QVector< QgsPointXY > >() << ( QVector< QgsPointXY >() << p1 << p2 );
}

geod_geodesic geod;
Expand All @@ -551,15 +551,15 @@ QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1,
catch ( QgsCsException & )
{
QgsMessageLog::logMessage( QObject::tr( "Caught a coordinate system exception while trying to transform a point. Unable to calculate geodesic line." ) );
return QList< QList< QgsPointXY > >();
return QVector< QVector< QgsPointXY > >();
}

geod_geodesicline line;
geod_inverseline( &line, &geod, pp1.y(), pp1.x(), pp2.y(), pp2.x(), GEOD_ALL );
const double totalDist = line.s13;

QList< QList< QgsPointXY > > res;
QList< QgsPointXY > currentPart;
QVector< QVector< QgsPointXY > > res;
QVector< QgsPointXY > currentPart;
currentPart << p1;
double d = interval;
double prevLon = p1.x();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsdistancearea.h
Expand Up @@ -317,7 +317,7 @@ class CORE_EXPORT QgsDistanceArea
*
* \since QGIS 3.6
*/
QList< QList< QgsPointXY > > geodesicLine( const QgsPointXY &p1, const QgsPointXY &p2, double interval, bool breakLine = false ) const;
QVector<QVector<QgsPointXY> > geodesicLine( const QgsPointXY &p1, const QgsPointXY &p2, double interval, bool breakLine = false ) const;

/**
* Calculates the latitude at which the geodesic line joining \a p1 and \a p2 crosses
Expand Down

0 comments on commit eaad71e

Please sign in to comment.