添加围栏存储功能
This commit is contained in:
@@ -35,7 +35,7 @@ void geoFencecircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setOpacity(0.4);
|
||||
painter->setOpacity(0.5);
|
||||
|
||||
QPointF p1;
|
||||
QPointF p2;
|
||||
@@ -97,7 +97,7 @@ void geoFencecircle::refreshLocations()
|
||||
|
||||
rectangle.setRect(-line.length(),-line.length(), 2 * line.length(), 2 * line.length());
|
||||
|
||||
qDebug() << line << rectangle << C.Lat() << C.Lng() << m_radius;
|
||||
//qDebug() << line << rectangle << C.Lat() << C.Lng() << m_radius;
|
||||
|
||||
setPos(p);
|
||||
update();
|
||||
|
||||
@@ -27,7 +27,7 @@ void geoFenceitem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setOpacity(0.4);
|
||||
painter->setOpacity(0.5);
|
||||
|
||||
QPen myPen = painter->pen();
|
||||
myPen.setWidth(lineWidth);
|
||||
|
||||
@@ -2332,15 +2332,59 @@ void OPMapWidget::WPSave(QString path)//带文件目录参数
|
||||
QJsonArray circles;
|
||||
QJsonArray polygons;
|
||||
{
|
||||
QJsonArray polygon;
|
||||
QJsonObject polygonObj;
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
|
||||
polygonObj["inclusion"] = true;
|
||||
polygonObj["polygon"] = polygon;
|
||||
polygonObj["version"] = 1;
|
||||
QJsonArray polygon;
|
||||
QJsonObject polygonObj;
|
||||
|
||||
polygons.append(polygonObj);
|
||||
QList<internals::PointLatLng> points = w->points;
|
||||
|
||||
for(internals::PointLatLng ll:points)
|
||||
{
|
||||
|
||||
QJsonArray latlng;
|
||||
latlng.append(ll.Lat());
|
||||
latlng.append(ll.Lng());
|
||||
|
||||
polygon.push_back(latlng);
|
||||
}
|
||||
|
||||
polygonObj["inclusion"] = w->Inclusion();
|
||||
polygonObj["polygon"] = polygon;
|
||||
polygonObj["version"] = 1;
|
||||
|
||||
|
||||
polygons.push_back(polygonObj);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
QJsonObject circle;
|
||||
QJsonObject circleObj;
|
||||
|
||||
|
||||
QJsonArray center;
|
||||
center.append(w->Latitude());
|
||||
center.append(w->Longitude());
|
||||
|
||||
double radius = w->Radius();
|
||||
|
||||
circle["center"] = center;
|
||||
circle["radius"] = radius;
|
||||
|
||||
|
||||
circleObj["inclusion"] = w->Inclusion();
|
||||
circleObj["circle"] = circle;
|
||||
circleObj["version"] = 1;
|
||||
|
||||
|
||||
circles.push_back(circleObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
geoFence.insert("circles",circles);
|
||||
geoFence.insert("polygons",polygons);
|
||||
|
||||
Reference in New Issue
Block a user