Skip to content

Commit 32aef5f

Browse files
committed
gdal: Resolve various analyzer hints
1 parent 4131001 commit 32aef5f

File tree

5 files changed

+35
-34
lines changed

5 files changed

+35
-34
lines changed

src/gdal/gdal_manager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2018 Kai Pastor
2+
* Copyright 2016-2019 Kai Pastor
33
*
44
* This file is part of OpenOrienteering.
55
*
@@ -68,6 +68,9 @@ class GdalManager::GdalManagerPrivate
6868
}
6969

7070
GdalManagerPrivate(const GdalManagerPrivate&) = delete;
71+
GdalManagerPrivate(GdalManagerPrivate&&) = delete;
72+
GdalManagerPrivate& operator=(const GdalManagerPrivate&) = delete;
73+
GdalManagerPrivate&& operator=(GdalManagerPrivate&&) = delete;
7174

7275
void configure()
7376
{

src/gdal/gdal_settings_page.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2018 Kai Pastor
2+
* Copyright 2016-2019 Kai Pastor
33
*
44
* This file is part of OpenOrienteering.
55
*
@@ -94,10 +94,8 @@ GdalSettingsPage::GdalSettingsPage(QWidget* parent)
9494
connect(parameters, &QTableWidget::cellChanged, this, &GdalSettingsPage::cellChange);
9595
}
9696

97-
GdalSettingsPage::~GdalSettingsPage()
98-
{
99-
// nothing, not inlined
100-
}
97+
GdalSettingsPage::~GdalSettingsPage() = default;
98+
10199

102100
QString GdalSettingsPage::title() const
103101
{

src/gdal/ogr_file_format.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ OgrFileImport::OgrFileImport(const QString& path, Map* map, MapView* view, UnitT
541541
: Importer(path, map, view)
542542
, manager{ OGR_SM_Create(nullptr) }
543543
, unit_type{ unit_type }
544-
, georeferencing_import_enabled{ true }
545544
{
546545
GdalManager().configure();
547546

@@ -829,7 +828,8 @@ ogr::unique_srs OgrFileImport::importGeoreferencing(OGRDataSourceH data_source)
829828
CPLFree(projected_srs_spec);
830829
return suitable_srs;
831830
}
832-
else if (suitable_srs)
831+
832+
if (suitable_srs)
833833
{
834834
// Found a suitable SRS but it is not projected.
835835
// Setting up a local orthographic projection.
@@ -847,18 +847,17 @@ ogr::unique_srs OgrFileImport::importGeoreferencing(OGRDataSourceH data_source)
847847
map->setGeoreferencing(ortho_georef);
848848
return srsFromMap();
849849
}
850-
else if (local_srs || no_srs)
850+
851+
if (local_srs || no_srs)
851852
{
852853
auto georef = Georeferencing();
853854
georef.setScaleDenominator(int(map->getScaleDenominator()));
854855
georef.setDeclination(map->getGeoreferencing().getDeclination());
855856
map->setGeoreferencing(georef);
856857
return local_srs ? std::move(local_srs) : srsFromMap();
857858
}
858-
else
859-
{
860-
throw FileFormatException(tr("The geospatial data has no suitable spatial reference."));
861-
}
859+
860+
throw FileFormatException(tr("The geospatial data has no suitable spatial reference."));
862861
}
863862

864863

@@ -1000,7 +999,8 @@ Object* OgrFileImport::importPointGeometry(OGRFeatureH feature, OGRGeometryH geo
1000999
object->setPosition(toMapCoord(OGR_G_GetX(geometry, 0), OGR_G_GetY(geometry, 0)));
10011000
return object;
10021001
}
1003-
else if (symbol->getType() == Symbol::Text)
1002+
1003+
if (symbol->getType() == Symbol::Text)
10041004
{
10051005
const auto& description = symbol->getDescription();
10061006
auto length = description.length();
@@ -1035,7 +1035,7 @@ Object* OgrFileImport::importPointGeometry(OGRFeatureH feature, OGRGeometryH geo
10351035
applyLabelAnchor(anchor, object);
10361036
}
10371037

1038-
auto angle = QStringRef(&description, 3, split-3).toFloat(&ok);
1038+
auto angle = QStringRef(&description, 3, split-3).toDouble(&ok);
10391039
if (ok)
10401040
{
10411041
object->setRotation(qDegreesToRadians(angle));
@@ -1121,7 +1121,7 @@ PathObject* OgrFileImport::importPolygonGeometry(OGRFeatureH feature, OGRGeometr
11211121

11221122
Symbol* OgrFileImport::getSymbol(Symbol::Type type, const char* raw_style_string)
11231123
{
1124-
auto style_string = QByteArray::fromRawData(raw_style_string, qstrlen(raw_style_string));
1124+
auto style_string = QByteArray::fromRawData(raw_style_string, int(qstrlen(raw_style_string)));
11251125
Symbol* symbol = nullptr;
11261126
switch (type)
11271127
{
@@ -1164,7 +1164,7 @@ Symbol* OgrFileImport::getSymbol(Symbol::Type type, const char* raw_style_string
11641164

11651165
MapColor* OgrFileImport::makeColor(OGRStyleToolH tool, const char* color_string)
11661166
{
1167-
auto key = QByteArray::fromRawData(color_string, qstrlen(color_string));
1167+
auto key = QByteArray::fromRawData(color_string, int(qstrlen(color_string)));
11681168
auto color = colors.value(key);
11691169
if (!color)
11701170
{
@@ -1369,7 +1369,7 @@ PointSymbol* OgrFileImport::getSymbolForOgrSymbol(OGRStyleToolH tool, const QByt
13691369
break;
13701370
default:
13711371
return nullptr;
1372-
};
1372+
}
13731373

13741374
int is_null;
13751375
auto color_string = OGR_ST_GetParamStr(tool, color_key, &is_null);
@@ -1412,7 +1412,7 @@ TextSymbol* OgrFileImport::getSymbolForLabel(OGRStyleToolH tool, const QByteArra
14121412

14131413
// Don't use the style string as a key: The style contains the label.
14141414
QByteArray key;
1415-
key.reserve(qstrlen(color_string) + qstrlen(font_size_string) + 1);
1415+
key.reserve(int(qstrlen(color_string) + qstrlen(font_size_string) + 1));
14161416
key.append(color_string);
14171417
key.append(font_size_string);
14181418
auto text_symbol = static_cast<TextSymbol*>(text_symbols.value(key));
@@ -1446,7 +1446,7 @@ TextSymbol* OgrFileImport::getSymbolForLabel(OGRStyleToolH tool, const QByteArra
14461446
angle = 0.0;
14471447

14481448
QString description;
1449-
description.reserve(qstrlen(label_string) + 100);
1449+
description.reserve(int(qstrlen(label_string) + 100));
14501450
description.append(QString::number(100 + anchor));
14511451
description.append(QString::number(angle, 'g', 1));
14521452
description.append(QLatin1Char(' '));
@@ -1461,7 +1461,7 @@ LineSymbol* OgrFileImport::getSymbolForPen(OGRStyleToolH tool, const QByteArray&
14611461
Q_ASSERT(OGR_ST_GetType(tool) == OGRSTCPen);
14621462

14631463
auto raw_tool_key = OGR_ST_GetStyleString(tool);
1464-
auto tool_key = QByteArray::fromRawData(raw_tool_key, qstrlen(raw_tool_key));
1464+
auto tool_key = QByteArray::fromRawData(raw_tool_key, int(qstrlen(raw_tool_key)));
14651465
auto symbol = line_symbols.value(tool_key);
14661466
if (symbol && symbol->getType() == Symbol::Line)
14671467
return static_cast<LineSymbol*>(symbol);
@@ -1493,7 +1493,7 @@ AreaSymbol* OgrFileImport::getSymbolForBrush(OGRStyleToolH tool, const QByteArra
14931493
Q_ASSERT(OGR_ST_GetType(tool) == OGRSTCBrush);
14941494

14951495
auto raw_tool_key = OGR_ST_GetStyleString(tool);
1496-
auto tool_key = QByteArray::fromRawData(raw_tool_key, qstrlen(raw_tool_key));
1496+
auto tool_key = QByteArray::fromRawData(raw_tool_key, int(qstrlen(raw_tool_key)));
14971497
auto symbol = area_symbols.value(tool_key);
14981498
if (symbol && symbol->getType() == Symbol::Area)
14991499
return static_cast<AreaSymbol*>(symbol);
@@ -2009,7 +2009,7 @@ void OgrFileExport::addTextToLayer(OGRLayerH layer, const std::function<bool (co
20092009
{
20102010
// There is no label field, or the text is too long.
20112011
// Put the text directly in the label.
2012-
text.replace(QRegularExpression(QLatin1String("([\"\\\\])"), QRegularExpression::MultilineOption), QLatin1String("\\\\1"));
2012+
text.replace(QRegularExpression(QLatin1String(R"((["\\]))"), QRegularExpression::MultilineOption), QLatin1String("\\\\1"));
20132013
style.replace("{Name}", text.toUtf8());
20142014
}
20152015
OGR_F_SetStyleString(po_feature.get(), style);
@@ -2028,7 +2028,7 @@ void OgrFileExport::addLinesToLayer(OGRLayerH layer, const std::function<bool (c
20282028
auto add_feature = [&](const Object* object) {
20292029
const auto* symbol = object->getSymbol();
20302030
const auto* path = object->asPath();
2031-
if (path->parts().size() < 1)
2031+
if (path->parts().empty())
20322032
return;
20332033

20342034
QString sym_name = symbol->getPlainTextName();
@@ -2069,7 +2069,7 @@ void OgrFileExport::addAreasToLayer(OGRLayerH layer, const std::function<bool (c
20692069
auto add_feature = [&](const Object* object) {
20702070
const auto* symbol = object->getSymbol();
20712071
const auto* path = object->asPath();
2072-
if (path->parts().size() < 1)
2072+
if (path->parts().empty())
20732073
return;
20742074

20752075
auto po_feature = ogr::unique_feature(OGR_F_Create(OGR_L_GetLayerDefn(layer)));

src/gdal/ogr_file_format_p.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,15 @@ class OgrFileImport : public Importer
327327

328328
ogr::unique_stylemanager manager;
329329

330-
int empty_geometries;
331-
int no_transformation;
332-
int failed_transformation;
333-
int unsupported_geometry_type;
334-
int too_few_coordinates;
330+
int empty_geometries = 0;
331+
int no_transformation = 0;
332+
int failed_transformation = 0;
333+
int unsupported_geometry_type = 0;
334+
int too_few_coordinates = 0;
335335

336336
UnitType unit_type;
337337

338-
bool georeferencing_import_enabled;
338+
bool georeferencing_import_enabled = true;
339339
};
340340

341341

src/gdal/ogr_template.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2018 Kai Pastor
2+
* Copyright 2016-2019 Kai Pastor
33
*
44
* This file is part of OpenOrienteering.
55
*
@@ -328,7 +328,7 @@ try
328328

329329
if (!explicit_georef)
330330
{
331-
explicit_georef.reset(new Georeferencing());
331+
explicit_georef = std::make_unique<Georeferencing>();
332332
explicit_georef->setScaleDenominator(int(map_georef.getScaleDenominator()));
333333
explicit_georef->setProjectedCRS(QString{}, projected_crs_spec);
334334
explicit_georef->setProjectedRefPoint({}, false);
@@ -506,7 +506,7 @@ bool OgrTemplate::loadTypeSpecificTemplateConfiguration(QXmlStreamReader& xml)
506506
{
507507
if (xml.name() == literal::georeferencing)
508508
{
509-
explicit_georef.reset(new Georeferencing());
509+
explicit_georef = std::make_unique<Georeferencing>();
510510
explicit_georef->load(xml, false);
511511
}
512512
else if (xml.name() == literal::crs_spec)

0 commit comments

Comments
 (0)