嗨,我想添加基于空间的三元组
http://www.izmirdeafet.com/Disaster htp://www.opengis.net/ont/geosparql#asWKT> "htp://www.opengis.net/def/crs/OGC/1.3/CRS84 POINT (8.46035239692792 51.48661096320327)"^^<http://www.opengis.net/ont/sf#wktLiteral>
在下面的java代码中进入带有库的议会三重商店,jena
但我在下面出错了。我有基于空间的本体,我已经添加到三重存储中。
public static void main(String[] args) {
// set to false when running the second time to avoid recreating the graphs/index
boolean firstTime = true;
// create spatial index factory and configure for GeoSPARQL. This is used
// by the GraphStore whenever a new named graph is created.
SpatialIndexFactory factory = new SpatialIndexFactory();
Properties properties = new Properties();
properties.setProperty(Constants.GEOMETRY_INDEX_TYPE,
Constants.GEOMETRY_INDEX_RTREE);
properties.setProperty(Constants.GEOSPARQL_ENABLED,
Boolean.TRUE.toString());
factory.configure(properties);
// register factory
IndexFactoryRegistry.getInstance().register(factory);
// create a Parliament graph and graph store
//KbGraph graph= KbGraphFactory.createNamedGraph();
KbGraph graph =
KbGraphFactory.createDefaultGraph("file:C:\\ParliamentKB\\data\\");
KbGraphStore graphStore = new KbGraphStore(graph);
graphStore.initialize();
if (firstTime) {
// create spatial index from factory
SpatialIndex index = factory.createIndex(graph, null);
// register index with IndexManager
IndexManager.getInstance().register(graph, null, factory, index);
// the following tells the graph store that the graph is now an
// indexing graph. This is necessary so that the next time Parliament
// loads, the index is read in automatically.
graphStore.setIndexingEnabled(KbGraphStore.DEFAULT_GRAPH_NODE, true);
}
// create a Jena model
Model model = ModelFactory.createModelForGraph(graph);
// load data
String fileName =
"C:\\Users\\Can\\Desktop\\DisasterOntologyEnglish\\disaster.rdf";
RDFFormat dataFormat = RDFFormat.parseFilename(fileName);
FileManager.get().readModel(model, fileName, dataFormat.toString());
// get index and print size
System.out.println(IndexManager.getInstance().
getIndexes(graph).get(0).size());
// do a spatial query
String query = ""
+ "\nPREFIX my: <http://somewhere/ApplicationSchema#>"
+ "\nPREFIX geo: <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/>"
+ "\nPREFIX geof:
<http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/>"
+ "\nSELECT ?f" + "\nWHERE { my:A my:hasExactGeometry ?aGeom ."
+ "\n ?aGeom geo:asWKT ?aWKT ."
+ "\n ?f my:hasExactGeometry ?fGeom ."
+ "\n ?fGeom geo:asWKT ?fWKT ."
+ "\n FILTER (geof:sf-contains(?aWKT, ?fWKT) &&"
+ "\n !sameTerm(?aGeom, ?fGeom)) " + "\n}";
Query q = QueryFactory.create(query, Syntax.syntaxARQ);
ResultSet rs = QueryExecutionFactory.create(q, model).execSelect();
while (rs.hasNext()) {
System.out.println(rs.nextSolution());
}
}
错误
Exception in thread "main" java.lang.UnsatisfiedLinkError:
no Parliament in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.bbn.parliament.jni.Config.<clinit>(Config.java:184)
at com.bbn.parliament.jena.graph.KbGraphFactory.getKbConfigForDefaultGraph
(KbGraphFactory.java:81)
at com.bbn.parliament.jena.graph.KbGraphFactory.createDefaultGraph
(KbGraphFactory.java:38)
at com.disaster.demo.GeoSPARQLTest.main(GeoSPARQLTest.java:46)
我认为问题来自createdefaultgraph
部分:
你说的 dir 路径取自ParliamentConfig.txt
KbGraph graph = KbGraphFactory.createDefaultGraph("file:C:\\ParliamentKB\\data\\");
我这样编码,但没有用。