54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
//
|
|
// Created by scoliono on 10/14/23.
|
|
//
|
|
|
|
#ifndef FEMMAPS_SIGALERTMAPPROVIDER_H
|
|
#define FEMMAPS_SIGALERTMAPPROVIDER_H
|
|
|
|
#include "MapProvider.h"
|
|
#include "SigalertRoad.h"
|
|
#include "SigalertRoadSection.h"
|
|
#include "../include/json.hpp"
|
|
#include <curl/curl.h>
|
|
#include <vector>
|
|
|
|
|
|
class SigalertMapProvider : public MapProvider {
|
|
|
|
public:
|
|
SigalertMapProvider();
|
|
~SigalertMapProvider();
|
|
void refreshData();
|
|
inline const std::vector<SigalertRoadSection*> roadSections() const { return m_allsections; }
|
|
inline const std::vector<SigalertRoadSensor*> roadSensors() const { return m_allsensors; }
|
|
inline const std::map<int, Road*>& roads() const { return m_roads; }
|
|
|
|
private:
|
|
static constexpr const char* STATIC_DATA_URL = "https://cdn-static.sigalert.com/240/Zip/RegionInfo/NoCalStatic.json";
|
|
static constexpr const char* CURRENT_DATA_URL = "https://www.sigalert.com/Data/NoCal/0~j/NoCalData.json";
|
|
|
|
void populateRoads();
|
|
void populateRoadSections();
|
|
void populateRoadSensors();
|
|
|
|
std::map<int, Road*> m_roads;
|
|
std::vector<SigalertRoadSection*> m_allsections;
|
|
std::vector<SigalertRoadSensor*> m_allsensors;
|
|
CURL* m_curl;
|
|
|
|
struct MemoryStruct {
|
|
char* memory;
|
|
size_t size;
|
|
};
|
|
size_t curl_write_callback(void* contents, size_t size, size_t nmemb, void* userp);
|
|
|
|
MemoryStruct m_static_data;
|
|
nlohmann::json m_static_json;
|
|
MemoryStruct m_current_data;
|
|
nlohmann::json m_current_json;
|
|
|
|
};
|
|
|
|
|
|
#endif //FEMMAPS_SIGALERTMAPPROVIDER_H
|