Skip to content

Commit

Permalink
remove some unused code found by clang, add some explicit static_cast…
Browse files Browse the repository at this point in the history
…s in initializer lists, update util
  • Loading branch information
patrickbr committed Oct 11, 2024
1 parent 43d5d78 commit 59f7f38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/spatialjoin/BoxIds.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ inline void getBoxIds(const util::geo::I32XSortedLine& line,
int yFrom, int yTo, int xWidth, int yHeight,
BoxIdList* ret, std::map<int32_t, size_t>* cutouts,
size_t startA, size_t startB) {

for (int32_t y = yFrom; y < yTo; y += yHeight) {
size_t firstInA = startA;
size_t firstInB = startB;
Expand All @@ -61,9 +60,10 @@ inline void getBoxIds(const util::geo::I32XSortedLine& line,
int localYHeight = std::min(yTo - y, yHeight);

util::geo::I32Box box(
{(x * GRID_W - WORLD_W / 2.0), (y * GRID_H - WORLD_H / 2.0)},
{(x + localXWidth) * GRID_W - WORLD_W / 2.0,
(y + localYHeight) * GRID_H - WORLD_H / 2.0});
{static_cast<int>((x * GRID_W - WORLD_W / 2.0)),
static_cast<int>((y * GRID_H - WORLD_H / 2.0))},
{static_cast<int>((x + localXWidth) * GRID_W - WORLD_W / 2.0),
static_cast<int>((y + localYHeight) * GRID_H - WORLD_H / 2.0)});

if (!util::geo::intersects(box, envelope)) continue;

Expand Down Expand Up @@ -113,9 +113,10 @@ inline void getBoxIds(const util::geo::I32XSortedPolygon& poly,
int localYHeight = std::min(yTo - y, yHeight);

util::geo::I32Box box(
{(x * GRID_W - WORLD_W / 2.0), (y * GRID_H - WORLD_H / 2.0)},
{(x + localXWidth) * GRID_W - WORLD_W / 2.0,
(y + localYHeight) * GRID_H - WORLD_H / 2.0});
{static_cast<int>((x * GRID_W - WORLD_W / 2.0)),
static_cast<int>((y * GRID_H - WORLD_H / 2.0))},
{static_cast<int>((x + localXWidth) * GRID_W - WORLD_W / 2.0),
static_cast<int>((y + localYHeight) * GRID_H - WORLD_H / 2.0)});

if (!util::geo::intersects(box, envelope)) continue;

Expand Down Expand Up @@ -174,7 +175,6 @@ inline BoxIdList getBoxIds(const util::geo::I32XSortedLine& line,
int32_t b = getBoxId(envelope.getUpperRight());
if (a == b) return {{a, 0}}; // shortcut


int32_t startX = std::floor(
(1.0 * envelope.getLowerLeft().getX() + WORLD_W / 2.0) / GRID_W);
int32_t startY = std::floor(
Expand Down
9 changes: 0 additions & 9 deletions src/spatialjoin/GeometryCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@ class GeometryCache {
}

~GeometryCache() {
size_t access = 0;
size_t diskAccess = 0;
for (size_t i = 0; i < _accessCount.size(); i++) {
access += _accessCount[i];
diskAccess += _diskAccessCount[i];
}
// std::cerr << "Geometry cache <" << getFName() << ">: " << access
// << " accesses, " << diskAccess << " disk lookups" << std::endl;

if (_geomsF.is_open()) _geomsF.close();
for (size_t i = 0; i < _geomsFReads.size(); i++) {
if (_geomsFReads[i].is_open()) _geomsFReads[i].close();
Expand Down
6 changes: 4 additions & 2 deletions src/spatialjoin/WKTParse.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ inline util::geo::I32Line parseLineString(const char* c, const char** endr) {
double y = util::atof(next, 10);
auto projPoint = latLngToWebMerc(util::geo::DPoint(x, y));

line.push_back({projPoint.getX() * PREC, projPoint.getY() * PREC});
line.push_back({static_cast<int>(projPoint.getX() * PREC),
static_cast<int>(projPoint.getY() * PREC)});

auto n = strchr(next, ',');
if (!n || n > end) break;
Expand All @@ -70,7 +71,8 @@ inline util::geo::I32Point parsePoint(const char* c) {
double y = util::atof(next, 10);
auto point = latLngToWebMerc(util::geo::DPoint(x, y));

return {point.getX() * PREC, point.getY() * PREC};
return {static_cast<int>(point.getX() * PREC),
static_cast<int>(point.getY() * PREC)};
}

// _____________________________________________________________________________
Expand Down
2 changes: 1 addition & 1 deletion src/util
Submodule util updated 2 files
+2 −0 geo/Collection.h
+13 −13 geo/Geo.h

0 comments on commit 59f7f38

Please sign in to comment.