Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to start building another STRTree from other STRTree #967

Open
zdila opened this issue Mar 10, 2023 · 1 comment
Open

Add option to start building another STRTree from other STRTree #967

zdila opened this issue Mar 10, 2023 · 1 comment

Comments

@zdila
Copy link

zdila commented Mar 10, 2023

We need a mean to "clone" existing STRTree to another one. Cloning should not build any of the source or destination STRTree.

STRTree index1 = new STRTree();

index1.insert(...);

STRTree index2 = new STRTree(index1);

// optional API: index2.insertAll(index1);

index1.insert(...);

index2.insert(...);

This could be suitable also for other SpatialIndexes.

@jiayuasu
Copy link
Contributor

jiayuasu commented Jun 8, 2023

@zdila in Apache Sedona (https://github.com/apache/sedona), we have been dealing with this issue for a while and I contributed a few functions to JTS to make the clone possible (in Sedona, we call it Serialize/Deserialize): #634 The necessary building blocks in JTS are package-private so it seems to be impossible to implement but it is actually possible.

Please feel free to use our Sedona serializer to clone STRtree and QuadTree.

Implementation: https://github.com/apache/sedona/tree/master/common/src/main/java/org/locationtech/jts/index
Coding example: https://github.com/apache/sedona/blob/master/common/src/test/java/org/apache/sedona/common/geometrySerde/SpatialIndexSerdeTest.java#L83

To use it, add the following dependencies in addition to your JTS dependency

<!-- https://mvnrepository.com/artifact/org.apache.sedona/sedona-common -->
<dependency>
    <groupId>org.apache.sedona</groupId>
    <artifactId>sedona-common</artifactId>
    <version>1.4.0</version>
</dependency>

<dependency>
    <groupId>com.esotericsoftware</groupId>
    <artifactId>kryo</artifactId>
    <version>4.0.2</version>
</dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants