From 189fbef7946a703cceabf42f48a7b8cfb0be6a61 Mon Sep 17 00:00:00 2001 From: ullingerc Date: Mon, 18 Nov 2024 11:41:10 +0100 Subject: [PATCH] allow right parameter outside if only distance is limited, not results --- src/parser/SpatialQuery.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/parser/SpatialQuery.cpp b/src/parser/SpatialQuery.cpp index 7fcc8c1bf8..c2c859e81c 100644 --- a/src/parser/SpatialQuery.cpp +++ b/src/parser/SpatialQuery.cpp @@ -67,13 +67,19 @@ void SpatialQuery::addParameter(const SparqlTriple& triple) { SpatialJoinConfiguration SpatialQuery::toSpatialJoinConfiguration() const { if (!left_.has_value()) { throw SpatialSearchException("Missing parameter 'left' in spatial search."); - } else if (!right_.has_value()) { - throw SpatialSearchException( - "Missing parameter 'right' in spatial search."); } else if (!maxDist_.has_value() && !maxResults_.has_value()) { throw SpatialSearchException( "Neither 'nearestNeighbors' nor 'maxDistance' were provided. At least " "one of both is required."); + } else if (!right_.has_value() && maxResults_.has_value()) { + // Only if the number of results is limited, it is mandatory that the right + // variable must be selected inside the service. If only the distance is + // limited, it may be declared inside or outside of the service. + throw SpatialSearchException( + "Missing parameter 'right' in spatial search. A spatial search with " + "a maximum number of results must have its right variable declared " + "inside the service using a graph pattern: SERVICE spatialSearch: { " + "... { ... ?right } }."); } // Default algorithm