围栏可以在表格编辑
This commit is contained in:
@@ -2029,6 +2029,58 @@ void OPMapWidget::WPFollowPrevious(bool flag,WayPointItem *w)
|
||||
|
||||
}
|
||||
|
||||
void OPMapWidget::setFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng)
|
||||
{
|
||||
//查找对应的组,进行设置
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if ((w)&&(w->Group() == group)) {
|
||||
|
||||
/*
|
||||
w->setInclusion(inclusion);
|
||||
w->setRadius(radius);
|
||||
w->setLatitude(lat);
|
||||
w->setLongitude(lng);
|
||||
*/
|
||||
|
||||
w->setParameter(group,radius,inclusion,lat,lng);
|
||||
|
||||
qDebug() << "set Circle value" << group << radius << inclusion << lat << lng;
|
||||
}
|
||||
}
|
||||
qDebug() << "set Circle";
|
||||
}
|
||||
|
||||
void OPMapWidget::setFencePolygon(int group,qreal vertex,bool inclusion,QList<QPointF> latlng)
|
||||
{
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if ((w)&&(w->Group() == group)) {
|
||||
|
||||
QList<internals::PointLatLng> p;
|
||||
|
||||
for(QPointF pf:latlng)
|
||||
{
|
||||
internals::PointLatLng ll;
|
||||
|
||||
ll.SetLat(pf.x());
|
||||
ll.SetLng(pf.y());
|
||||
|
||||
p.push_back(ll);
|
||||
}
|
||||
|
||||
w->setInclusion(inclusion);
|
||||
w->setVertex(vertex);
|
||||
w->setPoints(p);
|
||||
qDebug() << "set Polygon value";
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "set Polygon";
|
||||
}
|
||||
|
||||
|
||||
//先清除再读取
|
||||
void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
{
|
||||
@@ -2055,6 +2107,7 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
QJsonObject json = doc.object();
|
||||
|
||||
//栅栏解码
|
||||
int fenceCount = 0;
|
||||
QJsonArray circlesArray = json.value("geoFence").toObject().value("circles").toArray();
|
||||
for(QJsonValue item: circlesArray) {
|
||||
|
||||
@@ -2072,9 +2125,12 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
//生成一个⚪
|
||||
|
||||
|
||||
geoFenceitem *centeritem = new geoFenceitem(0,1,1, inclusion ,internals::PointLatLng(lat,lng),QColor("#FF8000"),map);
|
||||
//geoFenceitem *centeritem = new geoFenceitem(fenceCount,inclusion,version,internals::PointLatLng(lat,lng),QColor("#FF8000"),map);
|
||||
|
||||
geoFencecircle *c = new geoFencecircle(0,1,1,inclusion,centeritem,radius,QColor("#FF8000"),map);
|
||||
geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,version,internals::PointLatLng(lat,lng),radius,QColor("#FF8000"),map);
|
||||
|
||||
|
||||
emit createFenceCircle(fenceCount++,radius,inclusion,lat,lng);
|
||||
|
||||
}
|
||||
|
||||
@@ -2083,7 +2139,7 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
|
||||
//每个item是一个组
|
||||
QList<internals::PointLatLng> points;
|
||||
QList<geoFenceitem *> polyitems;
|
||||
QList<QPointF> latlng;
|
||||
//获得边界
|
||||
bool inclusion = item.toObject().value("inclusion").toBool();
|
||||
QJsonArray polygon = item.toObject().value("polygon").toArray();
|
||||
@@ -2099,12 +2155,12 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
//生成一个多边形
|
||||
points.push_back(internals::PointLatLng(lat,lng));
|
||||
|
||||
qDebug() << "polygon" << inclusion << version << lat << lng;
|
||||
|
||||
|
||||
lat_sum += lat;
|
||||
lng_sum += lng;
|
||||
|
||||
|
||||
latlng.push_back(QPointF(lat,lng));
|
||||
|
||||
}
|
||||
|
||||
internals::PointLatLng center;
|
||||
@@ -2112,51 +2168,11 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
center.SetLat(lat_sum/polygon.size());
|
||||
center.SetLng(lng_sum/polygon.size());
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(0,points.size(),0, inclusion ,center,QColor("#FF8000"),map);
|
||||
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,version,center,QColor("#FF8000"),map);
|
||||
|
||||
polyitem->setPoints(points);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
int count = 0;
|
||||
for(internals::PointLatLng p : points)
|
||||
{
|
||||
geoFenceitem *polyitem = new geoFenceitem(0,points.size(),count, inclusion ,p,QColor("#FF8000"),map);
|
||||
count ++;
|
||||
polyitems.push_back(polyitem);
|
||||
|
||||
}
|
||||
|
||||
geoFenceitem *last;
|
||||
|
||||
for(geoFenceitem *p : polyitems)
|
||||
{
|
||||
if(p == polyitems.first())
|
||||
{
|
||||
last = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p == polyitems.last())
|
||||
{
|
||||
geoFenceitemline *polyline = new geoFenceitemline(last, polyitems.first(),map,QColor("#FF8000"));
|
||||
}
|
||||
else
|
||||
{
|
||||
geoFenceitemline *polyline = new geoFenceitemline(last, p,map,QColor("#FF8000"));
|
||||
last = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
emit createFencePolygon(fenceCount++,points.size(),inclusion,latlng);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user