Mapping GeoSpatial Data into Virtual Graph

Hi,

I am trying to map some GeoSpatial data that I have stored in a PostreSQL database. Below in a snippet of the mapping file:

prefix geo: http://www.opengis.net/ont/geosparql#
prefix geof: http://www.opengis.net/def/function/geosparql/

MAPPING
FROM SQL {
SELECT * FROM public.GeoPoints
}
TO {

?subject a geo:Geometry;
geo:asWKT "Point({?long ?lat})"^^geo:wktLiteral.
} WHERE {
BIND(template("http://example.com/v2#points/{poiid}") AS ?subject)
BIND(xsd:float(?lat) AS ?lat)
BIND(xsd:float(?long) AS ?long)
}

Basically, in this form, triples containing a property "geo:asWKT" with a static value ""Point({?long ?lat})"^^geo:wktLiteral" are generated, so for ?long and ?lat the concrete values are not taken. I need this for doing a polygon search.

An additional question would be:
"Does the polygon search work in other way then specifying points/locations as geo:Geometry and giving the property geo:asWKT "Point(?long ?lat)"^^geo:wktLiteral", for example, by simply passing ?long and ?lat values?

Thank you in advance.

Best,

WKT is somewhat limited in what it allows; for a Polygon, you're basically stuck needing (LONG, LAT) pairs in your WKT string.

If you wanted to use Geometries, and your polygon happens to be rectangular, you can use the <Geometry> geof:within (<WKT Literal> <WKT Literal>) form of geof:within to specify 2 points as the lower-left and upper-right corners.

I see. Thank you for your explanation.

What about the mapping as above?

Your mapping would produce WKT points, however you would need to materialize them into Stardog itself in order to insert them into the spatial index for geospatial querying.

Actually I don't think you would need the xsd:float bindings since ultimately you're only mapping the lat/long into a string anyway. That said, if you wanted to bind those values into geo:lat and geo:long values on top of generating the wktLiteral, that would work, however I would suggest using different variable names for the bound variables, e.g., BIND(xsd:float(?lat) as ?floatLat)

Maybe I was not clear enough. The mapping as above is producing triples:

<http://example.com/v2#points/point1> geo:asWKT "Point(?long ?lat)"^^geo:wktLiteral .
<http://example.com/v2#points/point2> geo:asWKT "Point(?long ?lat)"^^geo:wktLiteral .
<http://example.com/v2#points/point3> geo:asWKT "Point(?long ?lat)"^^geo:wktLiteral .

instead of (for example):

<http://example.com/v2#points/point1> geo:asWKT "Point(48.7258 8.9315)"^^geo:wktLiteral .
<http://example.com/v2#points/point2> geo:asWKT "Point(48.7446 8.9701)"^^geo:wktLiteral .
<http://example.com/v2#points/point3> geo:asWKT "Point(50.1431 8.7130)"^^geo:wktLiteral .

So the actual values of ?long and ?lat are not taken.

Thank you for your explanation about using the BINDING function.

P.S. Yes, I know that in order to use the Geospatial feature, I have to materialize triples to Stardog.

Any idea for the question about the mappings as above?

I don't believe you need the {} for variables when you're in the TO section; you could try geo:asWKT "Point(?long ?lat)"^^geo:wktLiteral.

If that doesn't work, you could try adding another binding: BIND(CONCAT("Point(", ?long, " ", ?lat, ")")^^geo:wktLiteral as ?wktLit) and then change your TO to geo:asWKT ?wktLit

I already tried with all combinations as below:

MAPPING
FROM SQL {
SELECT * FROM public.poisviewTest
}
TO {

?subject a geo:Geometry;
# geo:asWKT "Point('{?longP ?latP}'')"^^geo:wktLiteral ;
# geo:asWKT "Point('{longP latP}'')"^^geo:wktLiteral ;
# geo:asWKT "Point(''?longP ?latP'')"^^geo:wktLiteral ;
# geo:asWKT "Point(''longP latP'')"^^geo:wktLiteral ;
# geo:asWKT "Point('longP latP')"^^geo:wktLiteral ;
# geo:asWKT "Point('?longP ?latP')"^^geo:wktLiteral ;
# geo:asWKT "Point('?longP ?latP')"^^geo:wktLiteral ;
geo:asWKT "Point(?longP ?latP)"^^geo:wktLiteral ;
} WHERE {
BIND(template("[http://example.com/v2#points/{poiid} AS ?subject))
BIND(xsd:float(?lat) AS ?latP)
BIND(xsd:float(?long) AS ?longP)

}

All of the above forms do not produce the desired results, i.e. Points with actual coordinate values.

Regarding to the usage of BIND function, I tried in different forms as below:

1. When I use the following BIND form:

MAPPING
FROM SQL {
SELECT * FROM public.poisviewTest
}
TO {

?subject a geo:Geometry;
geo:asWKT ?location.

} WHERE {
BIND(template("[http://example.com/v2#points/{poiid} AS ?subject))
BIND(xsd:float(?lat) AS ?latP)
BIND(xsd:float(?long) AS ?longP)
BIND(CONCAT("Point(", ?longP, " ", ?latP, ")")^^geo:wktLiteral as ?location)

}

I get this exception:

ERROR 2019-07-16 15:04:18,929 [stardog-user-11] com.complexible.stardog.virtual.DefaultVirtualGraphRegistry:createVirtualGraph(314): Cannot initialize virtual graph fqNearByFeatureTest
com.complexible.stardog.plan.parser.QueryParseException: Encountered " "^^" "^^ "" at line 38, column 49.
Was expecting one of:
"=" ...
"!=" ...
">" ...
"<" ...
"<=" ...
">=" ...
"||" ...
"&&" ...
"+" ...
"-" ...
"" ...
"/" ...
"as" ...
"in" ...
"not in" ...
<INTEGER_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_POSITIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_POSITIVE> ...
<DOUBLE_NEGATIVE> ...
at com.complexible.stardog.plan.parser.QueryParserImpl.parseDatasourceMappings(QueryParserImpl.java:516) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseSms2Mappings(RdbmsMappings.java:162) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:122) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:107) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:92) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsVirtualGraphFactory.create(RdbmsVirtualGraphFactory.java:68) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsVirtualGraphFactory.create(RdbmsVirtualGraphFactory.java:44) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph(DefaultVirtualGraphRegistry.java:311) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph(DefaultVirtualGraphRegistry.java:297) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.add(DefaultVirtualGraphRegistry.java:171) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.SecuredVirtualGraphRegistry.add(SecuredVirtualGraphRegistry.java:133) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.addVG(VirtualGraphHttpService.java:344) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.update(VirtualGraphHttpService.java:153) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-6.2.2.jar:?]
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [shiro-core-1.2.3.jar:1.2.3]
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [shiro-core-1.2.3.jar:1.2.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_212]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_212]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: com.complexible.common.rdf.query.parser.sparql.ast.ParseException: Encountered " "^^" "^^ "" at line 38, column 49.
Was expecting one of:
"=" ...
"!=" ...
">" ...
"<" ...
"<=" ...
">=" ...
"||" ...
"&&" ...
"+" ...
"-" ...
"
" ...
"/" ...
"as" ...
"in" ...
"not in" ...
<INTEGER_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_POSITIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_POSITIVE> ...
<DOUBLE_NEGATIVE> ...
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.generateParseException(SyntaxTreeBuilder.java:10389) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.jj_consume_token(SyntaxTreeBuilder.java:10242) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.Bind(SyntaxTreeBuilder.java:7784) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.ScopeTerminator(SyntaxTreeBuilder.java:2889) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.Scopes(SyntaxTreeBuilder.java:2478) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.Scopes(SyntaxTreeBuilder.java:2534) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.Scopes(SyntaxTreeBuilder.java:2534) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.Scopes(SyntaxTreeBuilder.java:2534) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.GroupGraphPattern(SyntaxTreeBuilder.java:2430) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.WhereClause(SyntaxTreeBuilder.java:1386) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.Mapping(SyntaxTreeBuilder.java:9362) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SyntaxTreeBuilder.Mappings(SyntaxTreeBuilder.java:9247) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl.parseDatasourceMappings(QueryParserImpl.java:497) ~[stardog-6.2.2.jar:?]
... 18 more
ERROR 2019-07-16 15:04:18,930 [stardog-user-11] com.complexible.stardog.protocols.http.server.StardogHttpServiceLoader:accept(232): An exception was handled by the server: Encountered " "^^" "^^ "" at line 38, column 49.
Was expecting one of:
"=" ...
"!=" ...
">" ...
"<" ...
"<=" ...
">=" ...
"||" ...
"&&" ...
"+" ...
"-" ...
"*" ...
"/" ...
"as" ...
"in" ...
"not in" ...
<INTEGER_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_POSITIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_POSITIVE> ...
<DOUBLE_NEGATIVE> ...

2. When I use the following BIND form:

MAPPING
FROM SQL {
SELECT * FROM public.poisviewTest
}
TO {

?subject a geo:Geometry;
geo:asWKT ?location.

} WHERE {
BIND(template("[http://example.com/v2#points/{poiid} AS ?subject))
BIND(xsd:float(?lat) AS ?latP)
BIND(xsd:float(?long) AS ?longP)
BIND(geo:wktLiteral(concat('Point(', STR(?longP), ' ', STR(?latP), ')' )) as ?location)

}

I get this exception:

ERROR 2019-07-16 15:02:30,412 [stardog-user-25] com.complexible.stardog.virtual.DefaultVirtualGraphRegistry:createVirtualGraph(314): Cannot initialize virtual graph fqNearByFeatureTest
com.complexible.stardog.plan.PlanException: Unrecognized function: http://www.opengis.net/ont/geosparql#wktLiteral
at com.complexible.stardog.plan.parser.QueryParserImpl.parseDatasourceMappings(QueryParserImpl.java:528) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseSms2Mappings(RdbmsMappings.java:162) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:122) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:107) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:92) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsVirtualGraphFactory.create(RdbmsVirtualGraphFactory.java:68) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsVirtualGraphFactory.create(RdbmsVirtualGraphFactory.java:44) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph(DefaultVirtualGraphRegistry.java:311) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph(DefaultVirtualGraphRegistry.java:297) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.add(DefaultVirtualGraphRegistry.java:171) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.SecuredVirtualGraphRegistry.add(SecuredVirtualGraphRegistry.java:133) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.addVG(VirtualGraphHttpService.java:344) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.update(VirtualGraphHttpService.java:153) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-6.2.2.jar:?]
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [shiro-core-1.2.3.jar:1.2.3]
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [shiro-core-1.2.3.jar:1.2.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_212]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_212]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: java.lang.UnsupportedOperationException: Unrecognized function: http://www.opengis.net/ont/geosparql#wktLiteral
at com.complexible.stardog.plan.filter.functions.FunctionRegistry.get(FunctionRegistry.java:162) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$ExpressionBuilder.visit(QueryParserImpl.java:3923) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$ExpressionBuilder.visit(QueryParserImpl.java:3773) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTFunctionCall.jjtAccept(ASTFunctionCall.java:20) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$ExpressionBuilder.toExpression(QueryParserImpl.java:4081) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$ExpressionBuilder.access$600(QueryParserImpl.java:3773) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.buildForBinder(QueryParserImpl.java:1469) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:1441) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:702) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTBind.jjtAccept(ASTBind.java:20) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:792) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:702) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTScope.jjtAccept(ASTScope.java:22) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:162) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:824) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:702) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTGraphPatternGroup.jjtAccept(ASTGraphPatternGroup.java:19) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:2866) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:702) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTWhereClause.jjtAccept(ASTWhereClause.java:19) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.DatasourceMappingParser.parse(DatasourceMappingParser.java:139) ~[stardog-6.2.2.jar:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_212]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[?:1.8.0_212]
at com.complexible.stardog.plan.parser.QueryParserImpl.parseDatasourceMappings(QueryParserImpl.java:513) ~[stardog-6.2.2.jar:?]
... 18 more
ERROR 2019-07-16 15:02:30,414 [stardog-user-25] com.stardog.http.server.undertow.ErrorHandling:writeError(138): Unexpected error on the server
com.complexible.stardog.plan.PlanException: Unrecognized function: http://www.opengis.net/ont/geosparql#wktLiteral
at com.complexible.stardog.plan.parser.QueryParserImpl.parseDatasourceMappings(QueryParserImpl.java:528) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseSms2Mappings(RdbmsMappings.java:162) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:122) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:107) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseOrGenerateMappings(RdbmsMappings.java:92) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsVirtualGraphFactory.create(RdbmsVirtualGraphFactory.java:68) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsVirtualGraphFactory.create(RdbmsVirtualGraphFactory.java:44) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph(DefaultVirtualGraphRegistry.java:311) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph(DefaultVirtualGraphRegistry.java:297) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.add(DefaultVirtualGraphRegistry.java:171) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.SecuredVirtualGraphRegistry.add(SecuredVirtualGraphRegistry.java:133) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.addVG(VirtualGraphHttpService.java:344) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.update(VirtualGraphHttpService.java:153) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-6.2.2.jar:?]
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [shiro-core-1.2.3.jar:1.2.3]
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [shiro-core-1.2.3.jar:1.2.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_212]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_212]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: java.lang.UnsupportedOperationException: Unrecognized function: http://www.opengis.net/ont/geosparql#wktLiteral
at com.complexible.stardog.plan.filter.functions.FunctionRegistry.get(FunctionRegistry.java:162) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$ExpressionBuilder.visit(QueryParserImpl.java:3923) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$ExpressionBuilder.visit(QueryParserImpl.java:3773) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTFunctionCall.jjtAccept(ASTFunctionCall.java:20) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$ExpressionBuilder.toExpression(QueryParserImpl.java:4081) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$ExpressionBuilder.access$600(QueryParserImpl.java:3773) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.buildForBinder(QueryParserImpl.java:1469) ~[stardog-6.2.2.jar:?]
at .....com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:702) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTScope.jjtAccept(ASTScope.java:22) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:162) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:824) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:702) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTGraphPatternGroup.jjtAccept(ASTGraphPatternGroup.java:19) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:2866) ~[stardog-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.QueryParserImpl$GeneratePlan.visit(QueryParserImpl.java:702) ~[stardog-6.2.2.jar:?]
at com.complexible.common.rdf.query.parser.sparql.ast.ASTWhereClause.jjtAccept(ASTWhereClause.java:19) ~[stardog-utils-rdf-6.2.2.jar:?]
at com.complexible.stardog.plan.parser.DatasourceMappingParser.parse(DatasourceMappingParser.java:139) ~[stardog-6.2.2.jar:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_212]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[?:1.8.0_212]
at com.complexible.stardog.plan.parser.QueryParserImpl.parseDatasourceMappings(QueryParserImpl.java:513) ~[stardog-6.2.2.jar:?]
... 18 more

3. When I use the following BIND form:

MAPPING
FROM SQL {
SELECT * FROM public.poisviewTest
}
TO {

?subject a geo:Geometry;
geo:asWKT ?location.

} WHERE {
BIND(template("[http://example.com/v2#points/{poiid} AS ?subject))
BIND(xsd:float(?lat) AS ?latP)
BIND(xsd:float(?long) AS ?longP)
BIND(strdt(concat('Point(', STR(?longP) , ' ', STR(?latP), ')' ), geo:wktLiteral) as ?location)

}

I get this exception:

ERROR 2019-07-16 14:42:37,848 [stardog-user-28] com.complexible.stardog.virtual.DefaultVirtualGraphRegistry:createVirtualGraph(314): Cannot initialize virtual graph fqNearByFeatureTest
com.complexible.stardog.StardogException: Binding functions other than template() and cast are unsupported. Found StrDt for variable location
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.lambda$buildTriplesMapsFromSms2Mapping$11(RdbmsMappings.java:233) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.common.base.Functional.lambda$mapEntryBiFunction$0(Functional.java:27) ~[stardog-utils-common-6.2.2.jar:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1699) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_212]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[?:1.8.0_212]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.buildTriplesMapsFromSms2Mapping(RdbmsMappings.java:236) ~[stardog-virtual-core-6.2.2.jar:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_212]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[?:1.8.0_212]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseSms2Mappings(RdbmsMappings.java:175) ~[stardog-virtual-core-6.2.2.jar:?]
at .....
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph(DefaultVirtualGraphRegistry.java:311) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.createVirtualGraph(DefaultVirtualGraphRegistry.java:297) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.DefaultVirtualGraphRegistry.add(DefaultVirtualGraphRegistry.java:171) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.SecuredVirtualGraphRegistry.add(SecuredVirtualGraphRegistry.java:133) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.addVG(VirtualGraphHttpService.java:344) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.update(VirtualGraphHttpService.java:153) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-6.2.2.jar:?]
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [shiro-core-1.2.3.jar:1.2.3]
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [shiro-core-1.2.3.jar:1.2.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_212]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_212]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: com.complexible.stardog.StardogException: Binding functions other than template() and cast are unsupported. Found StrDt for variable location
at com.complexible.stardog.virtual.vega.mapping.MappingTermMapBuilder.buildTermMap(MappingTermMapBuilder.java:113) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.lambda$null$10(RdbmsMappings.java:228) ~[stardog-virtual-core-6.2.2.jar:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1556) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_212]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:1.8.0_212]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:1.8.0_212]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.lambda$buildTriplesMapsFromSms2Mapping$11(RdbmsMappings.java:229) ~[stardog-virtual-core-6.2.2.jar:?]
... 34 more
ERROR 2019-07-16 14:42:37,850 [stardog-user-28] com.stardog.http.server.undertow.ErrorHandling:writeError(138): Unexpected error on the server
com.complexible.stardog.StardogException: Binding functions other than template() and cast are unsupported. Found StrDt for variable location
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.lambda$buildTriplesMapsFromSms2Mapping$11(RdbmsMappings.java:233) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.common.base.Functional.lambda$mapEntryBiFunction$0(Functional.java:27) ~[stardog-utils-common-6.2.2.jar:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1699) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_212]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[?:1.8.0_212]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.buildTriplesMapsFromSms2Mapping(RdbmsMappings.java:236) ~[stardog-virtual-core-6.2.2.jar:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_212]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[?:1.8.0_212]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.parseSms2Mappings(RdbmsMappings.java:175) ~[stardog-virtual-core-6.2.2.jar:?]
at ......
at com.complexible.stardog.protocols.http.server.virtual.admin.VirtualGraphHttpService.update(VirtualGraphHttpService.java:153) ~[stardog-virtual-protocols-http-server-6.2.2.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-6.2.2.jar:?]
......[?:1.8.0_212]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: com.complexible.stardog.StardogException: Binding functions other than template() and cast are unsupported. Found StrDt for variable location
at com.complexible.stardog.virtual.vega.mapping.MappingTermMapBuilder.buildTermMap(MappingTermMapBuilder.java:113) ~[stardog-virtual-core-6.2.2.jar:?]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.lambda$null$10(RdbmsMappings.java:228) ~[stardog-virtual-core-6.2.2.jar:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_212]
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1556) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_212]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:1.8.0_212]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_212]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:1.8.0_212]
at com.complexible.stardog.virtual.vega.rdbms.RdbmsMappings.lambda$buildTriplesMapsFromSms2Mapping$11(RdbmsMappings.java:229) ~[stardog-virtual-core-6.2.2.jar:?]
... 34 more

I should have seen and answered this earlier, but yes, we also support the WGS84 standard for representing lat and long:

MAPPING
FROM SQL {
SELECT * FROM public.GeoPoints
}
TO {

?subject a geo:Geometry;
  <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?flat ;
  <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?flong .
} WHERE {
BIND(template("http://example.com/v2#points/{poiid}") AS ?subject)
BIND(xsd:float(?lat) AS ?flat)
BIND(xsd:float(?long) AS ?flong)
}

This should allow you to use the Geometry entities in geo functions as well.

Great, good to know. Thanks.

What about mapping to geo:asWKT "Point(long lat)"^^geo:wktLiteral, as I asked above?

You can try doing the concatenation on the Postgres side (I'm not 100% on the Postgres syntax, but it would be something like this):

MAPPING
FROM SQL {
SELECT poiid, lat, long,
               ("Point(" || long || ", " || lat || ")") as point
FROM public.poisviewTest
}
TO {

?subject a geo:Geometry;
geo:asWKT "?point"^^geo:wktLiteral.

} 

It works in this way. Thank you for your suggestion.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.