Skip to content

Commit

Permalink
Fix qube major bugs (#4457)
Browse files Browse the repository at this point in the history
* WayAverager uninitialized members in constructor
* Rethrow original exception in ChangesetTaskGridReplacer
* Initialize values before use in AttributeScoreExtractor
* Cleanup _oneDistance return
* Initialize type value in constructor
* Rethrow original exception in NodeDensityTileBoundsCalculator
* Set the status not compare it in BuildingMerger::_fixStatuses()
* Initialize members in RStarTreePrinter constructor
* Initialize RGB value to 0 before calculating.
* Reduce complexity of DirectedGraph::determineCost() function
* Initialize bounds arrays in HilbertRTree
* Add HTTPS to ignore list for tag translation in PoiPolygonTypeScoreExtractor
* Adding HOOT_HOME prefix to test pathnames
* Update copyright
  • Loading branch information
bmarchant authored Jan 20, 2021
1 parent 8200e24 commit 4dfcebf
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 87 deletions.
10 changes: 6 additions & 4 deletions hoot-core-test/src/test/cpp/hoot/core/TestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/

#ifndef TESTUTILS_H
Expand Down Expand Up @@ -263,10 +263,12 @@ class HootTestFixture : public CppUnit::TestFixture
ResetAll
};

/** Constructor to set the paths, default reset to none, and create the output path if needed */
/** Constructor to set the paths to begin with $HOOT_HOME if used, default reset to none,
* and create the output path if needed
*/
HootTestFixture(const QString& inputPath = UNUSED_PATH, const QString& outputPath = UNUSED_PATH)
: _inputPath(inputPath),
_outputPath(outputPath),
: _inputPath((inputPath != UNUSED_PATH) ? ConfPath::getHootHome() + "/" + inputPath : inputPath),
_outputPath((outputPath != UNUSED_PATH) ? ConfPath::getHootHome() + "/" + outputPath : outputPath),
_reset(ResetNone)
{
if (outputPath != UNUSED_PATH)
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. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/

// Hoot
Expand Down Expand Up @@ -247,8 +247,6 @@ class OsmSchemaTest : public HootTestFixture
*/
void loadTest()
{
QString hootHome(getenv("HOOT_HOME"));

OsmSchema& uut = OsmSchema::getInstance();

QFile fp("tmp/schema.dot");
Expand Down
7 changes: 4 additions & 3 deletions hoot-core/src/main/cpp/hoot/core/Hoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "Hoot.h"

Expand All @@ -36,8 +36,9 @@
#include <geos/version.h>

// hoot
#include <hoot/core/util/Factory.h>
#include <hoot/core/util/ConfigOptions.h>
#include <hoot/core/util/ConfPath.h>
#include <hoot/core/util/Factory.h>
#include <hoot/core/util/HootException.h>
#include <hoot/core/util/Log.h>
#include <hoot/core/util/SignalCatcher.h>
Expand Down Expand Up @@ -85,7 +86,7 @@ void Hoot::_init()
# ifdef TGS_HAVE_LIBSTXXL
// initialize the environment variable for loading STXXL configuration. If the environment
// variable has already been set then don't overwrite it (that is the 0 at the end).
QString stxxlConf = QString(getenv("HOOT_HOME")) + "/conf/core/stxxl.conf";
QString stxxlConf = ConfPath::getHootHome() + "/conf/core/stxxl.conf";
Tgs::Stxxl::getInstance().setConfig(stxxlConf);
# endif

Expand Down
12 changes: 10 additions & 2 deletions hoot-core/src/main/cpp/hoot/core/algorithms/WayAverager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/

#include "WayAverager.h"
Expand Down Expand Up @@ -51,7 +51,15 @@ namespace hoot
{

WayAverager::WayAverager(OsmMapPtr map, WayPtr w1, WayPtr w2) :
_map(*map)
_map(*map),
_meanMovement1(0.0),
_meanMovement2(0.0),
_sumMovement1(0.0),
_sumMovement2(0.0),
_maxMovement1(0.0),
_maxMovement2(0.0),
_moveCount1(0),
_moveCount2(0)
{
if (w1->getStatus() == Status::Unknown2 && w2->getStatus() == Status::Unknown1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ OsmMapPtr ChangesetTaskGridReplacer::replace(
}
else
{
throw e;
// Rethrow original exception
throw;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2005 VividSolutions (http://www.vividsolutions.com/)
* @copyright Copyright (C) 2015, 2017, 2018 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2017, 2018, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "AttributeScoreExtractor.h"

Expand Down Expand Up @@ -64,8 +64,8 @@ void AttributeScoreExtractor::setConfiguration(const Settings& conf)
double AttributeScoreExtractor::_extract(const OsmMap& /*map*/, const ConstWayPtr& w1,
const ConstWayPtr& w2) const
{
double score;
double weight;
double score = 1.0;
double weight = 0.0;
TagComparator::getInstance().compareEnumeratedTags(w1->getTags(), w2->getTags(), score, weight);
if (_useWeight)
{
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. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "EdgeDistanceExtractor.h"

Expand Down Expand Up @@ -163,8 +163,7 @@ double EdgeDistanceExtractor::_oneDistance(const OsmMap& map,
return -1;
}

const double result = _aggregator->aggregate(distances);
return result;
return _aggregator->aggregate(distances);
}

std::shared_ptr<Geometry> EdgeDistanceExtractor::_toLines(const OsmMap& map,
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. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "PoiPolygonTypeScoreExtractor.h"

Expand Down Expand Up @@ -141,7 +141,8 @@ void PoiPolygonTypeScoreExtractor::_translateTagValue(const QString& tagKey, QSt
LOG_VART(tagValue);

//don't care about urls
if (tagValue.toLower().startsWith("http://"))
if (tagValue.toLower().startsWith("http://") ||
tagValue.toLower().startsWith("https://"))
{
return;
}
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. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "MatchGraph.h"

Expand Down Expand Up @@ -67,15 +67,16 @@ class MatchEdge
{
public:

MatchEdge() : match(0) {}
MatchEdge(ConstMatchPtr m) : match(m) {}

typedef enum
{
AssociatedWith,
MatchWith
MatchWith,
InvalidMatch
} MatchType;

MatchEdge() : match(0), type(InvalidMatch) {}
MatchEdge(ConstMatchPtr m, MatchType t) : match(m), type(t) {}

ConstMatchPtr match;
MatchType type;
};
Expand Down Expand Up @@ -254,8 +255,7 @@ class MatchGraphInternal

void _addMatchWith(ConstMatchPtr m)
{
MatchEdge matchWith(m);
matchWith.type = MatchEdge::MatchWith;
MatchEdge matchWith(m, MatchEdge::MatchWith);

// add an edge for each of the match pairs (typically just one match pair)
set<pair<ElementId, ElementId>> eids = m->getMatchPairs();
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. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "BuildingMerger.h"

Expand Down Expand Up @@ -760,23 +760,23 @@ void BuildingMerger::_fixStatuses(OsmMapPtr map)
{
if (secondElement->getStatus() == Status::Unknown1)
{
firstElement->getStatus() == Status::Unknown2;
firstElement->setStatus(Status::Unknown2);
}
else if (secondElement->getStatus() == Status::Unknown2)
{
firstElement->getStatus() == Status::Unknown1;
firstElement->setStatus(Status::Unknown1);
}
}
else if (secondElement->getStatus() == Status::Conflated &&
firstElement->getStatus() != Status::Conflated)
{
if (firstElement->getStatus() == Status::Unknown1)
{
secondElement->getStatus() == Status::Unknown2;
secondElement->setStatus(Status::Unknown2);
}
else if (firstElement->getStatus() == Status::Unknown2)
{
secondElement->getStatus() == Status::Unknown1;
secondElement->setStatus(Status::Unknown1);
}
}
}
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. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/

#include "NodeDensityTileBoundsCalculator.h"
Expand Down Expand Up @@ -147,7 +147,8 @@ void NodeDensityTileBoundsCalculator::calculateTiles(const ConstOsmMapPtr& map)
{
msg += " Aborting calculation.";
LOG_ERROR(msg);
throw e;
// Rethrow original exception
throw;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
#include "PythonSchemaTranslator.h"

// hoot
#include <hoot/core/elements/Tags.h>
#include <hoot/core/util/ConfPath.h>
#include <hoot/core/util/Exception.h>
#include <hoot/core/util/Factory.h>
#include <hoot/core/elements/Tags.h>
#include <hoot/core/util/Log.h>

// Qt
Expand Down Expand Up @@ -70,7 +71,7 @@ void PythonSchemaTranslator::_init()
{
LOG_DEBUG("Initializing Python");

QString hootHome(getenv("HOOT_HOME"));
QString hootHome = ConfPath::getHootHome();

QStringList pythonPath;
QString moduleName;
Expand Down
5 changes: 3 additions & 2 deletions hoot-core/src/main/cpp/hoot/core/schema/TagInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/

#include "TagInfo.h"
Expand All @@ -33,6 +33,7 @@
#include <hoot/core/io/OgrReader.h>
#include <hoot/core/io/OsmMapReaderFactory.h>
#include <hoot/core/util/ConfigOptions.h>
#include <hoot/core/util/ConfPath.h>
#include <hoot/core/util/Factory.h>
#include <hoot/core/util/Settings.h>
#include <hoot/core/util/StringUtils.h>
Expand Down Expand Up @@ -97,7 +98,7 @@ QString TagInfo::_getInfo(const QString& input)
std::shared_ptr<OgrReader> ogrReader = std::dynamic_pointer_cast<OgrReader>(reader);
if (ogrReader.get())
{
ogrReader->setSchemaTranslationScript(QString(getenv("HOOT_HOME")) + "/translations/quick.js");
ogrReader->setSchemaTranslationScript(ConfPath::getHootHome() + "/translations/quick.js");

QStringList layers;
if (inputInfo.contains(";"))
Expand Down
4 changes: 2 additions & 2 deletions hoot-core/src/main/cpp/hoot/core/scoring/BaseComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/

#include "BaseComparator.h"
Expand Down Expand Up @@ -197,7 +197,7 @@ void BaseComparator::_saveImage(cv::Mat& image, QString path, double max, bool g

QImage qImage(_width, _height, QImage::Format_ARGB32);

QRgb rgb;
QRgb rgb = 0;
if (max > 0.0)
{
for (int y = 0; y < _height; y++)
Expand Down
36 changes: 9 additions & 27 deletions hoot-core/src/main/cpp/hoot/core/scoring/DirectedGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2015, 2017, 2018, 2019, 2020, 2021 DigitalGlobe (http://www.digitalglobe.com/)
*/

#include "DirectedGraph.h"
Expand Down Expand Up @@ -56,41 +56,23 @@ double DirectedGraph::determineCost(const std::shared_ptr<Way>& way)

// TODO: move to config
if (highway == "motorway")
{
mph = 65;
}
if (highway == "trunk")
{
else if (highway == "trunk")
mph = 45;
}
if (highway == "primary")
{
else if (highway == "primary")
mph = 30;
}
if (highway == "secondary")
{
else if (highway == "secondary")
mph = 25;
}
if (highway == "tertiary")
{
else if (highway == "tertiary")
mph = 22;
}
if (highway == "residential" || highway == "unclassified")
{
else if (highway == "residential" || highway == "unclassified")
mph = 15;
}
if (highway == "living_street")
{
else if (highway == "living_street")
mph = 10;
}
if (highway == "track")
{
else if (highway == "track")
mph = 10;
}
if (highway == "path")
{
else if (highway == "path")
mph = 5;
}

return _mphToSecondsPerMeter(mph);
}
Expand Down
Loading

0 comments on commit 4dfcebf

Please sign in to comment.