forked from GokuMK/TSRE5
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCoordsRoutePlaces.cpp
78 lines (72 loc) · 3.11 KB
/
CoordsRoutePlaces.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
/* 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 "CoordsRoutePlaces.h"
#include "GLMatrix.h"
#include <math.h>
#include <QDebug>
#include "Game.h"
#include "TDB.h"
#include "TRitem.h"
#include "GeoCoordinates.h"
CoordsRoutePlaces::~CoordsRoutePlaces() {
}
CoordsRoutePlaces::CoordsRoutePlaces(TDB *tdb, QString place) {
QMap<QString, bool> stations;
IghCoordinate igh;
PreciseTileCoordinate coords;
LatitudeLongitudeCoordinate latlon;
for(int i = 0; i < tdb->iTRitems; i++){
TRitem* n = tdb->trackItems[i];
if (n == NULL)
continue;
if (n->trItemRData == NULL)
continue;
if (n->stationName.length() > 0 && place == "stations"){
if(stations[n->stationName] == false){
stations[n->stationName] = true;
markerList.push_back(Marker());
markerList.back().name = n->stationName;
markerList.back().type = 0;
markerList.back().tileX.push_back(n->trItemRData[3]);
markerList.back().tileZ.push_back(n->trItemRData[4]);
markerList.back().x.push_back(n->trItemRData[0]);
markerList.back().z.push_back(n->trItemRData[2]);
coords.TileX = n->trItemRData[3];
coords.TileZ = n->trItemRData[4];
coords.setWxyz(n->trItemRData[0], 0, -n->trItemRData[2]);
Game::GeoCoordConverter->ConvertToInternal(&coords, &igh);
Game::GeoCoordConverter->ConvertToLatLon(&igh, &latlon);
markerList.back().lat = latlon.Latitude;
markerList.back().lon = latlon.Longitude;
}
}
if (n->type == "sidingitem" && n->platformName.length() > 0 && place == "sidings"){
if(stations[n->platformName] == false){
stations[n->platformName] = true;
markerList.push_back(Marker());
markerList.back().name = n->platformName;
markerList.back().type = 0;
markerList.back().tileX.push_back(n->trItemRData[3]);
markerList.back().tileZ.push_back(n->trItemRData[4]);
markerList.back().x.push_back(n->trItemRData[0]);
markerList.back().z.push_back(n->trItemRData[2]);
coords.TileX = n->trItemRData[3];
coords.TileZ = n->trItemRData[4];
coords.setWxyz(n->trItemRData[0], 0, -n->trItemRData[2]);
Game::GeoCoordConverter->ConvertToInternal(&coords, &igh);
Game::GeoCoordConverter->ConvertToLatLon(&igh, &latlon);
markerList.back().lat = latlon.Latitude;
markerList.back().lon = latlon.Longitude;
}
}
}
if (markerList.size() > 0)
loaded = true;
}