MapAppAPIWrapper.cpp 1.7 KB
Newer Older
1
#include "MapAppAPIWrapper.hpp"
2
#include "pi2-view.h"
3
#include <string_view>
Martin Kröning's avatar
Martin Kröning committed
4
5
#include <vector>

6
7
MapAppAPIWrapper::MapAppAPIWrapper(std::string_view windowTitle)
    : mapApp(mapAppCreate(windowTitle.data())) {}
Martin Kröning's avatar
Martin Kröning committed
8

9
MapAppAPIWrapper::~MapAppAPIWrapper() {
Martin Kröning's avatar
Martin Kröning committed
10
11
12
13
  mapAppDestroy(mapApp);
  mapApp = nullptr;
}

14
void MapAppAPIWrapper::addJunction(const double x, const double y) {
Martin Kröning's avatar
Martin Kröning committed
15
16
17
  mapAppAddJunction(mapApp, x, y);
}

18
19
void MapAppAPIWrapper::addRoad(std::string_view laneThereName,
                               std::string_view laneBackName,
Martin Kröning's avatar
Martin Kröning committed
20
                               const std::vector<double> &coordinates) {
21
  mapAppAddRoad(mapApp, laneThereName.data(), laneBackName.data(),
Martin Kröning's avatar
Martin Kröning committed
22
23
24
                coordinates.data(), coordinates.size());
}

25
26
void MapAppAPIWrapper::addOrReplaceBicycle(std::string_view vehicleName,
                                           std::string_view laneName,
27
28
                                           const double positionOnLane,
                                           const double speed) {
29
  mapAppAddOrReplaceBicycle(mapApp, vehicleName.data(), laneName.data(),
30
31
32
                            positionOnLane, speed);
}

33
34
void MapAppAPIWrapper::addOrReplaceCar(std::string_view vehicleName,
                                       std::string_view laneName,
35
36
37
                                       const double positionOnLane,
                                       const double speed,
                                       const double remainingFuel) {
38
  mapAppAddOrReplaceCar(mapApp, vehicleName.data(), laneName.data(),
39
                        positionOnLane, speed, remainingFuel);
Martin Kröning's avatar
Martin Kröning committed
40
41
}

42
void MapAppAPIWrapper::setDurationLabel(const std::chrono::minutes minutes) {
Martin Kröning's avatar
Martin Kröning committed
43
44
  mapAppSetDurationLabel(mapApp, minutes.count());
}