Skip to content

Commit

Permalink
Compilation not possible due to Werror (#5360)
Browse files Browse the repository at this point in the history
* Fix GCC 12 errors in geom2d and BaseInterpolator
* Enable C++14
* Frechet class cleanup
* Copyright
* Fix NodeJS configure error
  • Loading branch information
bmarchant authored Jun 9, 2022
1 parent 5c506b5 commit 1657e5d
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 1,226 deletions.
4 changes: 2 additions & 2 deletions Configure.pri.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ LIBS += @LIBS@
INCLUDEPATH += $$PWD
QMAKE_CXXFLAGS += @CPPFLAGS@
QMAKE_CXXFLAGS += @DEFS@
QMAKE_CXXFLAGS += -frounding-math -std=c++11
QMAKE_CXXFLAGS += -frounding-math -std=c++14

CONFIG += @HAS_NEWMAT@ @HAS_CPPUNIT@ \
@HAS_COVERAGE@ @HAS_SERVICES@ @HAS_STXXL@ @HAS_JOSM@ @HAS_NODEJS@ @HAS_UI_TESTS@ \
@HAS_LIBPOSTAL@ @HAS_LIBPHONENUMBER@ @HAS_GRAPHVIZ@
@HAS_LIBPOSTAL@ @HAS_LIBPHONENUMBER@ @HAS_GRAPHVIZ@ c++14

# Default to release mode, this can be overridden in LocalConfig.pri
CONFIG += release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022 Maxar (http://www.maxar.com/)
*/
#include "FrechetDistance.h"

Expand Down Expand Up @@ -238,7 +238,7 @@ Radians FrechetDistance::getHeadingAvg(WayPtr way, int index) const
return heading / count;
}

Meters FrechetDistance::distance()
Meters FrechetDistance::distance() const
{
// Since at least one endpoint in each way points to an endpoint of another a simple
// maximum value of all the closest distances is the non-discreet Frechet distance
Expand Down
4 changes: 2 additions & 2 deletions hoot-core/src/main/cpp/hoot/core/algorithms/FrechetDistance.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2021, 2022 Maxar (http://www.maxar.com/)
*/
#ifndef FRECHETDISTANCE_H
#define FRECHETDISTANCE_H
Expand Down Expand Up @@ -73,7 +73,7 @@ class FrechetDistance
* @brief distance - calculate the Frechet distance between the two ways, _w1 and _w2
* @return Frechet distance in meters
*/
Meters distance();
Meters distance() const;

/**
* @brief maxSubline - find the maximum length, in nodes, subline for the two ways
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022 Maxar (http://www.maxar.com/)
*/

#include "FrechetSublineMatcher.h"
Expand All @@ -45,13 +45,11 @@ namespace hoot

HOOT_FACTORY_REGISTER(SublineMatcher, FrechetSublineMatcher)

WaySublineMatchString FrechetSublineMatcher::findMatch(
const ConstOsmMapPtr& map, const ConstWayPtr& way1, const ConstWayPtr& way2, double& score,
Meters maxRelevantDistance) const
WaySublineMatchString FrechetSublineMatcher::findMatch(const ConstOsmMapPtr& map, const ConstWayPtr& way1, const ConstWayPtr& way2,
double& score, Meters maxRelevantDistance) const
{
score = 0;
Meters mrd = maxRelevantDistance == -1 ? way1->getCircularError() + way2->getCircularError() :
maxRelevantDistance;
Meters mrd = maxRelevantDistance == -1 ? way1->getCircularError() + way2->getCircularError() : maxRelevantDistance;
// Create a copy of the map and the two ways
OsmMapPtr mapCopy = std::make_shared<OsmMap>();
CopyMapSubsetOp(map, way1->getElementId(), way2->getElementId()).apply(mapCopy);
Expand All @@ -60,14 +58,13 @@ WaySublineMatchString FrechetSublineMatcher::findMatch(
vector<frechet_subline> max = fd.matchingSublines(mrd);
// Make sure that there is a valid subline
if (max.size() < 1)
{
return WaySublineMatchString();
}

vector<WaySublineMatch> v;
for (vector<frechet_subline>::iterator it = max.begin(); it != max.end(); ++it)
for (const auto& subline : max)
{
// Create the way sublines
subline_entry max_subline = it->second;
subline_entry max_subline = subline.second;
WaySubline subline1(WayLocation(mapCopy, way1, max_subline[0].first, 0),
WayLocation(mapCopy, way1, max_subline[max_subline.size() - 1].first, 0));
WaySubline subline2(WayLocation(mapCopy, way2, max_subline[0].second, 0),
Expand All @@ -81,16 +78,14 @@ WaySublineMatchString FrechetSublineMatcher::findMatch(
std::shared_ptr<LineString> ls1 = ElementToGeometryConverter(mapCopy).convertToLineString(sub1);
std::shared_ptr<LineString> ls2 = ElementToGeometryConverter(mapCopy).convertToLineString(sub2);
if (ls1->isValid() && ls2->isValid())
{
score = min(ls1->getLength(), ls2->getLength());
}
}
// Create the match and match string
WaySublineMatch match = WaySublineMatch(subline1, subline2);
bool insert = true;
for (vector<WaySublineMatch>::size_type i = 0; i < v.size(); i++)
for (const auto& m : v)
{
if (match.overlaps(v[i]))
if (match.overlaps(m))
insert = false;
}
if (insert)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022 Maxar (http://www.maxar.com/)
*/
#ifndef FRECHETSUBLINEMATCHER_H
#define FRECHETSUBLINEMATCHER_H
Expand Down Expand Up @@ -53,7 +53,7 @@ class FrechetSublineMatcher : public SublineMatcher, public Configurable
* input ways.
*/
WaySublineMatchString findMatch(const ConstOsmMapPtr& map, const ConstWayPtr& way1,
const ConstWayPtr& way2, double& score, Meters maxRelevantDistance = -1) const override;
const ConstWayPtr& way2, double& score, Meters maxRelevantDistance = -1) const override;

/**
* @see Configurable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015, 2021, 2022 Maxar (http://www.maxar.com/)
*/
#include "DoubleFieldDefinition.h"

Expand All @@ -44,13 +44,9 @@ DoubleFieldDefinition::DoubleFieldDefinition()
QVariant DoubleFieldDefinition::getDefaultValue() const
{
if (getDefaultIsNull())
{
return QVariant();
}
else
{
return QVariant(_defaultValue);
}
}

bool DoubleFieldDefinition::hasDefaultValue() const
Expand All @@ -68,18 +64,15 @@ QString DoubleFieldDefinition::toString() const

void DoubleFieldDefinition::validate(const QVariant& v, StrictChecking strict) const
{
// the value is null, no problem.
if (getAllowNull() && v.isValid() == false)
{
// the value is null, no problem.
return;
}

bool ok;
v.toString().toDouble(&ok);
if (ok == false)
{
_reportError(getName(), "Unable to convert value to a double: " + v.toString(), strict);
}

double d = v.toDouble();

if (_enumeratedValues.find(d) != _enumeratedValues.end())
Expand Down
21 changes: 6 additions & 15 deletions hoot-core/src/main/cpp/hoot/core/io/schema/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2017, 2019, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015, 2017, 2019, 2021, 2022 Maxar (http://www.maxar.com/)
*/
#include "Feature.h"

Expand All @@ -33,7 +33,8 @@
namespace hoot
{

Feature::Feature(const std::shared_ptr<const FeatureDefinition>& d) : _definition(d)
Feature::Feature(const std::shared_ptr<const FeatureDefinition>& d)
: _definition(d)
{
}

Expand All @@ -45,16 +46,13 @@ QString Feature::toString() const
void Feature::validate(StrictChecking strict)
{
// make sure we didn't get more fields than necessary
for (QVariantMap::const_iterator it = _values.begin(); it != _values.end(); ++it)
for (auto it = _values.begin(); it != _values.end(); ++it)
{
if (_definition->hasField(it.key()) == false)
{
QString error = QString("Returned a field name that isn't appropriate for this layer. %1")
.arg(it.key());
QString error = QString("Returned a field name that isn't appropriate for this layer. %1").arg(it.key());
if (strict == StrictOn)
{
throw FieldDefinition::InvalidValueException(it.key(), error);
}
else if (strict == StrictWarn)
{
LOG_WARN(error);
Expand All @@ -70,26 +68,19 @@ void Feature::validate(StrictChecking strict)
{
if (d->hasDefaultValue() == false)
{
QString error = QString("Field has no default value and no value was specified. (%1)")
.arg(d->getName());
QString error = QString("Field has no default value and no value was specified. (%1)").arg(d->getName());
if (strict == StrictOn)
{
throw FieldDefinition::InvalidValueException(d->getName(), error);
}
else if (strict == StrictWarn)
{
LOG_WARN(error);
}
}
else
{
_values[d->getName()] = d->getDefaultValue();
}
}
else
{
d->validate(_values[d->getName()], strict);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion m4/nodejs.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AC_DEFUN([NODEJS_INIT],[
# Now find out which version we have
# We set the include path in the hoot-js.pro file
#saved_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-std=c++11 -I/usr/include -I/usr/include/nodejs -I/usr/include/node -I/usr/include/nodejs/deps/uv/include ${CPPFLAGS}"
CPPFLAGS="-I/usr/include -I/usr/include/nodejs -I/usr/include/node -I/usr/include/nodejs/deps/uv/include ${CPPFLAGS}"
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([nodejs/src/node.h], [hootFoundNjsHeaders=yes; break;])
Expand Down
Loading

0 comments on commit 1657e5d

Please sign in to comment.