Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "GISTRtree"
name = "SortTileRecursiveTree"
uuid = "746ee33f-1797-42c2-866d-db2fce69d14d"
authors = ["Max Freudenberg <maximilian.freudenberg@uni-goettingen.de> and contributors"]
version = "0.1.0"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# GISTRtree
# SortTileRecursiveTree

[![Build Status](https://github.com/maxfreu/GISTRtree.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/maxfreu/GISTRtree.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Build Status](https://github.com/maxfreu/SortTileRecursiveTree.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/maxfreu/SortTileRecursiveTree.jl/actions/workflows/CI.yml?query=branch%3Amain)

An STR tree implementation for GeoInterface compatible geometries.

Usage:

```julia
using GISTRtree
using SortTileRecursiveTree
using Extents

tree = STRtree(geometries)
Expand Down
8 changes: 7 additions & 1 deletion src/GISTRtree.jl → src/SortTileRecursiveTree.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module GISTRtree
module SortTileRecursiveTree

using Extents
import GeoInterface as GI
Expand Down Expand Up @@ -34,6 +34,12 @@ GI.extent(n::STRNode) = n.extent
GI.extent(n::STRLeafNode) = foldl(Extents.union, n.extents)


function Base.show(io::IO, tree::SortTileRecursiveTree.STRtree)
println(io, "STRtree")
display(tree.rootnode.extent)
end


function leafnodes(geoms; nodecapacity=10)
extents_indices = [(GI.extent(geoms[i]), i) for i in eachindex(geoms)]
perm = sortperm(extents_indices; by=(v -> ((v[1][1][1] + v[1][1][2]) / 2))) # [extent/index][dim][min/max] sort by x
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using GISTRtree
using SortTileRecursiveTree
using Test
using Extents
import ArchGDAL as AG
import GeoInterface as GI


@testset "GISTRtree.jl" begin
@testset "SortTileRecursiveTree.jl" begin
x = 1:100
y = 1:100
points = AG.createpoint.(x, y')
# polygons = AG.buffer.(points, 0.1)
tree = STRtree(points)
@test tree.rootnode isa GISTRtree.STRNode
@test tree.rootnode.children[1] isa GISTRtree.STRNode
@test tree.rootnode isa SortTileRecursiveTree.STRNode
@test tree.rootnode.children[1] isa SortTileRecursiveTree.STRNode

query_result = query(tree, Extent(X=(0, 100.5), Y=(0, 1.5)))
@test query_result isa Vector{Int}
Expand Down