0

嗨,我想添加基于空间的三元组

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\\");

我这样编码,但没有用。

4

3 回答 3

1

unsatisfied link 错误可能表明它在java路径中找不到Parliament.dll。

检查此 SO 以了解有关 java 路径中 dll 的详细信息: java.lang.UnsatisfiedLinkError no *****.dll in java.library.path

另外,您是否遵循议会设置指南? http://parliament.semwebcentral.org/ParliamentUserGuide.pdf

您可能还想确保您使用的是正确的 dll……已经有一段时间了,所以我可能错了,但我认为有 32 位和 64 位版本。

于 2013-12-23T15:49:28.820 回答
0

根据抛出的异常,您的问题是由于配置/建立议会环境变量方面的差距。请按照上述答案中提供的议会用户指南进行操作。完成后,您将获得并输出如下:

INFO [main] (KbGraphStore.java:163) - Adding named graph: <http://parliament.semwebcentral.org/parliament#MasterGraph> (graphDir = "master") Apr 07, 2014 2:17:05 PM org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory to a 1800000ms timeout Apr 07, 2014 2:17:05 PM org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.DefaultFactory to a 1800000ms timeout Apr 07, 2014 2:17:05 PM org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory createDataSource INFO: Building new data source for org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory Apr 07, 2014 2:17:05 PM org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory createBackingStore INFO: Building backing store for org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory Apr 07, 2014 2:17:05 PM org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory createBackingStore INFO: Creating cached EPSG database version 7.5.0. This operation may take a few minutes... Apr 07, 2014 2:17:06 PM org.geotools.referencing.factory.PropertyAuthorityFactory <init> WARNING: Axis elements found in a wkt definition, the force longitude first axis order hint might not be respected: PROJCS["Google Projection",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],UNIT["degree", 0.017453292519943295],AXIS["Geodetic longitude", EAST],AXIS["Geodetic latitude", NORTH],AUTHORITY["EPSG","4326"]],PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]],PARAMETER["semi_minor", 6378137.0],PARAMETER["latitude_of_origin", 0.0],PARAMETER["central_meridian", 0.0],PARAMETER["scale_factor", 1.0],PARAMETER["false_easting", 0.0],PARAMETER["false_northing", 0.0],UNIT["m", 1.0]] 只有在此之后,您才能对创建的模型执行任何操作,例如添加三元组和查询。

除了具有空间属性的 Triple 之外:假设您想将空间坐标添加到 Individual(例如individual),您可以使用以下代码片段:

import com.bbn.parliament.jena.graph.index.spatial.geosparql.datatypes.WKTLiteral;
import com.bbn.parliament.jena.graph.index.spatial.geosparql.vocabulary.*;
.
.
.
WKTLiteral geoLiteral = new WKTLiteral();
String value="Point(22.5 88.5)";// OR "POLYGON((22.5 88.5, 88.5 99.5, 99.5 22.5))"
individual.addLiteral(Geo.asWKT, model.createTypedLiteral(value, geoLiteral));

诀窍:

KbGraph graph = KbGraphFactory.createDefaultGraph("file:C:\\ParliamentKB\\data\\"); 不工作,我不知道为什么!所以您可能需要在ParliamentCONfig.txt 本身中指定路径。

于 2014-04-07T09:00:34.460 回答
0

在议会用户指南 ( http://parliament.semwebcentral.org/ParliamentUserGuide.pdf ) 中,第 26 页的第 2.8 节专门用于解决这些 UnsatisfiedLinkError 问题。

于 2014-01-17T15:52:34.933 回答