version 2.13.0
add Map library (MapView with OSM maps and items) and mapviewer util
This commit is contained in:
35
libs/map/mapitemgeopolygon.cpp
Normal file
35
libs/map/mapitemgeopolygon.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "mapitemgeopolygon.h"
|
||||
|
||||
#include "osm_math_p.h"
|
||||
|
||||
|
||||
MapItemGeoPolygon::MapItemGeoPolygon(const QPolygonF & p) {
|
||||
ignore_scale = true;
|
||||
setPolygon(p);
|
||||
}
|
||||
|
||||
|
||||
void MapItemGeoPolygon::setPolygon(const QPolygonF & p) {
|
||||
pol = p;
|
||||
updatePolygon();
|
||||
}
|
||||
|
||||
|
||||
void MapItemGeoPolygon::draw(QPainter * p) {
|
||||
p->setPen(pen());
|
||||
p->setBrush(brush());
|
||||
QPolygonF dp(norm_polygon);
|
||||
QPointF pos_offset = mapToView(norm_pos);
|
||||
for (auto & i: dp)
|
||||
i = mapToView(i) - pos_offset;
|
||||
p->drawPolygon(dp);
|
||||
setBoundingRect(dp.boundingRect());
|
||||
}
|
||||
|
||||
|
||||
void MapItemGeoPolygon::updatePolygon() {
|
||||
norm_polygon.resize(pol.size());
|
||||
for (int i = 0; i < pol.size(); ++i)
|
||||
norm_polygon[i] = OSM::geo2xy(pol[i]);
|
||||
updateParent();
|
||||
}
|
||||
Reference in New Issue
Block a user