From 72dbe0e9ed215e7c0777ed72378c62cc40596498 Mon Sep 17 00:00:00 2001 From: Rafael Biehler Date: Wed, 25 Dec 2024 20:47:05 +0100 Subject: [PATCH] MQL docGeoWithin: Implicitly convert string into geometry --- .../org/polypheny/db/functions/MqlFunctions.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/polypheny/db/functions/MqlFunctions.java b/core/src/main/java/org/polypheny/db/functions/MqlFunctions.java index 067e93fe2c..8b6ca0834b 100644 --- a/core/src/main/java/org/polypheny/db/functions/MqlFunctions.java +++ b/core/src/main/java/org/polypheny/db/functions/MqlFunctions.java @@ -782,8 +782,18 @@ public static PolyBoolean docGeoIntersects( PolyValue input, PolyValue geometry @SuppressWarnings("UnusedDeclaration") public static PolyBoolean docGeoWithin( PolyValue input, PolyValue geometry, PolyValue distance ) { try { - // TODO: Do PolyString -> PolyGeometry conversion here - PolyGeometry geometryFilter = geometry.asGeometry(); + PolyGeometry geometryFilter; + if (geometry.isString()){ + geometryFilter = PolyGeometry.of(geometry.asString().getValue()); + if (geometryFilter == null){ + throw new GenericRuntimeException( "Cannot parse geometry string %s to type Geometry", distance); + } + } else if (geometry.isGeometry()){ + geometryFilter = geometry.asGeometry(); + } + else { + throw new GenericRuntimeException( "Cannot parse geometry %s to type Geometry", distance); + } PolyGeometry inputGeometry = convertInputToPolyGeometry( input, geometryFilter.getSRID() ); double distanceValue; if (distance.isBigDecimal()){