- Fix encoding function to iterate reversed list
- Fix decoding routine to not loose last point
--- a/QTfrontend/drawmapscene.cpp Fri Dec 24 11:54:34 2010 -0500
+++ b/QTfrontend/drawmapscene.cpp Fri Dec 24 20:33:17 2010 +0300
@@ -87,9 +87,10 @@
{
QByteArray b;
- foreach(QList<QPoint> points, paths)
+ for(int i = paths.size() - 1; i >= 0; --i)
{
int cnt = 0;
+ QList<QPoint> points = paths.at(i);
foreach(QPoint point, points)
{
qint16 px = qToBigEndian((qint16)point.x());
@@ -124,19 +125,21 @@
quint8 flags = *(quint8 *)data.data();
data.remove(0, 1);
- if (data.size() < 5) points.append(QPoint(px, py));
- //last chunk or first point
- if((data.size() < 5) || (flags & 0x80))
+ if((flags & 0x80) && points.size())
{
- if(points.size())
- {
- addPath(pointsToPath(points), m_pen);
- paths.append(points);
+ addPath(pointsToPath(points), m_pen);
+ paths.prepend(points);
+
+ points.clear();
+ }
- points.clear();
- }
- }
- if (data.size() >= 5) points.append(QPoint(px, py));
+ points.append(QPoint(px, py));
+ }
+
+ if(points.size())
+ {
+ addPath(pointsToPath(points), m_pen);
+ paths.prepend(points);
}
emit pathChanged();