35 lines
932 B
C++
35 lines
932 B
C++
//
|
|
// Created by scoliono on 10/14/23.
|
|
//
|
|
|
|
#include "SigalertRoad.h"
|
|
#include "SigalertRoadSensor.h"
|
|
#include "../include/IntervalTree.h"
|
|
#include <utility>
|
|
|
|
|
|
SigalertRoad::SigalertRoad(int id, const SigalertRoadJson& json)
|
|
: m_id(id), m_name(json.name), m_section_idx_range{json.section_start_idx, json.section_end_idx}
|
|
{
|
|
std::vector<Interval<int, int>> intervals;
|
|
for (auto sensor : json.sensors)
|
|
{
|
|
intervals.push_back(Interval<int, int>(sensor[0], sensor[1], sensor[2]));
|
|
}
|
|
m_sensor_speedlimits = IntervalTree<int, int>(std::move(intervals));
|
|
}
|
|
|
|
void SigalertRoad::addSection(SigalertRoadSection* section)
|
|
{
|
|
m_sections.push_back(section);
|
|
}
|
|
|
|
void SigalertRoad::populateSensors(const std::vector<SigalertRoadSensor*>& sensors)
|
|
{
|
|
for (int i = m_section_idx_range[0]; i <= m_section_idx_range[1]; ++i)
|
|
{
|
|
m_sensors.push_back(sensors[i]);
|
|
sensors[i]->setRoad(this);
|
|
}
|
|
}
|