Skip to content

Commit

Permalink
ISSUE #695 check that the calibration is valid before writing it to d…
Browse files Browse the repository at this point in the history
…atabase
  • Loading branch information
sebjf committed Sep 25, 2024
1 parent a5d7639 commit 991db93
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
4 changes: 4 additions & 0 deletions bouncer/src/repo/manipulator/modelutility/repo_drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ namespace repo {
std::vector<repo::lib::RepoVector3D> horizontalCalibration3d;
std::vector<repo::lib::RepoVector2D> horizontalCalibration2d;
std::string units;

bool valid() {
return horizontalCalibration2d.size() && horizontalCalibration3d.size();
}
};

/**
Expand Down
32 changes: 18 additions & 14 deletions bouncer/src/repo/manipulator/modelutility/repo_drawing_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,28 @@ uint8_t DrawingManager::commitImage(
return REPOERR_UPLOAD_FAILED;
}

// Retreive and process calibration
// Retreive and process calibration - drawing processors do not have to return a calibration,
// in which case the vectors will be empty.

auto calibration = drawing.calibration;
if (calibration.valid()) {

auto calibrationBSON = repo::core::model::RepoBSONFactory::makeRepoCalibration(
revision.getProject(),
revision.getModel(),
revId,
calibration.horizontalCalibration3d,
calibration.horizontalCalibration2d,
calibration.units
);
auto calibrationBSON = repo::core::model::RepoBSONFactory::makeRepoCalibration(
revision.getProject(),
revision.getModel(),
revId,
calibration.horizontalCalibration3d,
calibration.horizontalCalibration2d,
calibration.units
);

handler->insertDocument(teamspace, REPO_COLLECTION_CALIBRATIONS, calibrationBSON, error);
handler->insertDocument(teamspace, REPO_COLLECTION_CALIBRATIONS, calibrationBSON, error);

if (error.size())
{
repoError << "Error committing calibration: " << error;
return REPOERR_UPLOAD_FAILED;
if (error.size())
{
repoError << "Error committing calibration: " << error;
return REPOERR_UPLOAD_FAILED;
}
}

return REPOERR_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,9 @@ TEST(DrawingImportManager, ImportDWG)
// And of course expect that the DWG holds the above geometries

EXPECT_EQ(groupPrimitives, 2);

// Finally check that the calibration structure has been populated

EXPECT_TRUE(drawing.calibration.valid());
}

0 comments on commit 991db93

Please sign in to comment.