~ubuntu-branches/ubuntu/saucy/merkaartor/saucy

« back to all changes in this revision

Viewing changes to Map/ImportNGT.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2009-09-13 00:52:12 UTC
  • mto: (1.2.7 upstream) (0.1.3 upstream) (3.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090913005212-pjecal8zxm07x0fj
ImportĀ upstreamĀ versionĀ 0.14+svnfixes~20090912

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "ImportNGT.h"
2
 
#include "Command/DocumentCommands.h"
3
 
#include "Map/MapDocument.h"
4
 
#include "Map/TrackPoint.h"
5
 
#include "Map/TrackSegment.h"
6
 
 
7
 
#include <QtCore/QFile>
8
 
#include <QtCore/QStringList>
9
 
#include <QtCore/QTextStream>
10
 
 
11
 
#include <math.h>
12
 
 
13
 
bool importNGT(QWidget* /* aParent */, const QString& aFilename, MapDocument* theDocument, MapLayer* theLayer)
14
 
{
15
 
        QFile f(aFilename);
16
 
        if (f.open(QIODevice::ReadOnly))
17
 
        {
18
 
                QTextStream s(&f);
19
 
                CommandList* theList  = new CommandList(MainWindow::tr("Import NGT"), NULL);
20
 
                TrackSegment* theSegment = new TrackSegment;
21
 
                while (!f.atEnd())
22
 
                {
23
 
                        QString Line(f.readLine());
24
 
                        QStringList Items(Line.split('|'));
25
 
                        if (Items.count() >= 5)
26
 
                        {
27
 
                                TrackPoint* Pt = new TrackPoint(Coord(int(Items[4].toDouble()*INT_MAX), int(Items[3].toDouble()*INT_MAX)));
28
 
                                Pt->setLastUpdated(MapFeature::Log);
29
 
                                theList->add(new AddFeatureCommand(theLayer,Pt, true));
30
 
                                theSegment->add(Pt);
31
 
                        }
32
 
                }
33
 
                if (theList->empty())
34
 
                {
35
 
                        delete theList;
36
 
                        delete theSegment;
37
 
                }
38
 
                else
39
 
                {
40
 
                        theList->add(new AddFeatureCommand(theLayer,theSegment,true));
41
 
                        theDocument->addHistory(theList);
42
 
                }
43
 
                return true;
44
 
        }
45
 
        return false;
46
 
}