Skip to content

Commit

Permalink
Update indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 29, 2017
1 parent 548461a commit c96a32a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
44 changes: 22 additions & 22 deletions src/core/geometry/qgspointv2.cpp
Expand Up @@ -466,31 +466,31 @@ double QgsPointV2::azimuth( const QgsPointV2& other ) const

QgsPointV2 QgsPointV2::project( double distance, double azimuth, double inclination ) const
{
QgsWkbTypes::Type pType(QgsWkbTypes::Point);
QgsWkbTypes::Type pType( QgsWkbTypes::Point );

double rads_xy = azimuth * M_PI / 180.0;
double dx = 0.0, dy = 0.0, dz = 0.0;
double radsXy = azimuth * M_PI / 180.0;
double dx = 0.0, dy = 0.0, dz = 0.0;

inclination = fmod( inclination, 360.0 );
inclination = fmod( inclination, 360.0 );

if ( !is3D() && qgsDoubleNear(inclination, 90.0) )
{
dx = distance * sin( rads_xy );
dy = distance * cos( rads_xy );
}
else
{
pType = QgsWkbTypes::addZ( pType );
double rads_z = inclination * M_PI / 180.0;
dx = distance * sin( rads_z ) * sin( rads_xy );
dy = distance * sin( rads_z ) * cos( rads_xy );
dz = distance * cos( rads_z );
}
if ( !is3D() && qgsDoubleNear( inclination, 90.0 ) )
{
dx = distance * sin( radsXy );
dy = distance * cos( radsXy );
}
else
{
pType = QgsWkbTypes::addZ( pType );
double radsZ = inclination * M_PI / 180.0;
dx = distance * sin( radsZ ) * sin( radsXy );
dy = distance * sin( radsZ ) * cos( radsXy );
dz = distance * cos( radsZ );
}

if ( isMeasure() )
{
pType = QgsWkbTypes::addM( pType );
}
if ( isMeasure() )
{
pType = QgsWkbTypes::addM( pType );
}

return QgsPointV2( pType, mX + dx, mY + dy, mZ + dz, mM );
return QgsPointV2( pType, mX + dx, mY + dy, mZ + dz, mM );
}
2 changes: 1 addition & 1 deletion src/core/geometry/qgspointv2.h
Expand Up @@ -220,7 +220,7 @@ class CORE_EXPORT QgsPointV2: public QgsAbstractGeometry
* \endcode
* @note added in QGIS 3.0
*/
QgsPointV2 project(double distance, double azimuth, double inclination = 90.0 ) const;
QgsPointV2 project( double distance, double azimuth, double inclination = 90.0 ) const;

/**
* Calculates the vector obtained by subtracting a point from this point.
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpression.cpp
Expand Up @@ -2768,7 +2768,7 @@ static QVariant fcnProject( const QVariantList& values, const QgsExpressionConte
const QgsPointV2* p = dynamic_cast<const QgsPointV2*>( geom.geometry() );
QgsPointV2 newPoint = p->project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );

return QVariant::fromValue( QgsGeometry( new QgsPointV2( newPoint) ) );
return QVariant::fromValue( QgsGeometry( new QgsPointV2( newPoint ) ) );
}

static QVariant fcnExtrude( const QVariantList& values, const QgsExpressionContext*, QgsExpression* parent )
Expand Down
40 changes: 20 additions & 20 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -867,28 +867,28 @@ void TestQgsGeometry::point()

// 3D
QgsPointV2 p34 = QgsPointV2( QgsWkbTypes::PointZ, 1, 2, 2 );
QCOMPARE( p34.project( 1, 0 ), QgsPointV2(QgsWkbTypes::PointZ, 1, 3, 2 ) );
QCOMPARE( p34.project( 1, 0, 0 ), QgsPointV2(QgsWkbTypes::PointZ, 1, 2, 3 ) );
QCOMPARE( p34.project( 1.5, 90 ), QgsPointV2(QgsWkbTypes::PointZ, 2.5, 2, 2 ) );
QCOMPARE( p34.project( 1.5, 90, 90 ), QgsPointV2(QgsWkbTypes::PointZ, 2.5, 2, 2 ) );
QCOMPARE( p34.project( 2, 180 ), QgsPointV2(QgsWkbTypes::PointZ, 1, 0, 2 ) );
QCOMPARE( p34.project( 2, 180, 180 ), QgsPointV2(QgsWkbTypes::PointZ, 1, 2, 0 ) );
QCOMPARE( p34.project( 5, 270 ), QgsPointV2(QgsWkbTypes::PointZ, -4, 2, 2 ) );
QCOMPARE( p34.project( 5, 270, 270 ), QgsPointV2(QgsWkbTypes::PointZ, 6, 2, 2 ) );
QCOMPARE( p34.project( 6, 360 ), QgsPointV2(QgsWkbTypes::PointZ, 1, 8, 2 ) );
QCOMPARE( p34.project( 6, 360, 360 ), QgsPointV2(QgsWkbTypes::PointZ, 1, 2, 8 ) );
QCOMPARE( p34.project( 5, 450 ), QgsPointV2(QgsWkbTypes::PointZ, 6, 2, 2 ) );
QCOMPARE( p34.project( 5, 450, 450 ), QgsPointV2(QgsWkbTypes::PointZ, 6, 2, 2 ) );
QCOMPARE( p34.project( -1, 0 ), QgsPointV2(QgsWkbTypes::PointZ, 1, 1, 2 ) );
QCOMPARE( p34.project( -1, 0, 0 ), QgsPointV2(QgsWkbTypes::PointZ, 1, 2, 1 ) );
QCOMPARE( p34.project( 1.5, -90 ), QgsPointV2(QgsWkbTypes::PointZ, -0.5, 2, 2 ) );
QCOMPARE( p34.project( 1.5, -90, -90 ), QgsPointV2(QgsWkbTypes::PointZ, 2.5, 2, 2 ) );
QCOMPARE( p34.project( 1, 0 ), QgsPointV2( QgsWkbTypes::PointZ, 1, 3, 2 ) );
QCOMPARE( p34.project( 1, 0, 0 ), QgsPointV2( QgsWkbTypes::PointZ, 1, 2, 3 ) );
QCOMPARE( p34.project( 1.5, 90 ), QgsPointV2( QgsWkbTypes::PointZ, 2.5, 2, 2 ) );
QCOMPARE( p34.project( 1.5, 90, 90 ), QgsPointV2( QgsWkbTypes::PointZ, 2.5, 2, 2 ) );
QCOMPARE( p34.project( 2, 180 ), QgsPointV2( QgsWkbTypes::PointZ, 1, 0, 2 ) );
QCOMPARE( p34.project( 2, 180, 180 ), QgsPointV2( QgsWkbTypes::PointZ, 1, 2, 0 ) );
QCOMPARE( p34.project( 5, 270 ), QgsPointV2( QgsWkbTypes::PointZ, -4, 2, 2 ) );
QCOMPARE( p34.project( 5, 270, 270 ), QgsPointV2( QgsWkbTypes::PointZ, 6, 2, 2 ) );
QCOMPARE( p34.project( 6, 360 ), QgsPointV2( QgsWkbTypes::PointZ, 1, 8, 2 ) );
QCOMPARE( p34.project( 6, 360, 360 ), QgsPointV2( QgsWkbTypes::PointZ, 1, 2, 8 ) );
QCOMPARE( p34.project( 5, 450 ), QgsPointV2( QgsWkbTypes::PointZ, 6, 2, 2 ) );
QCOMPARE( p34.project( 5, 450, 450 ), QgsPointV2( QgsWkbTypes::PointZ, 6, 2, 2 ) );
QCOMPARE( p34.project( -1, 0 ), QgsPointV2( QgsWkbTypes::PointZ, 1, 1, 2 ) );
QCOMPARE( p34.project( -1, 0, 0 ), QgsPointV2( QgsWkbTypes::PointZ, 1, 2, 1 ) );
QCOMPARE( p34.project( 1.5, -90 ), QgsPointV2( QgsWkbTypes::PointZ, -0.5, 2, 2 ) );
QCOMPARE( p34.project( 1.5, -90, -90 ), QgsPointV2( QgsWkbTypes::PointZ, 2.5, 2, 2 ) );
// PointM
p34.addMValue( 5.0 );
QCOMPARE( p34.project( 1, 0 ), QgsPointV2(QgsWkbTypes::PointZM, 1, 3, 2, 5 ) );
QCOMPARE( p34.project( 1, 0, 0 ), QgsPointV2(QgsWkbTypes::PointZM, 1, 2, 3, 5 ) );
QCOMPARE( p34.project( 5, 450 ), QgsPointV2(QgsWkbTypes::PointZM, 6, 2, 2, 5 ) );
QCOMPARE( p34.project( 5, 450, 450 ), QgsPointV2(QgsWkbTypes::PointZM, 6, 2, 2, 5 ) );
QCOMPARE( p34.project( 1, 0 ), QgsPointV2( QgsWkbTypes::PointZM, 1, 3, 2, 5 ) );
QCOMPARE( p34.project( 1, 0, 0 ), QgsPointV2( QgsWkbTypes::PointZM, 1, 2, 3, 5 ) );
QCOMPARE( p34.project( 5, 450 ), QgsPointV2( QgsWkbTypes::PointZM, 6, 2, 2, 5 ) );
QCOMPARE( p34.project( 5, 450, 450 ), QgsPointV2( QgsWkbTypes::PointZM, 6, 2, 2, 5 ) );

}

Expand Down

0 comments on commit c96a32a

Please sign in to comment.