首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SPARQL三角函数

SPARQL三角函数
EN

Stack Overflow用户
提问于 2015-10-29 12:50:41
回答 1查看 108关注 0票数 1

我正在使用芝麻服务器来存储和查询三层集。在我的存储库中,我有一组三元组,它们代表地球上由经度和纬度定义的位置。

示例:

代码语言:javascript
复制
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不支持三角函数。

还有其他方法来创建这个功能吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-29 20:12:28

您可以自己添加自定义函数到Sesame的SPARQL引擎,编程。不久前,我写了一篇关于如何做到这一点的教程文章。它的主旨是:

  1. 为实现org.openrdf.query.algebra.evaluation.function.Function接口的函数创建一个类。

例如:

代码语言:javascript
复制
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 
     }
}
  1. 为您的自定义函数创建一个带有(SPI)注册表配置的jar。

这涉及到jar文件中的META-INF/services目录中有一个名为META-INF/services的文件。这个文件的内容应该是每个函数实现的完全限定的名称,每一行一个。

  1. 将jar放到Server的运行时类路径中,然后重新启动。
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33414778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档