Skip to content

Commit

Permalink
drop client-side filtering for POINTs again, just take everything del…
Browse files Browse the repository at this point in the history
…ivered by the QLever query
  • Loading branch information
patrickbr committed Oct 23, 2024
1 parent 494f916 commit 4a6996b
Showing 1 changed file with 26 additions and 36 deletions.
62 changes: 26 additions & 36 deletions src/qlever-petrimaps/GeomCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ using util::geo::latLngToWebMerc;
// change on each index-breaking change to the code base
const static std::string INDEX_HASH_PREFIX = "_1_";

const static std::string WKT_ENDING =
"\"^^<HTTP://WWW.OPENGIS.NET/ONT/GEOSPARQL#WKTLITERAL>";

// Different SPAQRL queries to obtain the WKT geometries from an endpoint.
// It depends on the endpoint which query is used, see `getQuery`.
//
Expand Down Expand Up @@ -168,34 +165,29 @@ void GeomCache::parse(const char *c, size_t size) {
if (*c == '\t' || *c == '\n') {
size_t p = std::string::npos;

bool isGeom = _dangling.size() >= WKT_ENDING.size() &&
std::equal(WKT_ENDING.crbegin(), WKT_ENDING.crend(),
_dangling.crbegin());

// if the previous was not a multi geometry, and if the strings
// match exactly, re-use the geometry
if (isGeom && _prev == _dangling && _lastQidToId.qid == 0) {
if (_prev == _dangling && _lastQidToId.qid == 0) {
IdMapping idm{0, _lastQidToId.id};
_lastQidToId = idm;
_qidToIdF.write(reinterpret_cast<const char *>(&idm),
sizeof(IdMapping));
_qidToIdFSize++;
} else if (isGeom && (p = _dangling.rfind("\"POINT(", 0)) !=
std::string::npos) {
// _curUniqueGeom++;
// size_t i = 0;
// p = parseMultiPoint(_dangling, p + 4, std::string::npos, &i);

// // dummy element to keep sync
// if (i == 0) {
// IdMapping idm{0, std::numeric_limits<ID_TYPE>::max()};
// _lastQidToId = idm;
// _qidToIdF.write(reinterpret_cast<const char *>(&idm),
// sizeof(IdMapping));
// _qidToIdFSize++;
// }
} else if (isGeom && (p = _dangling.rfind("\"MULTIPOINT(", 0)) !=
std::string::npos) {
} else if ((p = _dangling.rfind("POINT(", 1)) != std::string::npos) {
_curUniqueGeom++;
size_t i = 0;
p = parseMultiPoint(_dangling, p + 4, std::string::npos, &i);

// dummy element to keep sync
if (i == 0) {
IdMapping idm{0, std::numeric_limits<ID_TYPE>::max()};
_lastQidToId = idm;
_qidToIdF.write(reinterpret_cast<const char *>(&idm),
sizeof(IdMapping));
_qidToIdFSize++;
}
} else if ((p = _dangling.rfind("MULTIPOINT(", 1)) !=
std::string::npos) {
_curUniqueGeom++;
size_t i = 0;
p = parseMultiPoint(_dangling, p + 10, std::string::npos, &i);
Expand All @@ -208,8 +200,8 @@ void GeomCache::parse(const char *c, size_t size) {
sizeof(IdMapping));
_qidToIdFSize++;
}
} else if (isGeom && (p = _dangling.rfind("\"LINESTRING(", 0)) !=
std::string::npos) {
} else if ((p = _dangling.rfind("LINESTRING(", 1)) !=
std::string::npos) {
_curUniqueGeom++;
size_t i = 0;
p = parseMultiLineString(_dangling, p + 9, std::string::npos, &i);
Expand All @@ -222,8 +214,8 @@ void GeomCache::parse(const char *c, size_t size) {
sizeof(IdMapping));
_qidToIdFSize++;
}
} else if (isGeom && (p = _dangling.rfind("\"MULTILINESTRING(", 0)) !=
std::string::npos) {
} else if ((p = _dangling.rfind("MULTILINESTRING(", 1)) !=
std::string::npos) {
_curUniqueGeom++;
size_t i = 0;
p = parseMultiLineString(_dangling, p + 15, std::string::npos, &i);
Expand All @@ -236,8 +228,8 @@ void GeomCache::parse(const char *c, size_t size) {
sizeof(IdMapping));
_qidToIdFSize++;
}
} else if (isGeom && (p = _dangling.rfind("\"POLYGON(", 0)) !=
std::string::npos) {
} else if ((p = _dangling.rfind("POLYGON(", 1)) !=
std::string::npos) {
_curUniqueGeom++;
size_t i = 0;
p = parsePolygon(_dangling, p + 7, std::string::npos, &i);
Expand All @@ -250,8 +242,8 @@ void GeomCache::parse(const char *c, size_t size) {
sizeof(IdMapping));
_qidToIdFSize++;
}
} else if (isGeom && (p = _dangling.rfind("\"MULTIPOLYGON(", 0)) !=
std::string::npos) {
} else if ((p = _dangling.rfind("MULTIPOLYGON(", 1)) !=
std::string::npos) {
_curUniqueGeom++;
size_t i = 0;
p = parseMultiPolygon(_dangling, p + 12, std::string::npos, &i);
Expand All @@ -264,8 +256,8 @@ void GeomCache::parse(const char *c, size_t size) {
sizeof(IdMapping));
_qidToIdFSize++;
}
} else if (isGeom && (p = _dangling.rfind("\"GEOMETRYCOLLECTION(",
0)) != std::string::npos) {
} else if ((p = _dangling.rfind("GEOMETRYCOLLECTION(", 1)) !=
std::string::npos) {
_curUniqueGeom++;
p += 18;

Expand Down Expand Up @@ -419,8 +411,6 @@ void GeomCache::parseIds(const char *c, size_t size) {

uint8_t type = (_curId.val & (uint64_t(15) << 60)) >> 60;

if (type == 8) continue;

if (_curIdRow < _qidToId.size() && _qidToId[_curIdRow].qid == 0) {
// if we have two consecutive and equivalent QLever ids, the geometry
// was returned multiple times in the fill query. This can happen if the
Expand Down

0 comments on commit 4a6996b

Please sign in to comment.