diff --git a/Project.toml b/Project.toml index 4b1508c..cee576b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,4 +1,4 @@ -name = "GISTRtree" +name = "SortTileRecursiveTree" uuid = "746ee33f-1797-42c2-866d-db2fce69d14d" authors = ["Max Freudenberg and contributors"] version = "0.1.0" diff --git a/README.md b/README.md index 642c446..eec1fb6 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/GISTRtree.jl b/src/SortTileRecursiveTree.jl similarity index 96% rename from src/GISTRtree.jl rename to src/SortTileRecursiveTree.jl index 9b60b85..271d0c5 100644 --- a/src/GISTRtree.jl +++ b/src/SortTileRecursiveTree.jl @@ -1,4 +1,4 @@ -module GISTRtree +module SortTileRecursiveTree using Extents import GeoInterface as GI @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 4240f04..5ec9e70 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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}