diff --git a/src/qlever-petrimaps/GeomCache.cpp b/src/qlever-petrimaps/GeomCache.cpp index b4f9f5a..14dca10 100644 --- a/src/qlever-petrimaps/GeomCache.cpp +++ b/src/qlever-petrimaps/GeomCache.cpp @@ -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 = - "\"^^"; - // Different SPAQRL queries to obtain the WKT geometries from an endpoint. // It depends on the endpoint which query is used, see `getQuery`. // @@ -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(&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::max()}; - // _lastQidToId = idm; - // _qidToIdF.write(reinterpret_cast(&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::max()}; + _lastQidToId = idm; + _qidToIdF.write(reinterpret_cast(&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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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; @@ -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