Skip to content

Instantly share code, notes, and snippets.

@arturaz
Forked from charliedavi/gist:2320843
Created April 6, 2012 15:44
Show Gist options
  • Save arturaz/2320916 to your computer and use it in GitHub Desktop.
Save arturaz/2320916 to your computer and use it in GitHub Desktop.
require 'java'
require 'libssrckdtree-j-1.0.2.jar'
GenericPoint = Java::com.savarese.spatial.GenericPoint
KDTree = Java::com.savarese.spatial.KDTree
def generate_points(tree, size)
size.times do
x = rand(100)
y = rand(100)
point = GenericPoint.new(x, y)
tree.put(point, point.to_s)
end
end
tree = KDTree.new
range = tree.iterator(
GenericPoint.new(25, 25),
GenericPoint.new(75, 75)
)
while range.has_next
e = range.next
puts "#{e.key}: #{e.value}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment