From 81d1b68a730cc1101d998c92cba606684a1e37b2 Mon Sep 17 00:00:00 2001 From: Max Freudenberg Date: Thu, 4 Jan 2024 15:28:33 +0100 Subject: [PATCH 1/2] add show method --- src/GISTRtree.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/GISTRtree.jl b/src/GISTRtree.jl index 9b60b85..eb5bc7b 100644 --- a/src/GISTRtree.jl +++ b/src/GISTRtree.jl @@ -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::GISTRtree.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 From 197a38b1bc829a7f6be6f034ccae31d2708ddff2 Mon Sep 17 00:00:00 2001 From: Max Freudenberg Date: Mon, 29 Jan 2024 11:33:23 +0100 Subject: [PATCH 2/2] rename --- Project.toml | 2 +- README.md | 6 +++--- src/{GISTRtree.jl => SortTileRecursiveTree.jl} | 4 ++-- test/runtests.jl | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) rename src/{GISTRtree.jl => SortTileRecursiveTree.jl} (97%) 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 97% rename from src/GISTRtree.jl rename to src/SortTileRecursiveTree.jl index eb5bc7b..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,7 +34,7 @@ GI.extent(n::STRNode) = n.extent GI.extent(n::STRLeafNode) = foldl(Extents.union, n.extents) -function Base.show(io::IO, tree::GISTRtree.STRtree) +function Base.show(io::IO, tree::SortTileRecursiveTree.STRtree) println(io, "STRtree") display(tree.rootnode.extent) end 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}