在java程序中使用graphHopper时出现文件锁定异常

时间:2016-01-28 09:14:55

标签: java maven locking distance graphhopper

我以下列方式使用GraphHopper:

    GraphHopper hopper = new GraphHopper().forServer();
    hopper.setCHEnable(false);
    hopper.setGraphHopperLocation(GraphHoperMasterFile);
    hopper.setOSMFile(OSMFile);
    hopper.setEncodingManager(new EncodingManager("car,bike"));

    hopper.importOrLoad();

    GHRequest req = new GHRequest().addPoint(new GHPoint (latFrom, lonFrom)).addPoint(new GHPoint(latTo, lonTo))
            .setVehicle("car")
            .setWeighting("fastest")
            .setAlgorithm(AlgorithmOptions.ASTAR_BI);;
    req.getHints().put("pass_through", true);
    GHResponse res = hopper.route(req);

我通过从https://github.com/graphhopper/graphhopper/blob/0.5/docs/core/routing.md下载zip来获得GraphHoperMasterFile。

我从http://download.geofabrik.de/europe/great-britain/england/greater-london.html获得了.osm文件。

我还从http://mvnrepository.com/artifact/com.graphhopper/graphhopper-web/0.5.0添加了maven依赖。我觉得拥有maven依赖并引用graphHopperLocation是错误的,但我不确定。

当我在某个时间(而不是所有时间)运行此代码时,会出现以下错误:

java.util.concurrent.ExecutionException: java.lang.RuntimeException: To avoid reading partial data we need to obtain the read lock but it failed.
Caused by: java.lang.RuntimeException: To avoid reading partial data we need to obtain the read lock but it failed.
Caused by: java.nio.channels.OverlappingFileLockException

当它工作时,我得到以下内容:

2016-01-28 08:48:14,551 [pool-1-thread-8] INFO  com.graphhopper.GraphHopper - version 0.5.0|2015-08-12T12:33:51+0000 (4,12,3,2,2,1)
2016-01-28 08:48:14,551 [pool-1-thread-8] INFO  com.graphhopper.GraphHopper - graph car,bike|RAM_STORE|2D|NoExt|4,12,3,2,2, details:edges:387 339(12MB), nodes:291 068(4MB), name:(2MB), geo:960 828(4MB), bounds:-0.5177850019436703,0.33744369456418666,51.28324388600686,51.69833101402963

我在这里看到了抛出的错误https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/GraphHopper.java

如何阻止此错误发生?

0 个答案:

没有答案