-
Notifications
You must be signed in to change notification settings - Fork 17
/
CoordsMkr.cpp
79 lines (70 loc) · 2.79 KB
/
CoordsMkr.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* This file is part of TSRE5.
*
* TSRE5 - train sim game engine and MSTS/OR Editors.
* Copyright (C) 2016 Piotr Gadecki <[email protected]>
*
* Licensed under GNU General Public License 3.0 or later.
*
* See LICENSE.md or https://www.gnu.org/licenses/gpl.html
*/
#include "CoordsMkr.h"
#include <QFile>
#include "GLMatrix.h"
#include <math.h>
#include "ParserX.h"
#include <QDebug>
#include <cstdlib>
#include "Vector2f.h"
#include "TerrainLib.h"
#include "TS.h"
#include "Game.h"
#include "FileFunctions.h"
#include "ReadFile.h"
#include "GeoCoordinates.h"
CoordsMkr::CoordsMkr(QString path) {
path.replace("//", "/");
qDebug() << path;
QFile *file = new QFile(path);
if (!file->open(QIODevice::ReadOnly))
return;
FileBuffer* data = ReadFile::read(file);
ParserX::NextLine(data);
QString sh = "";
//ParserX::szukajsekcji1(sh, data);
//ParserX::GetNumber(data);
IghCoordinate* igh;
PreciseTileCoordinate* ppp;
while (!((sh = ParserX::NextTokenInside(data).toLower()) == "")) {
//qDebug() << sh;
if (sh == ("marker")) {
markerList.push_back(Marker());
markerList.back().lon = ParserX::GetNumber(data);
markerList.back().lat = ParserX::GetNumber(data);
markerList.back().name = ParserX::GetString(data);
markerList.back().type = ParserX::GetNumber(data);
//IghCoordinate* igh = Game::GeoCoordConverter->ConvertToIgh(x, -z, 0, 0);
//qDebug() << igh->Line << " === " << igh->Sample;
//LatitudeLongitudeCoordinate* latlon = Game::GeoCoordConverter->ConvertToLatLon(igh);
//qDebug() << latlon->Latitude << " === " << latlon->Longitude;
igh = Game::GeoCoordConverter->ConvertToInternal(markerList.back().lat, markerList.back().lon);
//qDebug() << igh->Line << " === " << igh->Sample;
ppp = Game::GeoCoordConverter->ConvertToTile(igh);
//qDebug() << ppp->TileX << " === " << ppp->TileZ << " " << ppp->X << " === " << ppp->Z;
//igh = Game::GeoCoordConverter->ConvertToIgh(ppp);
//qDebug() << igh->Line << " === " << igh->Sample;
//latlon = Game::GeoCoordConverter->ConvertToLatLon(igh);
//qDebug() << latlon->Latitude << " === " << latlon->Longitude;
markerList.back().tileX.push_back(ppp->TileX);
markerList.back().tileZ.push_back(ppp->TileZ);
markerList.back().x.push_back(ppp->X*2048-1024);
markerList.back().z.push_back(ppp->Z*2048-1024);
ParserX::SkipToken(data);
continue;
}
ParserX::SkipToken(data);
}
if (markerList.size() > 0)
loaded = true;
}
CoordsMkr::~CoordsMkr() {
}