summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-12 09:32:20 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-12 09:38:18 (GMT)
commit45f9db6dcdc7a3a9415eb0d643ae4ebbf96cd123 (patch)
tree490366c8f8ff014646f6f27ee75f33482dc53745
parentfd535e6b3e11be92f9ca88fc12a3346a34a45af3 (diff)
Add a mid() method just as QVector provides
-rw-r--r--src/lib/marble/geodata/data/GeoDataLineString.cpp12
-rw-r--r--src/lib/marble/geodata/data/GeoDataLineString.h7
2 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataLineString.cpp b/src/lib/marble/geodata/data/GeoDataLineString.cpp
index bb62766..648e8fe 100644
--- a/src/lib/marble/geodata/data/GeoDataLineString.cpp
+++ b/src/lib/marble/geodata/data/GeoDataLineString.cpp
@@ -305,6 +305,18 @@ GeoDataCoordinates& GeoDataLineString::operator[]( int pos )
return d->m_vector[pos];
}
+GeoDataLineString GeoDataLineString::mid(int pos, int length) const
+{
+ GeoDataLineString substring;
+ auto d = substring.d_func();
+ d->m_vector = d_func()->m_vector.mid(pos, length);
+ d->m_dirtyBox = true;
+ d->m_dirtyRange = true;
+ d->m_tessellationFlags = d_func()->m_tessellationFlags;
+ d->m_extrude = d_func()->m_extrude;
+ return substring;
+}
+
const GeoDataCoordinates& GeoDataLineString::operator[]( int pos ) const
{
Q_D(const GeoDataLineString);
diff --git a/src/lib/marble/geodata/data/GeoDataLineString.h b/src/lib/marble/geodata/data/GeoDataLineString.h
index 133b1ff..ace26f1 100644
--- a/src/lib/marble/geodata/data/GeoDataLineString.h
+++ b/src/lib/marble/geodata/data/GeoDataLineString.h
@@ -240,6 +240,13 @@ class GEODATA_EXPORT GeoDataLineString : public GeoDataGeometry
GeoDataCoordinates& operator[]( int pos );
+ /**
+ Returns a sub-string which contains elements from this vector, starting at position pos. If length is -1
+ (the default), all elements after pos are included; otherwise length elements (or all remaining elements if
+ there are less than length elements) are included.
+ */
+ GeoDataLineString mid(int pos, int length = -1) const;
+
/*!
\brief Returns a reference to the coordinates of a node at a given position.
This method does not detach the returned coordinate object from the line string.