Skip to content

Commit 665aa64

Browse files
committed
Merge branch 'dev'
2 parents 873b038 + fab3a28 commit 665aa64

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ a spatial index for neo4j 4.x.
55

66
## What can it do
77

8-
create a spatial index
8+
### create a spatial index
99
~~~java
1010
//5个参数依次是: neo4j的GraphDatabaseService实例 索引名(唯一) 空间属性名 rtree最大子节点数 最大缓存geometry对象数
1111
RTreeIndex rTreeIndex = RTreeIndexManager.createIndex(db, "index1", "geometry", 64, 1024);
1212
~~~
1313

1414

15-
add node(s) to spatial index
15+
### add node(s) to spatial index
1616
~~~java
1717
Transaction tx = db.beginTx();
1818
Node node = tx.createNode(testLabel);//create node
@@ -23,7 +23,7 @@ rTreeIndex.add(node,tx);//add to spatial index(if you have many vertices, add as
2323

2424
~~~
2525

26-
spatial query
26+
### spatial query
2727
~~~java
2828
//Enter a rectangle and query the node covered by the rectangle
2929
double[] bbox = new double[]{3, 1, 8, 9};
@@ -45,7 +45,7 @@ try (Transaction tx = db.beginTx()) {
4545
}
4646
~~~
4747

48-
nearest neighbor search
48+
### nearest neighbor search
4949
~~~java
5050
//Query the 5 nodes closest to point (10.2, 13.2)
5151
try (Transaction tx = db.beginTx()) {
@@ -61,11 +61,22 @@ try (Transaction tx = db.beginTx()) {
6161
System.out.println(res);//DistanceResult里包含了node、距离以及geometry,详见测试用例
6262
}
6363
~~~
64-
64+
### Faster spatial analysis of big geometry
65+
As for very fine geometry, because it contains too many points, the performance of spatial relationship calculation by using JTS's ``intersects`` function directly will be poor. At this point, it can be considered to use the Tool BigShapeManager to cut it open and establish index before analysis:
66+
~~~java
67+
String wkt = "...";//一个很多点构成的多边形
68+
Geometry geometry = wktReader.read(wkt);
69+
String indexId = "123";//声明一个id来构建索引,注意id唯一性
70+
BigShapeManager.build(graphDb, indexId, geometry, 10, 10);//切割多边形为10行10列并构建索引
71+
BigShape bigShape = BigShapeManager.get(graphDb, indexId);//获取到BigShape对象
72+
Geometry s1 = new WKTReader().read("POINT (866.8184900283813 132.99309968948364)");
73+
System.out.println(bigShape.intersects(tx, s1));//利用BigShape来做空间关系计算
74+
~~~
75+
The actual measurement performance of BigShape is up to 100 times faster than that of direct JTS for fine and complex geometry (simple geometry does not need BigShape cutting, otherwise the performance may decline)
6576

6677

6778
## install
68-
The latest version is `1.3.0`
79+
The latest version is `1.4.0`
6980

7081
maven import in your project
7182
```

README_zh.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
## 这个项目能干什么
77

8-
新建空间索引
8+
### 新建空间索引
99
~~~java
1010
//5个参数依次是: neo4j的GraphDatabaseService实例 索引名(唯一) 空间属性名 rtree最大子节点数 最大缓存geometry对象数
1111
RTreeIndex rTreeIndex = RTreeIndexManager.createIndex(db, "index1", "geometry", 64, 1024);
1212
~~~
1313

1414

15-
简洁地为node加入空间索引:
15+
### 简洁地为node加入空间索引:
1616
~~~java
1717
Transaction tx = db.beginTx();
1818
Node node = tx.createNode(testLabel);//新建节点
@@ -23,7 +23,7 @@ rTreeIndex.add(node,tx);//加入索引(效率起见,多个node的话用list ad
2323

2424
~~~
2525

26-
空间查询
26+
### 空间查询
2727
~~~java
2828
//输入一个矩形范围,查询矩形覆盖的节点
2929
double[] bbox = new double[]{3, 1, 8, 9};
@@ -45,7 +45,7 @@ try (Transaction tx = db.beginTx()) {
4545
}
4646
~~~
4747

48-
最邻近搜索
48+
### 最邻近搜索
4949
~~~java
5050
//查询距离点(10.2, 13.2)最近的5个node
5151
try (Transaction tx = db.beginTx()) {
@@ -61,11 +61,22 @@ try (Transaction tx = db.beginTx()) {
6161
System.out.println(res);//DistanceResult里包含了node、距离以及geometry,详见测试用例
6262
}
6363
~~~
64-
64+
### 精细对象的快速空间分析
65+
对于非常精细的geometry,由于它包含了太多的点,直接用jts的intersects等函数去进行空间关系计算性能会很差,此时,可以考虑用BigShapeManager工具将其切割开并建立索引后再分析:
66+
~~~java
67+
String wkt = "...";//一个很多点构成的多边形
68+
Geometry geometry = wktReader.read(wkt);
69+
String indexId = "123";//声明一个id来构建索引,注意id唯一性
70+
BigShapeManager.build(graphDb, indexId, geometry, 10, 10);//切割多边形为10行10列并构建索引
71+
BigShape bigShape = BigShapeManager.get(graphDb, indexId);//获取到BigShape对象
72+
Geometry s1 = new WKTReader().read("POINT (866.8184900283813 132.99309968948364)");
73+
System.out.println(bigShape.intersects(tx, s1));//利用BigShape来做空间关系计算
74+
~~~
75+
实测对于精细复杂的geometry,BigShape的性能比直接jts快了上百倍(简单的geometry就不要BigShape切割了,否则可能反而性能下降)
6576

6677

6778
## install
68-
The latest version is `1.3.0`
79+
The latest version is `1.4.0`
6980

7081
maven import in your project
7182
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</properties>
1313
<groupId>org.wowtools</groupId>
1414
<artifactId>neo4j-rtree</artifactId>
15-
<version>1.4-SNAPSHOT</version>
15+
<version>1.4.0</version>
1616
<name>neo4j-rtree</name>
1717

1818
<description>a spatial index for neo4j 4.x.</description>

0 commit comments

Comments
 (0)