From 3385fc86d353c2800081f1ef1ba36957f161a08a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 5 Nov 2022 14:08:08 +0100 Subject: [PATCH] Code cleanup --- src/map/ENC/mapdata.cpp | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/map/ENC/mapdata.cpp b/src/map/ENC/mapdata.cpp index 0f196dcf..314e5db6 100644 --- a/src/map/ENC/mapdata.cpp +++ b/src/map/ENC/mapdata.cpp @@ -33,6 +33,14 @@ static void warning(const ISO8211::Field &FRID, uint PRIM) } } +static void pointBounds(const Coordinates &c, double min[2], double max[2]) +{ + min[0] = c.lon(); + min[1] = c.lat(); + max[0] = c.lon(); + max[1] = c.lat(); +} + static void rectcBounds(const RectC &rect, double min[2], double max[2]) { min[0] = rect.left(); @@ -598,18 +606,12 @@ void MapData::load() QVector s(soundingGeometry(r)); for (int i = 0; i < s.size(); i++) { point = pointObject(s.at(i)); - min[0] = point->pos().lon(); - min[1] = point->pos().lat(); - max[0] = point->pos().lon(); - max[1] = point->pos().lat(); + pointBounds(point->pos(), min, max); _points.Insert(min, max, point); } } else { if ((point = pointObject(r, OBJL))) { - min[0] = point->pos().lon(); - min[1] = point->pos().lat(); - max[0] = point->pos().lon(); - max[1] = point->pos().lat(); + pointBounds(point->pos(), min, max); _points.Insert(min, max, point); } else warning(f, PRIM); @@ -655,11 +657,7 @@ void MapData::points(const RectC &rect, QList *points) { double min[2], max[2]; - min[0] = rect.left(); - min[1] = rect.bottom(); - max[0] = rect.right(); - max[1] = rect.top(); - + rectcBounds(rect, min, max); _points.Search(min, max, pointCb, points); } @@ -667,11 +665,7 @@ void MapData::lines(const RectC &rect, QList *lines) { double min[2], max[2]; - min[0] = rect.left(); - min[1] = rect.bottom(); - max[0] = rect.right(); - max[1] = rect.top(); - + rectcBounds(rect, min, max); _lines.Search(min, max, lineCb, lines); } @@ -679,10 +673,6 @@ void MapData::polygons(const RectC &rect, QList *polygons) { double min[2], max[2]; - min[0] = rect.left(); - min[1] = rect.bottom(); - max[0] = rect.right(); - max[1] = rect.top(); - + rectcBounds(rect, min, max); _areas.Search(min, max, polygonCb, polygons); }