我想使用附近的地理空间函数,这里通过JENA FUSEKI描述为支持 - https://jena.apache.org/documentation/query/spatial-query.html
我需要为查询构建地理空间索引才能工作。说明如下(取自上面的链接):
构建TDB数据集:
java -cp $ FUSEKI_HOME / fuseki-server.jar tdb.tdbloader --tdb = assembler_file data_file
使用Fuseki附带的TDB副本。或者,使用TDB实用程序之一tdbloader或tdbloader2:
$ JENA_HOME / bin / tdbloader --loc = directory data_file
然后使用jena.spatialindexer:
构建空间索引java -cp jena-spatial.jar jena.spatialindexer --desc = assembler_file
假设我知道哪个文件是我的FUSEKI文件夹中的汇编程序文件(我没有),我在最新的jena下载中搜索jena-spatial.jar。发现它不在那里,我搜索它并在这里找到一个罐子的副本 - https://jar-download.com/?detail_search=g%3A%22org.apache.jena%22+AND+a%3A%22jena-spatial%22&search_type=av&a=jena-spatial&p=1
我尝试运行它,但是我收到错误“无法找到或加载主类jena.spatialindexer”。我为jena.spatialindexer做搜索,我找到了一个匹配(不能在链接帖子限制发布在这里)。
此时我想知道是否有可能让这更复杂一点?你知道,我显然一直在世界各地搜索谷歌试图找出这些神秘的线索。
简而言之,如果之前有人这样做了,请你指出我哪里出错了?
最诚挚的问候,
克里斯。
答案 0 :(得分:0)
以防它可能会有所帮助,请在我的配置下面找到
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix : <#> .
@prefix spatial: <http://jena.apache.org/spatial#> .
# TDB
[] ja:loadClass "org.apache.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
# Spatial
[] ja:loadClass "org.apache.jena.query.spatial.SpatialQuery" .
spatial:SpatialDataset rdfs:subClassOf ja:RDFDataset .
#spatial:SpatialIndexSolr rdfs:subClassOf spatial:SpatialIndex .
spatial:SpatialIndexLucene rdfs:subClassOf spatial:SpatialIndex .
## ---------------------------------------------------------------
## This URI must be fixed - it's used to assemble the spatial dataset.
:spatial_dataset rdf:type spatial:SpatialDataset ;
spatial:dataset <#tdb_dataset_readwrite> ;
##spatial:index <#indexSolr> ;
spatial:index <#indexLucene> ;
.
<#tdb_dataset_readwrite> rdf:type tdb:DatasetTDB ;
tdb:location "/myfolder" ;
## # Query timeout on this dataset (milliseconds)
## ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "1000" ] ;
## # Default graph for query is the (read-only) union of all named graphs.
tdb:unionDefaultGraph true ;
.
<#indexLucene> a spatial:SpatialIndexLucene ;
#spatial:directory <file:Lucene> ;
## spatial:directory "mem" ;
spatial:directory <file:/myfolder/spatial> ;
spatial:definition <#definition> ;
.
<#definition> a spatial:EntityDefinition ;
spatial:entityField "uri" ;
spatial:geoField "geo" ;
# custom geo predicates for 1) Latitude/Longitude Format
spatial:hasSpatialPredicatePairs (
[ spatial:latitude :latitude_1 ; spatial:longitude :longitude_1 ]
[ spatial:latitude :latitude_2 ; spatial:longitude :longitude_2 ]
) ;
# custom geo predicates for 2) Well Known Text (WKT) Literal
spatial:hasWKTPredicates (:wkt_1 :wkt_2) ;
# custom SpatialContextFactory for 2) Well Known Text (WKT) Literal
spatial:spatialContextFactory
"org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory"
.
# "com.spatial4j.core.context.jts.JtsSpatialContextFactory"
<#service_tdb1> rdf:type fuseki:Service ;
rdfs:label "TDB Service" ;
fuseki:name "tdb_spatial" ;
fuseki:serviceQuery "query" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadWriteGraphStore "data" ;
# A separate read-only graph store endpoint:
fuseki:serviceReadGraphStore "get" ;
fuseki:dataset :spatial_dataset ;
如您所见,我已将班级名称更改为org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory
。除了运行fuseki时,我必须在类路径中包含另一个jar文件,否则我会遇到
EntityDefinitionAssembler WARN Custom SpatialContextFactory lib is not ready in classpath:com/vividsolutions/jts/geom/CoordinateSequenceFactory
然后我的命令行看起来像:
java -cp“fuseki-server.jar:lib / jts-1.13.jar”org.apache.jena.fuseki.cmd.FusekiCmd -debug
我已从here
下载了jts-1.13.jar
此外,我要感谢Kai指出我正确的方向。
注意:我仍然必须完全理解spatial:EntityDefinition
下的字段。我将尝试编辑更多信息。