Skip to content

Commit

Permalink
Merge pull request #1 from maxfreu/dev
Browse files Browse the repository at this point in the history
rename
  • Loading branch information
maxfreu authored Jan 29, 2024
2 parents 09d0c94 + 197a38b commit 1c6e9df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
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 <[email protected]> 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

0 comments on commit 1c6e9df

Please sign in to comment.