5#include "GeoDataMultiTrack.h"
6#include "GeoDataMultiTrack_p.h"
8#include "GeoDataLineString.h"
9#include "GeoDataLinearRing.h"
10#include "GeoDataPoint.h"
11#include "GeoDataPolygon.h"
12#include "GeoDataTrack.h"
13#include "GeoDataTypes.h"
15#include "MarbleDebug.h"
22GeoDataMultiTrack::GeoDataMultiTrack()
23 : GeoDataGeometry(new GeoDataMultiTrackPrivate)
27GeoDataMultiTrack::GeoDataMultiTrack(
const GeoDataGeometry &other)
28 : GeoDataGeometry(other)
32GeoDataMultiTrack::~GeoDataMultiTrack() =
default;
34const char *GeoDataMultiTrack::nodeType()
const
36 return GeoDataTypes::GeoDataMultiTrackType;
39EnumGeometryId GeoDataMultiTrack::geometryId()
const
41 return GeoDataMultiTrackId;
44GeoDataGeometry *GeoDataMultiTrack::copy()
const
46 return new GeoDataMultiTrack(*
this);
49bool GeoDataMultiTrack::operator==(
const GeoDataMultiTrack &other)
const
54 Q_D(
const GeoDataMultiTrack);
55 const GeoDataMultiTrackPrivate *other_d = other.d_func();
62 for (; d_it != d_end && other_it != other_end; ++d_it, ++other_it) {
63 if (**d_it != **other_it)
67 return d_it == d_end && other_it == other_end;
70bool GeoDataMultiTrack::operator!=(
const GeoDataMultiTrack &other)
const
75const GeoDataLatLonAltBox &GeoDataMultiTrack::latLonAltBox()
const
77 Q_D(
const GeoDataMultiTrack);
82 d->m_latLonAltBox.clear();
83 for (; it !=
end; ++it) {
84 if (!(*it)->latLonAltBox().isEmpty()) {
85 if (d->m_latLonAltBox.isEmpty()) {
86 d->m_latLonAltBox = (*it)->latLonAltBox();
88 d->m_latLonAltBox |= (*it)->latLonAltBox();
92 return d->m_latLonAltBox;
95int GeoDataMultiTrack::size()
const
97 Q_D(
const GeoDataMultiTrack);
98 return d->m_vector.size();
103 Q_D(
const GeoDataMultiTrack);
106 results.
reserve(d->m_vector.size());
111 for (; it !=
end; ++it) {
112 const GeoDataTrack f(**it);
119GeoDataTrack &GeoDataMultiTrack::at(
int pos)
121 mDebug() <<
"detaching!";
124 Q_D(GeoDataMultiTrack);
125 return *(d->m_vector[pos]);
128const GeoDataTrack &GeoDataMultiTrack::at(
int pos)
const
130 Q_D(
const GeoDataMultiTrack);
131 return *(d->m_vector.at(pos));
134GeoDataTrack &GeoDataMultiTrack::operator[](
int pos)
138 Q_D(GeoDataMultiTrack);
139 return *(d->m_vector[pos]);
142const GeoDataTrack &GeoDataMultiTrack::operator[](
int pos)
const
144 Q_D(
const GeoDataMultiTrack);
145 return *(d->m_vector[pos]);
148GeoDataTrack &GeoDataMultiTrack::last()
152 Q_D(GeoDataMultiTrack);
153 return *(d->m_vector.last());
156GeoDataTrack &GeoDataMultiTrack::first()
160 Q_D(GeoDataMultiTrack);
161 return *(d->m_vector.first());
164const GeoDataTrack &GeoDataMultiTrack::last()
const
166 Q_D(
const GeoDataMultiTrack);
167 return *(d->m_vector.last());
170const GeoDataTrack &GeoDataMultiTrack::first()
const
172 Q_D(
const GeoDataMultiTrack);
173 return *(d->m_vector.first());
180 Q_D(GeoDataMultiTrack);
181 return d->m_vector.begin();
188 Q_D(GeoDataMultiTrack);
189 return d->m_vector.end();
194 Q_D(
const GeoDataMultiTrack);
195 return d->m_vector.constBegin();
200 Q_D(
const GeoDataMultiTrack);
201 return d->m_vector.constEnd();
207GeoDataTrack *GeoDataMultiTrack::child(
int i)
211 Q_D(
const GeoDataMultiTrack);
212 return d->m_vector.at(i);
215const GeoDataTrack *GeoDataMultiTrack::child(
int i)
const
217 Q_D(
const GeoDataMultiTrack);
218 return d->m_vector.at(i);
224int GeoDataMultiTrack::childPosition(
const GeoDataTrack *
object)
const
226 Q_D(
const GeoDataMultiTrack);
227 for (
int i = 0; i < d->m_vector.size(); ++i) {
228 if (d->m_vector.at(i) ==
object) {
238void GeoDataMultiTrack::append(GeoDataTrack *other)
242 Q_D(GeoDataMultiTrack);
243 other->setParent(
this);
244 d->m_vector.append(other);
247GeoDataMultiTrack &GeoDataMultiTrack::operator<<(
const GeoDataTrack &value)
251 Q_D(GeoDataMultiTrack);
252 auto g =
new GeoDataTrack(value);
254 d->m_vector.append(g);
258void GeoDataMultiTrack::clear()
262 Q_D(GeoDataMultiTrack);
263 qDeleteAll(d->m_vector);
267void GeoDataMultiTrack::pack(
QDataStream &stream)
const
269 Q_D(
const GeoDataMultiTrack);
271 GeoDataGeometry::pack(stream);
273 stream << d->m_vector.size();
276 const GeoDataTrack *geometry = *iterator;
277 stream << geometry->geometryId();
278 geometry->pack(stream);
286 Q_D(GeoDataMultiTrack);
287 GeoDataGeometry::unpack(stream);
293 for (
int i = 0; i < size; i++) {
295 stream >> geometryId;
296 switch (geometryId) {
297 case InvalidGeometryId:
299 case GeoDataTrackId: {
300 auto track =
new GeoDataTrack;
301 track->unpack(stream);
302 d->m_vector.append(track);
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
KIOCORE_EXPORT bool operator==(const UDSEntry &entry, const UDSEntry &other)
bool equals(const QVariant &lhs, const QVariant &rhs)
Binds a QML item to a specific geodetic location in screen coordinates.
void append(QList< T > &&value)
void reserve(qsizetype size)