config 读取边界
This commit is contained in:
@@ -299,3 +299,92 @@ void Config::setTTS(QVariant value)
|
||||
|
||||
setJsonObject("Sound",obj);
|
||||
}
|
||||
|
||||
QMap<int, Config::_latlng> Config::getVirtualMargin(int type)
|
||||
{
|
||||
QJsonObject obj = getJsonObject("VirtualMargin");
|
||||
|
||||
QJsonArray notice_obj = obj.value("orange").toArray();
|
||||
QJsonArray warning_obj = obj.value("red").toArray();
|
||||
|
||||
QMap<int, Config::_latlng> map;
|
||||
|
||||
|
||||
if(type == 0)//红
|
||||
{
|
||||
foreach (QJsonValue v, warning_obj) {
|
||||
Config::_latlng latlng;
|
||||
|
||||
latlng.index = v.toObject().value("index").toInt();
|
||||
latlng.latitude = v.toObject().value("latitude").toDouble();
|
||||
latlng.longitude = v.toObject().value("longitude").toDouble();
|
||||
|
||||
map.insert(latlng.index,latlng);
|
||||
|
||||
qDebug() << "virtual margin" << type << latlng.index << latlng.latitude << latlng.longitude;
|
||||
}
|
||||
}
|
||||
else if(type == 1)//黄
|
||||
{
|
||||
foreach (QJsonValue v, notice_obj) {
|
||||
Config::_latlng latlng;
|
||||
|
||||
latlng.index = v.toObject().value("index").toInt();
|
||||
latlng.latitude = v.toObject().value("latitude").toDouble();
|
||||
latlng.longitude = v.toObject().value("longitude").toDouble();
|
||||
|
||||
map.insert(latlng.index,latlng);
|
||||
qDebug() << "virtual margin" << type << latlng.index << latlng.latitude << latlng.longitude;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
void Config::setVirtualMargin(QMap<int, Config::_latlng> mvs,int type)
|
||||
{
|
||||
QJsonObject obj = getJsonObject("VirtualMargin");//总
|
||||
|
||||
QJsonArray notice_obj = obj.value("orange").toArray();
|
||||
QJsonArray warning_obj = obj.value("red").toArray();
|
||||
|
||||
|
||||
if(type == 0)//红
|
||||
{
|
||||
foreach (Config::_latlng latlng, mvs) {
|
||||
|
||||
QJsonObject v;
|
||||
|
||||
v["index"] = latlng.index;
|
||||
v["latitude"] = latlng.latitude;
|
||||
v["longitude"] = latlng.longitude;
|
||||
}
|
||||
}
|
||||
else if(type == 1)//黄
|
||||
{
|
||||
foreach (QJsonValue v, notice_obj) {
|
||||
Config::_latlng latlng;
|
||||
|
||||
latlng.index = v.toObject().value("index").toInt();
|
||||
latlng.latitude = v.toObject().value("latitude").toDouble();
|
||||
latlng.longitude = v.toObject().value("longitude").toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
obj["orange"] = notice_obj;
|
||||
obj["red"] = warning_obj;
|
||||
|
||||
setJsonObject("VirtualMargin",obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user