Skip to content

Commit

Permalink
minor additions
Browse files Browse the repository at this point in the history
- add Manifest to .gitignore
- use Aqua quality assurance
- sort Project.toml
- remove debugging statement
  • Loading branch information
visr committed Sep 21, 2023
1 parent 5a68682 commit 112c16b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.jl.cov
*.jl.*.cov
*.jl.mem
/deps/deps.jl
/deps/usr/
Manifest.toml
10 changes: 6 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ license = "MIT"
version = "0.2.0"

[deps]
LibSpatialIndex_jll = "00e98e2a-4326-5239-88cb-15dcbe1c18d0"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
LibSpatialIndex_jll = "00e98e2a-4326-5239-88cb-15dcbe1c18d0"

[compat]
julia = "1.6"
LibSpatialIndex_jll = "1.8"
Aqua = "0.7"
GeoInterface = "1"
LibSpatialIndex_jll = "1.8"
julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Aqua", "Test"]
19 changes: 9 additions & 10 deletions src/LibSpatialIndex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module LibSpatialIndex
* `fillfactor`: The fill factor. Default is `0.7`.
* `splitdistributionfactor`: Default is `0.4`.
* `reinsertfactor`: Default is `0.3`.
# Performance
Dataset size, data density, etc. have nothing to do with capacity and page
Expand Down Expand Up @@ -165,11 +165,11 @@ module LibSpatialIndex
Inserts an item into the `rtree` with given `id` and boundingbox specified
by `minvalues` and `maxvalues`, where the item lies within the interval
`[minvalues[i], maxvalues[i]]` for each axis `i` in 1, ..., `ndim`,
`[minvalues[i], maxvalues[i]]` for each axis `i` in 1, ..., `ndim`,
or similar for the `Extent` of `obj`.
If `obj` is passed it will be detected as a `GeoInterface.PointTrait`
and used as a point, or otherwise `GeoInterface.extent` will be called to
and used as a point, or otherwise `GeoInterface.extent` will be called to
detect or calculate the objects `Extent`, falling back to `Extents.extent`.
In these cases `minvalues` and `maxvalues` are taken from the point or extent.
Expand Down Expand Up @@ -203,7 +203,7 @@ module LibSpatialIndex
axis `i` in 1, ..., `ndim`, or similar for the `Extent` of `obj`.
If `obj` is passed it will be detected as a `GeoInterface.PointTrait`
and used as a point, or otherwise `GeoInterface.extent` will be called to
and used as a point, or otherwise `GeoInterface.extent` will be called to
detect or calculate the objects `Extent`, falling back to `Extents.extent`.
In these cases `minvalues` and `maxvalues` are taken from the point or extent.
Expand All @@ -230,7 +230,6 @@ module LibSpatialIndex
end
end
function intersects(rtree::RTree, extent::GI.Extent)
@show extent
intersects(rtree::RTree, _ext2vecs(extent)...)
end
intersects(rtree::RTree, ::Nothing) = _not_point_or_ext_error()

Check warning on line 235 in src/LibSpatialIndex.jl

View check run for this annotation

Codecov / codecov/patch

src/LibSpatialIndex.jl#L235

Added line #L235 was not covered by tests
Expand All @@ -250,7 +249,7 @@ module LibSpatialIndex
between some of the items, it might return more than `k` items.
If `obj` is passed it will be detected as a `GeoInterface.PointTrait`
and used as a point, or otherwise `GeoInterface.extent` will be called to
and used as a point, or otherwise `GeoInterface.extent` will be called to
detect or calculate the objects `Extent`, falling back to `Extents.extent`.
In these cases `minvalues` and `maxvalues` are taken from the point or extent.
Expand All @@ -271,7 +270,7 @@ module LibSpatialIndex
knn(rtree::RTree, point::Vector{Float64}, k::Integer) = knn(rtree, point, point, k)
knn(rtree::RTree, extent::GI.Extent, k::Integer) = knn(rtree::RTree, _ext2vecs(extent)..., k)
knn(rtree::RTree, extent::Nothing, k::Integer) = _not_point_or_ext_error()

Check warning on line 272 in src/LibSpatialIndex.jl

View check run for this annotation

Codecov / codecov/patch

src/LibSpatialIndex.jl#L272

Added line #L272 was not covered by tests
function knn(rtree::RTree, obj, k::Integer)
function knn(rtree::RTree, obj, k::Integer)
if GI.trait(obj) isa GI.PointTrait
knn(rtree, _point2vec(obj), k)
else
Expand All @@ -284,9 +283,9 @@ module LibSpatialIndex
haskey(ex, :X) && haskey(ex, :Y) || throw(ArgumentError("Extent does not have X and Y keys"))

min, max = if haskey(ex, :Z)
Float64[ex.X[1], ex.Y[1], ex.Z[1]], Float64[ex.X[2], ex.Y[2], ex.Z[1]]
Float64[ex.X[1], ex.Y[1], ex.Z[1]], Float64[ex.X[2], ex.Y[2], ex.Z[1]]

Check warning on line 286 in src/LibSpatialIndex.jl

View check run for this annotation

Codecov / codecov/patch

src/LibSpatialIndex.jl#L286

Added line #L286 was not covered by tests
else
Float64[ex.X[1], ex.Y[1]], Float64[ex.X[2], ex.Y[2]]
Float64[ex.X[1], ex.Y[1]], Float64[ex.X[2], ex.Y[2]]
end

return min, max
Expand All @@ -301,5 +300,5 @@ module LibSpatialIndex
end

_not_point_or_ext_error() = throw(ArgumentError("object is not a point, and does not have an extent"))

end # module
10 changes: 7 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using LibSpatialIndex
using Test
using GeoInterface
const SI = LibSpatialIndex
const GI = GeoInterface
import GeoInterface as GI
import LibSpatialIndex as SI
import Aqua

@testset "Simple Tutorial" begin
# based on https://github.com/libspatialindex/libspatialindex/wiki/Simple-Tutorial
Expand Down Expand Up @@ -69,3 +69,7 @@ end
@test sort(SI.knn(rtree, GI.Extent(X=(2.0, 2.0), Y=(2.0, 2.0)), 1)) == [2]
@test sort(SI.knn(rtree, (2.0, 2.0), 1)) == [2]
end

@testset "Aqua" begin
Aqua.test_all(LibSpatialIndex)
end

0 comments on commit 112c16b

Please sign in to comment.