Project

quadtree

0.0
A long-lived project that still receives updates
Quadtrees in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.14
~> 0.9
~> 13.1
~> 3.13
~> 1.62
~> 0.22

Runtime

 Project Readme

Quadtree

Gem Documentation

Quadtrees in Ruby. For searching spatially related nodes in some space, you know.

Installation

Add this line to your application's Gemfile:

gem 'quadtree'

And then execute:

bundle

Or install it yourself as:

gem install quadtree

Usage

Load it in your code to start building quadtrees:

require 'quadtree'

boundary = Quadtree::AxisAlignedBoundingBox.new(Quadtree::Point.new(19.8470050, 60.3747940), 8944.0)
qt = Quadtree::Quadtree.new(boundary)

Then you can do lookups and such:

getaboden = Quadtree::Point.new(19.8470050, 60.3747940, "Getaboden")
knutnas = Quadtree::Point.new(19.8271170, 60.3505570, "Knutnäs")
boundary = Quadtree::AxisAlignedBoundingBox.new(Quadtree::Point.new(19.8470050, 60.3747940), 8944.0)
boundary2 = Quadtree::AxisAlignedBoundingBox.new(Quadtree::Point.new(19.8470050, 60.3747940), 4472.0)
qt.insert! getaboden
qt.insert! knutnas
qt.query_range(boundary2)
# [#<Quadtree::Point:0x00007fdcb19e0698 @data="Getaboden", @x=19.847005, @y=60.374794>,
 #<Quadtree::Point:0x00007fdcb19ec7b8 @data="Knutnäs", @x=19.827117, @y=60.350557>]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number using rake version:create or rake version:bump, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on Github at https://github.com/janlindblom/ruby-quadtree. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Quadtree project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.