Skip to content

Commit

Permalink
support for touches, overlaps, equals, crosses
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbr committed May 3, 2024
1 parent f7df646 commit 34f27d3
Show file tree
Hide file tree
Showing 10 changed files with 1,228 additions and 310 deletions.
7 changes: 7 additions & 0 deletions src/spatialjoin/GeometryCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ sj::Area sj::GeometryCache<sj::Area>::getFromDisk(size_t off,
// area
_geomsFReads[tid].read(reinterpret_cast<char*>(&ret.area), sizeof(double));

// outer area
_geomsFReads[tid].read(reinterpret_cast<char*>(&ret.outerArea), sizeof(double));

// simplified inner
// readPoly(_geomsFReads[tid], ret.inner);

Expand Down Expand Up @@ -324,6 +327,10 @@ size_t sj::GeometryCache<sj::Area>::add(const sj::Area& val) {
_geomsF.write(reinterpret_cast<const char*>(&val.area), sizeof(double));
_geomsOffset += sizeof(double);

// outer area
_geomsF.write(reinterpret_cast<const char*>(&val.outerArea), sizeof(double));
_geomsOffset += sizeof(double);

// innerGeom
// writePoly(val.inner);

Expand Down
3 changes: 3 additions & 0 deletions src/spatialjoin/GeometryCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct Area {
// area
double area;

// outer area
double outerArea;

// inner geom
// util::geo::I32XSortedPolygon inner;

Expand Down
54 changes: 47 additions & 7 deletions src/spatialjoin/SpatialJoinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void printHelp(int argc, char** argv) {
<< "output file (.bz2 or .gz supported), empty prints to stdout\n"
<< std::setw(41) << " -c [ --cache ] (default: '.')"
<< "cache directory for intermediate files\n"
<< std::setw(41) << " -C"
<< "don't parse input, re-use intermediate cache files\n"
// << std::setw(41) << " -C"
// << "don't parse input, re-use intermediate cache files\n"
<< std::setw(41) << " --prefix (default: '')"
<< "prefix added at the beginning of every relation\n"
<< std::setw(41) << " --intersects (default: ' intersects ')"
Expand All @@ -51,6 +51,14 @@ void printHelp(int argc, char** argv) {
<< "separator between containing geometry IDs\n"
<< std::setw(41) << " --covers (default: ' covers ')"
<< "separator between covering geometry IDs\n"
<< std::setw(41) << " --touches (default: ' touches ')"
<< "separator between touching geometry IDs\n"
<< std::setw(41) << " --equals (default: ' equals ')"
<< "separator between equivalent geometry IDs\n"
<< std::setw(41) << " --overlaps (default: ' overlaps ')"
<< "separator between overlapping geometry IDs\n"
<< std::setw(41) << " --crosses (default: ' crosses ')"
<< "separator between crossing geometry IDs\n"
<< std::setw(41) << " --suffix (default: '\\n')"
<< "suffix added at the beginning of every relation\n\n"
<< std::setfill(' ') << std::left << "Geometric computation:\n"
Expand Down Expand Up @@ -79,6 +87,10 @@ int main(int argc, char** argv) {
std::string contains = " contains ";
std::string intersects = " intersects ";
std::string covers = " covers ";
std::string touches = " touches ";
std::string equals = " equals ";
std::string overlaps = " overlaps ";
std::string crosses = " crosses ";
std::string suffix = "\n";

bool useBoxIds = true;
Expand All @@ -92,9 +104,9 @@ int main(int argc, char** argv) {
printHelp(argc, argv);
exit(0);
}
if (cur == "-C") {
useCache = true;
}
// if (cur == "-C") {
// useCache = true;
// }
if (cur == "--prefix") {
state = 1;
}
Expand All @@ -116,6 +128,18 @@ int main(int argc, char** argv) {
if (cur == "--covers") {
state = 7;
}
if (cur == "--touches") {
state = 8;
}
if (cur == "--equals") {
state = 9;
}
if (cur == "--overlaps") {
state = 10;
}
if (cur == "--crosses") {
state = 11;
}
if (cur == "--no-box-ids") {
useBoxIds = false;
}
Expand Down Expand Up @@ -151,6 +175,22 @@ int main(int argc, char** argv) {
covers = cur;
state = 0;
break;
case 8:
touches = cur;
state = 0;
break;
case 9:
equals = cur;
state = 0;
break;
case 10:
overlaps = cur;
state = 0;
break;
case 11:
crosses = cur;
state = 0;
break;
}
}

Expand All @@ -161,8 +201,8 @@ int main(int argc, char** argv) {

size_t NUM_THREADS = std::thread::hardware_concurrency();

Sweeper sweeper({NUM_THREADS, prefix, intersects, contains, covers, suffix,
useBoxIds, useArea},
Sweeper sweeper({NUM_THREADS, prefix, intersects, contains, covers, touches,
equals, overlaps, crosses, suffix, useBoxIds, useArea},
useCache, cache, output);

if (!useCache) {
Expand Down
2 changes: 1 addition & 1 deletion src/spatialjoin/Stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ inline std::string Stats::toString() {

t = double(timeFullGeoCheckLinePoint) / 1000000000.0;
ss << "time for " << fullGeoChecksLinePoint
<< " full geom checks LINE/Point: " << t << " s (" << ((t / sum) * 100.0)
<< " full geom checks LINE/POINT: " << t << " s (" << ((t / sum) * 100.0)
<< "%)\n";

t = double(timeWrite) / 1000000000.0;
Expand Down
Loading

0 comments on commit 34f27d3

Please sign in to comment.