Smalyshev has uploaded a new change for review. https://gerrit.wikimedia.org/r/284930
Change subject: Add tests & enable third parameter ...................................................................... Add tests & enable third parameter Change-Id: I98d929400f88bd63dac164302adbfa1ab1e82914 --- M blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/WikibaseContextListener.java M blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/constraints/WikibaseDistanceBOp.java M tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseGeoExtensionIntegrationTest.java 3 files changed, 22 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/rdf refs/changes/30/284930/1 diff --git a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/WikibaseContextListener.java b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/WikibaseContextListener.java index 1c93488..afd6f7c 100644 --- a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/WikibaseContextListener.java +++ b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/WikibaseContextListener.java @@ -155,7 +155,7 @@ public IValueExpression<? extends IV> create(final BOpContextBase context, final GlobalAnnotations globals, Map<String, Object> scalarValues, final ValueExpressionNode... args) { - if (args.length != 2) { + if (args.length < 2) { throw new IllegalArgumentException("wrong # of args"); } diff --git a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/constraints/WikibaseDistanceBOp.java b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/constraints/WikibaseDistanceBOp.java index f064b3d..aa2ec75 100644 --- a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/constraints/WikibaseDistanceBOp.java +++ b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/constraints/WikibaseDistanceBOp.java @@ -17,6 +17,7 @@ /** * Implementation of geof:distance function. + * FIXME: units not supported yet. */ @SuppressWarnings("rawtypes") public class WikibaseDistanceBOp extends IVValueExpression<IV> implements INeedsMaterialization { diff --git a/tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseGeoExtensionIntegrationTest.java b/tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseGeoExtensionIntegrationTest.java index 0600f9c..7dd7602 100644 --- a/tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseGeoExtensionIntegrationTest.java +++ b/tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseGeoExtensionIntegrationTest.java @@ -3,7 +3,9 @@ import static org.wikidata.query.rdf.test.Matchers.binds; import org.junit.Test; +import org.openrdf.model.impl.LiteralImpl; import org.openrdf.model.impl.URIImpl; +import org.openrdf.model.vocabulary.XMLSchema; import org.openrdf.query.BindingSet; import org.openrdf.query.QueryEvaluationException; import org.openrdf.query.TupleQueryResult; @@ -105,4 +107,22 @@ resultsAre(results, "place", "http://Barcelona", "http://Johannesburg", "http://SanFrancisco"); } + @Test + public void distance() throws QueryEvaluationException { + TupleQueryResult results = rdfRepository().query( + "SELECT * WHERE {BIND ( geof:distance(\"Point(0 0)\"^^geo:wktLiteral, \"Point(-1 -1)\"^^geo:wktLiteral) AS ?distance)}"); + BindingSet result = results.next(); + // distance between two points + assertThat(result, binds("distance", new LiteralImpl("157.2418158675294", XMLSchema.DOUBLE))); + } + + @Test + public void distanceWithUnits() throws QueryEvaluationException { + // FIXME: for now, we just accept anything as units and ignore it. We need to do better. + TupleQueryResult results = rdfRepository().query( + "SELECT * WHERE {BIND ( geof:distance(\"Point(0 0)\"^^geo:wktLiteral, \"Point(-1 -1)\"^^geo:wktLiteral, wd:Q2) AS ?distance)}"); + BindingSet result = results.next(); + // distance between two points + assertThat(result, binds("distance", new LiteralImpl("157.2418158675294", XMLSchema.DOUBLE))); + } } -- To view, visit https://gerrit.wikimedia.org/r/284930 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I98d929400f88bd63dac164302adbfa1ab1e82914 Gerrit-PatchSet: 1 Gerrit-Project: wikidata/query/rdf Gerrit-Branch: master Gerrit-Owner: Smalyshev <smalys...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits