Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan24680 committed Feb 10, 2025
1 parent 61c6b98 commit c0bf282
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
28 changes: 14 additions & 14 deletions src/engine/SpatialJoinAlgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ std::optional<size_t> SpatialJoinAlgorithms::getAnyGeometry(
}

// ____________________________________________________________________________
double SpatialJoinAlgorithms::computeDist(
const size_t geometryIndex1,
const size_t geometryIndex2) const {
double SpatialJoinAlgorithms::computeDist(const size_t geometryIndex1,
const size_t geometryIndex2) const {
return boost::apply_visitor(ClosestPointVisitor(),
geometries_.at(geometryIndex1),
geometries_.at(geometryIndex2));
Expand Down Expand Up @@ -136,17 +135,17 @@ Id SpatialJoinAlgorithms::computeDist(RtreeEntry& geo1, RtreeEntry& geo2) {
geo1.geoPoint_.value(), geo2.geoPoint_.value()));
} else if (geo1.geometryIndex_.has_value() &&
geo2.geometryIndex_.has_value()) {
return Id::makeFromDouble(
computeDist(geo1.geometryIndex_.value(), geo2.geometryIndex_.value()));
return Id::makeFromDouble(computeDist(geo1.geometryIndex_.value(),
geo2.geometryIndex_.value()));
} else {
// one point and one area
if (!geo1.geometryIndex_) {
geo1.geometryIndex_ = convertGeoPointToPoint(geo1.geoPoint_.value());
} else if (!geo2.geometryIndex_) {
geo2.geometryIndex_ = convertGeoPointToPoint(geo2.geoPoint_.value());
}
return Id::makeFromDouble(
computeDist(geo1.geometryIndex_.value(), geo2.geometryIndex_.value()));
return Id::makeFromDouble(computeDist(geo1.geometryIndex_.value(),
geo2.geometryIndex_.value()));
}
}
}
Expand Down Expand Up @@ -216,17 +215,17 @@ Result SpatialJoinAlgorithms::BaselineAlgorithm() {
std::vector<std::pair<size_t, double>>,
decltype(compare)>
intermediate(compare);

auto entryLeft = getRtreeEntry(idTableLeft, rowLeft, leftJoinCol);

// Inner loop of cartesian product
for (size_t rowRight = 0; rowRight < idTableRight->size(); rowRight++) {
auto entryRight = getRtreeEntry(idTableRight, rowRight, rightJoinCol);

if (!entryLeft || !entryRight) {
continue;
}

Id dist = computeDist(entryLeft.value(), entryRight.value());

// Ensure `maxDist_` constraint
Expand Down Expand Up @@ -615,10 +614,11 @@ Result SpatialJoinAlgorithms::BoundingBoxAlgorithm() {
size_t rowRight;

bool operator<(const AddedPair& other) const {
return (rowLeft < other.rowLeft) || (rowLeft == other.rowLeft && rowRight < other.rowRight);
return (rowLeft < other.rowLeft) ||
(rowLeft == other.rowLeft && rowRight < other.rowRight);
}
};

const auto [idTableLeft, resultLeft, idTableRight, resultRight, leftJoinCol,
rightJoinCol, rightSelectedCols, numColumns, maxDist,
maxResults] = params_;
Expand Down Expand Up @@ -690,10 +690,10 @@ Result SpatialJoinAlgorithms::BoundingBoxAlgorithm() {
// as midpoints, the additional runtime can be saved in that case
if (useMidpointForAreas_) {
addResultTableEntry(&result, idTableLeft, idTableRight, rowLeft,
rowRight, distance);
rowRight, distance);
} else if (pairs.insert(AddedPair(rowLeft, rowRight)).second) {
addResultTableEntry(&result, idTableLeft, idTableRight, rowLeft,
rowRight, distance);
rowRight, distance);
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions src/engine/SpatialJoinAlgorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ class SpatialJoinAlgorithms {

// wrapper to access non const private function for testing
std::optional<RtreeEntry> onlyForTestingGetRtreeEntry(const IdTable* idTable,
const size_t row,
const ColumnIndex col) {
const size_t row,
const ColumnIndex col) {
return getRtreeEntry(idTable, row, col);
}

Expand Down Expand Up @@ -184,7 +184,7 @@ class SpatialJoinAlgorithms {
std::optional<RtreeEntry> getRtreeEntry(const IdTable* idTable,
const size_t row,
const ColumnIndex col);

// this helper function converts a GeoPoint into a boost geometry Point
size_t convertGeoPointToPoint(GeoPoint point);

Expand Down
9 changes: 5 additions & 4 deletions test/engine/SpatialJoinAlgorithmsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,10 +1601,11 @@ TEST(SpatialJoin, trueAreaDistance) {
SpatialJoinAlgorithms algorithms{
qec, params, spatialJoin->onlyForTestingGetConfig(), std::nullopt};
algorithms.setUseMidpointForAreas_(useMidpointForAreas);
auto entryLeft = algorithms.onlyForTestingGetRtreeEntry(params.idTableLeft_, 0, params.leftJoinCol_);
auto entryRight = algorithms.onlyForTestingGetRtreeEntry(params.idTableRight_, 0, params.rightJoinCol_);
auto distID =
algorithms.computeDist(entryLeft.value(), entryRight.value());
auto entryLeft = algorithms.onlyForTestingGetRtreeEntry(
params.idTableLeft_, 0, params.leftJoinCol_);
auto entryRight = algorithms.onlyForTestingGetRtreeEntry(
params.idTableRight_, 0, params.rightJoinCol_);
auto distID = algorithms.computeDist(entryLeft.value(), entryRight.value());
return distID.getDouble();
};
auto qec = buildMixedAreaPointQEC(true);
Expand Down

0 comments on commit c0bf282

Please sign in to comment.