From 89c0aa0ed455855aed9cff9f77fb5f2c3ede1bdc Mon Sep 17 00:00:00 2001 From: Hannah Bast Date: Fri, 12 Jan 2024 21:47:20 +0100 Subject: [PATCH] Suggest geo:hasGeometry/geo:asWKT automagically For a while now, the TTL files on https://osm2rdf.cs.uni-freiburg.de provide the geometry WKTs via `geo:hasGeometry/geo:asWKT` (because that is how it should be according to the GeoSPARQL standard), and not directly via `geo:hasGeometry` as it used to be. To ease query construction, the QLever UI now automagically suggests `geo:hasGeometry/geo:asWKT` whenenver `geo:hasGeometry` is among the suggested predicates. We had a similar mechanism already for predicates like `wdt:P31` (in which case also `wdt:P31/wdt:P279*` is suggested). When `geo:hasGeometry/geo:asWKT` is selected by the user, the variable name suggestion is `?geometry` and not `?as_wkt`. On the side, also show Map view button for OHM (when the result contains geomtries in the last column, as usual). --- .../static/js/codemirror/modes/sparql/sparql-hint.js | 10 ++++++++++ backend/static/js/qleverUI.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/static/js/codemirror/modes/sparql/sparql-hint.js b/backend/static/js/codemirror/modes/sparql/sparql-hint.js index 26833999..d8212ca1 100755 --- a/backend/static/js/codemirror/modes/sparql/sparql-hint.js +++ b/backend/static/js/codemirror/modes/sparql/sparql-hint.js @@ -516,6 +516,7 @@ function getDynamicSuggestions(context) { .replace(/^has([A-Z_-])/, "$1$") .replace(/^([a-z]+)edBy/, "$1$") .replace(/^(year)[A-Z_]\w*/, "$1$") + .replace(/^asWKT/, "geometry") .replace(/[^a-zA-Z0-9_]/g, "").toLowerCase(); response.push('?' + objectVarName + ' .'); @@ -940,6 +941,15 @@ function getQleverSuggestions( isMixedModeSuggestion: mainQueryHasTimedOut }); } + else if (displayText == "geo:hasGeometry ") { + dynamicSuggestions.push({ + displayText: "geo:hasGeometry/geo:asWKT ", + completion: "geo:hasGeometry/geo:asWKT ", + name: "geometry as WKT", + altname: altEntityName, + isMixedModeSuggestion: mainQueryHasTimedOut + }); + } else if (!ogc_contains_added && displayText.startsWith("osm2rdf:contains_")) { dynamicSuggestions.splice(dynamicSuggestions.length - 1, 0, { displayText: "ogc:contains ", diff --git a/backend/static/js/qleverUI.js b/backend/static/js/qleverUI.js index f74d18f3..7e7ed40f 100755 --- a/backend/static/js/qleverUI.js +++ b/backend/static/js/qleverUI.js @@ -566,7 +566,7 @@ async function processQuery(sendLimit=0, element=$("#exebtn")) { // the Django configuration of the respective backend). var res = "
"; if (showAllButton || (mapViewButtonVanilla && mapViewButtonPetri)) { - if (BASEURL.match("wikidata|osm-|dblp")) { + if (BASEURL.match("wikidata|osm|ohm|dblp")) { res += `
${showAllButton} ${mapViewButtonPetri}
`; } else { res += `
${showAllButton}
`;