我使用的是Virtuoso Opensource 7.2.4并且有一个由一些数据组成的数据集,例如:
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix ap: <http://vocab.linkeddata.es/datosabiertos/def/urbanismo-infraestructuras/alumbrado-publico#> .
<http://linkeddata.es/resource/farolas/lapalma/0> a ap:PuntoDeAlumbrado ;
geo:long "-17.774237421604201614"^^xsd:double ;
geo:lat "28.60580329136699973"^^xsd:double .
如果我执行以下简单的SPARQL查询
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX ap: <http://vocab.linkeddata.es/datosabiertos/def/urbanismo-infraestructuras/alumbrado-publico#>
select ?farola ?lat ?long where {
?farola a ap:PuntoDeAlumbrado; geo:lat ?lat; geo:long ?long .
}
我得到以下结果。请注意,纬度和经度的值会四舍五入为不太精确的值。
+-------------------------------------------------+----------+----------+
| farola | lat | long |
+-------------------------------------------------+----------+----------+
| http://linkeddata.es/resource/farolas/lapalma/0 | 28.6058 | -17.7742 |
+-------------------------------------------------+----------+----------+
当我将结果格式设置为HTML,XML,JSON等时会发生这种情况。如果我在Turtle中请求结果,我可以以正确的精度得到结果。
@prefix res: <http://www.w3.org/2005/sparql-results#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:_ a res:ResultSet .
_:_ res:resultVariable "farola" , "lat" , "long" .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
_:_ res:solution [
res:binding [ res:variable "farola" ; res:value <http://linkeddata.es/resource/farolas/lapalma/0> ] ;
res:binding [ res:variable "lat" ; res:value 28.60580329136699973 ] ;
res:binding [ res:variable "long" ; res:value -17.774237421604201614 ] ] .
问题是当我使用Apache Jena [v3.1.0]进行查询时,我得到了舍入的结果。我想,它要求application / sparql-results + json作为第一个首选项。使Virtuoso在结果中返回非截断值的最佳方法是什么(配置Virtuoso或Jena)?
此行为在DBpedia SPARQL端点中相同,因为在HTML Result与Turtle Result中可以看到查询
prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
select ?lat ?long where {
<http://dbpedia.org/resource/Liberty_Tower_(Manhattan)> geo:long ?long; geo:lat ?lat .
}
答案 0 :(得分:2)
作为一种变通方法,您可以将值转换为查询中的字符串:
prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
select (str(?lat) as ?lat) (str(?long) as ?long) where {
<http://dbpedia.org/resource/Liberty_Tower_(Manhattan)> geo:long ?long; geo:lat ?lat .
}