我正在使用芝麻服务器来存储和查询三层集。在我的存储库中,我有一组三元组,它们代表地球上由经度和纬度定义的位置。
示例:
PREFIX ont:<http://example.org/myontology.owl#>
<http://foo.com/location-a> a ont:Location.
<http://foo.com/location-a> ont:hasLatitude "25.91239"^^xsd:double.
<http://foo.com/location-a> ont:hasLongitude "30.3911"^^xsd:double.
<http://foo.com/location-b> a ont:Location.
<http://foo.com/location-b> ont:hasLatitude "15.7778"^^xsd:double.
<http://foo.com/location-b> ont:hasLongitude "13.6755"^^xsd:double.
...我想要写一个查询,返回由它的中心点(Latidude_Center,Longitude_Center)和半径(以公里或度)定义的圆表面上的所有位置。
为了达到这个目的,我必须使用一些包含三角函数的数学公式。据我所知,SPARQL不支持三角函数。
还有其他方法来创建这个功能吗?
发布于 2015-10-29 20:12:28
您可以自己添加自定义函数到Sesame的SPARQL引擎,编程。不久前,我写了一篇关于如何做到这一点的教程文章。它的主旨是:
org.openrdf.query.algebra.evaluation.function.Function接口的函数创建一个类。例如:
public class SinusFunction implements Function {
/** return the name of the function for use in SPARQL */
public String getURI() {
return "http://example.org/function/sin";
}
public Value evaluate(ValueFactory valueFactory, Value... args)
throws ValueExprEvaluationException
{
// TODO implement computing the function return value
// based on the input args
}
}这涉及到jar文件中的META-INF/services目录中有一个名为META-INF/services的文件。这个文件的内容应该是每个函数实现的完全限定的名称,每一行一个。
https://stackoverflow.com/questions/33414778
复制相似问题