summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-09-11 11:19:32 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-09-11 14:53:10 (GMT)
commit5f33d108b4f53669923a223da23783ed05c530f1 (patch)
treeec84e44d4564e88e4c78267fd6e81242c6109ae0
parentf72396cb4cb1879559c42e84431cb20591df2110 (diff)
Do not assume first == last
-rw-r--r--src/lib/marble/geodata/data/GeoDataLinearRing.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataLinearRing.cpp b/src/lib/marble/geodata/data/GeoDataLinearRing.cpp
index 3f9639d..742d558 100644
--- a/src/lib/marble/geodata/data/GeoDataLinearRing.cpp
+++ b/src/lib/marble/geodata/data/GeoDataLinearRing.cpp
@@ -85,12 +85,12 @@ bool GeoDataLinearRing::contains( const GeoDataCoordinates &coordinates ) const
bool GeoDataLinearRing::isClockwise() const
{
- int n = size();
+ int const n = size();
qreal area = 0;
- for ( int i = 1; i < n - 1; ++i ){
+ for ( int i = 1; i < n; ++i ){
area += ( at( i ).longitude() - at( i - 1 ).longitude() ) * ( at( i ).latitude() + at( i - 1 ).latitude() );
}
- area += ( at( 0 ).longitude() - at( n - 2 ).longitude() ) * ( at ( 0 ).latitude() + at( n - 2 ).latitude() );
+ area += ( at( 0 ).longitude() - at( n - 1 ).longitude() ) * ( at ( 0 ).latitude() + at( n - 1 ).latitude() );
return area > 0;
}