2014-01-07 21 views
0

的原因是什麼,以及如何解決此異常:Neo4j的使用空間:NotFoundException:超過一個關係

org.neo4j.graphdb.NotFoundException: More than one relationship[RTREE_CHILD, INCOMING] found for NodeImpl#105 
at org.neo4j.kernel.impl.core.NodeImpl.getSingleRelationship(NodeImpl.java:344) 
at org.neo4j.kernel.impl.core.NodeProxy.getSingleRelationship(NodeProxy.java:191) 
at org.neo4j.collections.rtree.RTreeIndex.getIndexNodeParent(RTreeIndex.java:768) 
at org.neo4j.collections.rtree.RTreeIndex.adjustPathBoundingBox(RTreeIndex.java:672) 
at org.neo4j.collections.rtree.RTreeIndex.add(RTreeIndex.java:90) 
at org.neo4j.gis.spatial.EditableLayerImpl.add(EditableLayerImpl.java:44) 
at org.neo4j.gis.spatial.ShapefileImporter.importFile(ShapefileImporter.java:209) 
at org.neo4j.gis.spatial.ShapefileImporter.importFile(ShapefileImporter.java:122) 

我使用的2.0.0和空間罐子從編譯GitHub的項目來。

,當我嘗試導入shapefile中的異常被拋出(這是在非託管擴展代碼):

GraphDatabaseService spatialDb = new GraphDatabaseFactory().newEmbeddedDatabase("/home/db/data/spatial.db"); 
    Transaction tx = spatialDb.beginTx(); 
    try { 
     ShapefileImporter importer = new ShapefileImporter(spatialDb, new NullListener()); 
     importer.importFile("/home/bla/realshp/users_location.shp", "users_location"); 
     tx.success(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } finally { 
     tx.close(); 
     return Response.status(200).entity("Done. ").build(); 
    } 

從CSV生成形狀文件,ogr2ogr文件 - 它似乎合法的,沒有例外被讀取。在原始文件有一圈定義如下(ogr2ogr將拉動經度和緯度)30000點:

id,longitude,latitude,gender,updated 
3,-122.1171925,37.4343361,1,2013-11-20 05:03:22 
304,-122.0919000,37.3094000,1,2013-11-03 00:42:01 
311,-122.0919000,37.3094000,1,2013-11-03 00:42:01 

怎麼去解決呢?我需要加載數百萬分的數據庫。 側面問題:現在我創建新的圖形空間數據存儲 - 它是否正確?也許我應該把它加載到現有的圖形數據庫?

UPDATE:

我試圖輸入 「手動」 座標使用從TestSimplePointLayer方法。我在第450個座標上得到了同樣的例外。它們的組合與你在樣本中看到的一樣,但是它們是有效的點。如何解決它?

回答

0

您跳過此步驟。您創建一個空間索引,然後將用戶添加到索引。

因此,舉例來說,如果你有在美國所有的州,縣或郵政編碼的形狀文件,您可以創建這些形狀的空間層和將用戶添加到他們。

您可以使用一個簡單的點層,以及如果你想要的,但他們必須是唯一的,但居住在這些地區的用戶節點沒有要。請參閱http://java.dzone.com/articles/running-along-graph-using-0http://www.markhneedham.com/blog/2013/03/10/neo4jcypher-finding-football-stadiums-near-a-city-using-spatial/以獲得更好的想法。

+0

感謝我能導入使用層對象API數據。從來沒有成功的shapefile,壽。 – user3167332

0

我滿足相同的錯誤,當我嘗試使用相同的經度/緯度(0,0)到層添加節點。 當插入超過100個RTREE_CHILD參考節點時,會出現此例外情況。這是源代碼的錯誤。

的src/main/JAVA /組織/ Neo4j的/ GIS /空間/ RTREE/RTreeIndex.java

試試這個分叉插件:

https://github.com/linkedin-inc/spatial