Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code formatting and updates 2 #5419

Merged
merged 27 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b82badb
Schema updates
bmarchant Aug 18, 2022
9cdf210
Scoring formatting and updates
bmarchant Aug 22, 2022
e469db0
Utils updates and formatting
bmarchant Aug 22, 2022
f72dc77
Copyright
bmarchant Aug 22, 2022
630f400
Sonar fixes
bmarchant Aug 22, 2022
220329b
Visitors updates and formatting part 1
bmarchant Aug 23, 2022
9db7237
Copyright
bmarchant Aug 23, 2022
648e0fd
IO and visitors updates and formatting
bmarchant Aug 23, 2022
6558fc1
IO fixes and formatting
bmarchant Aug 24, 2022
edc2b9a
More IO fixes and formatting
bmarchant Aug 25, 2022
727bff3
More IO fixes and formatting
bmarchant Aug 25, 2022
0e44f01
More IO fixes and formatting
bmarchant Aug 25, 2022
b5bfe1f
Cmd updates and formatting
bmarchant Aug 25, 2022
4b27f85
Merge remote-tracking branch 'origin/master' into code_formatting_and…
bmarchant Aug 25, 2022
ef64612
Conflate fixes and formatting
bmarchant Aug 26, 2022
5b651c4
Matching fixes and formatting
bmarchant Aug 26, 2022
f2db386
Merging fixes and formatting
bmarchant Aug 26, 2022
77c8d32
LinearDiffMerger fixes and formatting
bmarchant Aug 26, 2022
4326e7e
Network conflation fixes and formatting
bmarchant Aug 29, 2022
cce19eb
POI Polygon fixes and formatting
bmarchant Aug 29, 2022
887dae0
Conflate fixes and formatting
bmarchant Aug 29, 2022
b5573cc
Criterion fixes and formatting
bmarchant Aug 30, 2022
2761b48
Criterion fixes and formatting
bmarchant Aug 31, 2022
6041eff
Element fixes and formatting
bmarchant Aug 31, 2022
6d9980b
Copyright
bmarchant Aug 31, 2022
6a1d072
Sonar fixes
bmarchant Sep 1, 2022
57de84e
Copyright
bmarchant Sep 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 8 additions & 17 deletions hoot-core/src/main/cpp/hoot/core/cmd/AlignCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2017, 2018, 2019, 2020, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015, 2017, 2018, 2019, 2020, 2021, 2022 Maxar (http://www.maxar.com/)
*/

// Hoot
#include <hoot/core/util/Factory.h>
#include <hoot/core/cmd/BaseCommand.h>
#include <hoot/core/algorithms/rubber-sheet/RubberSheeter.h>
#include <hoot/core/algorithms/rubber-sheet/RubberSheetDeriver.h>
#include <hoot/core/algorithms/rubber-sheet/RubberSheetApplier.h>
#include <hoot/core/algorithms/rubber-sheet/RubberSheetDeriver.h>
#include <hoot/core/cmd/BaseCommand.h>
#include <hoot/core/util/Factory.h>
#include <hoot/core/util/StringUtils.h>

// Qt
Expand Down Expand Up @@ -62,8 +62,7 @@ class AlignCmd : public BaseCommand
if (args.size() < 3 || args.size() > 5)
{
std::cout << getHelp() << std::endl << std::endl;
throw HootException(
QString("%1 with the --derive option takes three to five parameters.").arg(getName()));
throw HootException(QString("%1 with the --derive option takes three to five parameters.").arg(getName()));
}

bool ref = false;
Expand All @@ -75,14 +74,9 @@ class AlignCmd : public BaseCommand

QString transform1to2Path;
if (args.size() == 4)
{
transform1to2Path = args[3];
}
else if (ref == false)
{
throw HootException(QString("You must specify a transform1to2.rs argument if --ref isn't "
"specified."));
}
throw HootException(QString("You must specify a transform1to2.rs argument if --ref isn't specified."));

RubberSheetDeriver().derive(args[0], args[1], args[2], transform1to2Path, ref);
}
Expand All @@ -92,8 +86,7 @@ class AlignCmd : public BaseCommand
if (args.size() != 3)
{
std::cout << getHelp() << std::endl << std::endl;
throw HootException(
QString("%1 with the --apply option takes three parameters.").arg(getName()));
throw HootException(QString("%1 with the --apply option takes three parameters.").arg(getName()));
}

RubberSheetApplier().apply(args[0], args[1], args[2]);
Expand All @@ -113,9 +106,7 @@ class AlignCmd : public BaseCommand
RubberSheeter().rubberSheet(args[0], args[1], args[2]);
}

LOG_STATUS(
"Alignment operation ran in " << StringUtils::millisecondsToDhms(timer.elapsed()) <<
" total.");
LOG_STATUS("Alignment operation ran in " << StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");

return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions hoot-core/src/main/cpp/hoot/core/cmd/AlphaShapeCmd.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, 2016, 2017, 2018, 2019, 2020, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Maxar (http://www.maxar.com/)
*/

// GEOS
Expand Down Expand Up @@ -127,9 +127,7 @@ class AlphaShapeCmd : public BaseCommand
// Save out the result.
_writeOutput(result, outputPath);

LOG_STATUS(
"Alpha shape written to " << outputPath << " in " <<
StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");
LOG_STATUS("Alpha shape written to " << outputPath << " in " << StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");

return 0;
}
Expand Down
10 changes: 3 additions & 7 deletions hoot-core/src/main/cpp/hoot/core/cmd/BaseCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ QString BaseCommand::getHelp() const

if (fp.open(QFile::ReadOnly) == false)
{
LOG_ERROR(QString("Error opening command help for reading. (%1) Is HOOT_HOME set properly?").
arg(_getHelpPath()));
LOG_ERROR(QString("Error opening command help for reading. (%1) Is HOOT_HOME set properly?").arg(_getHelpPath()));
}

return QString::fromUtf8(fp.readAll());
Expand Down Expand Up @@ -97,11 +96,8 @@ QStringList BaseCommand::_parseRecursiveInputParameter(QStringList& args, bool&
paramPresent = true;
const int recursiveIndex = args.indexOf("--recursive");
if (args.size() < recursiveIndex + 2)
{
throw IllegalArgumentException(
"The --recursive option must be followed by either \"*\" for no filtering or one or "
"more filters.");
}
throw IllegalArgumentException("The --recursive option must be followed by either \"*\" for no filtering or one or more filters.");

const QString filter = args.at(recursiveIndex + 1).trimmed();
// "*" denotes no filtering
if (filter != "*")
Expand Down
9 changes: 2 additions & 7 deletions hoot-core/src/main/cpp/hoot/core/cmd/BoundedCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,13 @@ void BoundedCommand::_writeBoundsFile()
QString boundsStr = opts.getBounds().trimmed();
if (!boundsStr.isEmpty())
{
OsmMapWriterFactory::write(
GeometryUtils::createMapFromBounds(GeometryUtils::boundsFromString(boundsStr)),
opts.getBoundsOutputFile());
OsmMapWriterFactory::write(GeometryUtils::createMapFromBounds(GeometryUtils::boundsFromString(boundsStr)), opts.getBoundsOutputFile());

if (_writeInternalEnvelope && GeometryUtils::isEnvelopeString(boundsStr))
{
QString outputFile = opts.getBoundsOutputFile();
outputFile = outputFile.replace(".osm", "-envelope-internal.osm");
OsmMapWriterFactory::write(
GeometryUtils::createMapFromBounds(
*(GeometryUtils::boundsFromString(boundsStr)->getEnvelopeInternal())),
outputFile);
OsmMapWriterFactory::write(GeometryUtils::createMapFromBounds(*(GeometryUtils::boundsFromString(boundsStr)->getEnvelopeInternal())), outputFile);
}
}
}
Expand Down
21 changes: 7 additions & 14 deletions hoot-core/src/main/cpp/hoot/core/cmd/BuildModelCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Maxar (http://www.maxar.com/)
*/

// Hoot
#include <hoot/core/util/Factory.h>
#include <hoot/core/cmd/BaseCommand.h>
#include <hoot/core/io/ArffToRfConverter.h>
#include <hoot/core/scoring/RandomForestModelBuilder.h>
#include <hoot/core/util/Factory.h>
#include <hoot/core/util/StringUtils.h>

// Qt
Expand Down Expand Up @@ -75,25 +75,19 @@ class BuildModelCmd : public BaseCommand
{
std::cout << getHelp() << std::endl << std::endl;
throw HootException(
QString(
"%1 takes an odd number of parameters and at least three parameters when converting to .rf from training data.")
.arg(getName()));
QString("%1 takes an odd number of parameters and at least three parameters when converting to .rf from training data.").arg(getName()));
}
else
{
// It must be a conversion to .rf from training data.
QStringList inputs;
for (int i = 0; i < args.size() - 1; i++)
{
inputs.append(args.at(i));
}
QStringList inputs = args;
// Remove the last one because it is the output
inputs.removeLast();
output = args.last();
RandomForestModelBuilder::build(inputs, args.last(), exportArffOnly);
}

LOG_STATUS(
"Model: ..." << output.right(25) << " built in " <<
StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");
LOG_STATUS("Model: ..." << output.right(25) << " built in " << StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");

return 0;
}
Expand All @@ -102,4 +96,3 @@ class BuildModelCmd : public BaseCommand
HOOT_FACTORY_REGISTER(Command, BuildModelCmd)

}

51 changes: 18 additions & 33 deletions hoot-core/src/main/cpp/hoot/core/cmd/ChangesetApplyCmd.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) 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/)
*/

// Hoot
Expand Down Expand Up @@ -85,27 +85,17 @@ class ChangesetApplyCmd : public BaseCommand
.arg(args.join(",")));
}

_progress =
std::make_shared<Progress>(
ConfigOptions().getJobId(), "Apply Changeset", Progress::JobState::Running);
_progress = std::make_shared<Progress>(ConfigOptions().getJobId(), "Apply Changeset", Progress::JobState::Running);

// Write changeset/OSM XML to OSM API
if (args[0].endsWith(".osc") || args[0].endsWith(".osm"))
{
_writeXmlChangeset(showProgress, showStats, args);
}
// Write changeset SQL directly to the database
else if (args[0].endsWith(".osc.sql"))
{
else if (args[0].endsWith(".osc.sql")) // Write changeset SQL directly to the database
_writeSqlChangeset(args);
}
else
{
throw HootException("Invalid changeset file format: " + args[0]);
}

LOG_STATUS(
"Changeset applied in " << StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");
LOG_STATUS("Changeset applied in " << StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");

return _success ? 0 : -1;
}
Expand All @@ -115,49 +105,45 @@ class ChangesetApplyCmd : public BaseCommand
std::shared_ptr<Progress> _progress;
bool _success = true;

void _writeXmlChangeset(
const bool showProgress, const bool showStats, const QStringList& args)
void _writeXmlChangeset(const bool showProgress, const bool showStats, const QStringList& args)
{
// Get the endpoint URL
const QString urlStr = args[args.size() - 1].toLower();
if (!urlStr.startsWith("http://") && !urlStr.startsWith("https://"))
{
throw IllegalArgumentException(
QString("XML changesets must be written to an OpenStreetMap compatible web service. ") +
QString("Tried to write to: " + urlStr));
QString("XML changesets must be written to an OpenStreetMap compatible web service. Tried to write to: %1").arg(urlStr));
}
QUrl osm;
osm.setUrl(args[args.size() - 1]);
osm.setUrl(args.last());

const int maxFilePrintLength = ConfigOptions().getProgressVarPrintLengthMax();

// Grab all the changeset files
QList<QString> changesets;
for (int i = 0; i < args.size() - 1; ++i)
// Grab all the changeset files (n - 1 args)
QList<QString> changesets = args;
changesets.removeLast();
for (const auto& input : qAsConst(changesets))
{
_progress->set(
0.0,
"Adding changeset: ..." + FileUtils::toLogFormat(args[i], maxFilePrintLength) +
"Adding changeset: ..." + FileUtils::toLogFormat(input, maxFilePrintLength) +
" for application to: " + FileUtils::toLogFormat(osm.toString(), maxFilePrintLength) +
"...", true);
changesets.append(args[i]);
}

// Get the error changeset pathname to pass to the writer
QFileInfo path(args[0]);
QString errorFilename =
path.absolutePath() + QDir::separator() + path.baseName() + "-error." + path.completeSuffix();
QString errorFilename = path.absolutePath() + QDir::separator() + path.baseName() + "-error." + path.completeSuffix();

// Do the actual splitting and uploading
OsmApiWriter writer(osm, changesets);
writer.setErrorPathname(errorFilename);
writer.showProgress(showProgress);
// OsmApiWriter is doing all the progress reporting but will pass a progress object in
// anyway, just in case we ever add any extra job steps outside of it.
if (showProgress)
{
// OsmApiWriter is doing all the progress reporting but will pass a progress object in
// anyway, just in case we ever add any extra job steps outside of it.
writer.setProgress(*_progress);
}

writer.apply();

_progress->set(
Expand All @@ -174,8 +160,7 @@ class ChangesetApplyCmd : public BaseCommand
if (writer.containsFailed())
{
// Output the errors from 'changeset.osc' to 'changeset-error.osc'
LOG_ERROR(
QString("Some changeset elements failed to upload. Stored in %1.").arg(errorFilename));
LOG_ERROR(QString("Some changeset elements failed to upload. Stored in %1.").arg(errorFilename));
writer.writeErrorFile();
}

Expand Down Expand Up @@ -208,7 +193,7 @@ class ChangesetApplyCmd : public BaseCommand
QUrl url(args[1]);
OsmApiDbSqlChangesetApplier changesetWriter(url);
changesetWriter.write(changesetSqlFile);
//The tests rely on this being output, so leave it as a cout and not a log statement.
// The tests rely on this being output, so leave it as a cout and not a log statement.
cout << changesetWriter.getChangesetStatsSummary();
}
};
Expand Down
Loading