Skip to content

Commit

Permalink
对原项目github.com/dhconnelly/rtreego进行了精度更改,准备测试
Browse files Browse the repository at this point in the history
  • Loading branch information
peifengll committed Nov 7, 2023
1 parent b56e152 commit 503c937
Show file tree
Hide file tree
Showing 8 changed files with 3,078 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.idea/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# rtreego
https://github.com/dhconnelly/rtreego 精度进行了更改
https://github.com/dhconnelly/rtreego 精度进行了更改,改为float32

32 changes: 32 additions & 0 deletions filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package rtreego

// Filter is an interface for filtering leaves during search. The parameters
// should be treated as read-only. If refuse is true, the current entry will
// not be added to the result set. If abort is true, the search is aborted and
// the current result set will be returned.
type Filter func(results []Spatial, object Spatial) (refuse, abort bool)

// ApplyFilters applies the given filters and returns whether the entry is
// refused and/or the search should be aborted. If a filter refuses an entry,
// the following filters are not applied for the entry. If a filter aborts, the
// search terminates without further applying any filter.
func applyFilters(results []Spatial, object Spatial, filters []Filter) (bool, bool) {
for _, filter := range filters {
refuse, abort := filter(results, object)
if refuse || abort {
return refuse, abort
}
}
return false, false
}

// LimitFilter checks if the results have reached the limit size and aborts if so.
func LimitFilter(limit int) Filter {
return func(results []Spatial, object Spatial) (refuse, abort bool) {
if len(results) >= limit {
return true, true
}

return false, false
}
}
Loading

0 comments on commit 503c937

Please sign in to comment.