Project

overlap

0.0
No commit activity in last 3 years
No release in over 3 years
Overlaps Tool
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0
 Project Readme

Overlap

Code Climate

Dependency Status

Build Status (Travis CI)

Coverage Status

Gem Version

The Overlap module provides methods to remove overlapping for linear segments, also provide some informations about them:

You can give a collection of object with a start position and end position and Overlap give you Unions, Overlap spot overlapped segments and merge them to one continuous segment, and provide to you some informations like intersection quantities, new quantity/distance of your segment

The main purpose of Overlaps -- given a set of Segment objects -- is to find all possible overlaps and merge overlapped segment to ones.

This gem is inspired by overlaps so thanks Ryan Stenberg

Installation

Add this line to your application's Gemfile:

gem 'overlap'

And then execute:

$ bundle

Or install it yourself as:

$ gem install overlap

Usage

Require the Overlap module and call #find on a collection. You can feed them two main types of input:

Array of Array objects

input_data = [ [1,4], [2,3], [5,6] ]
Overlaps.find(input_data)

Array of whatever object where each object is of the same class and the start and end point attribute/accessors are passed as values in an options hash to the :start and :end keys:

DataObject = Struct.new(:start_point, :end_point)

input_data = [ DataObject.new(1,10), DataObject.new(1,5), DataObject.new(3,6) ]
analysis = Overlaps.find(input_data, start: :start_point, end: :end_point)

Overlaps.find returns an Object Analysis, this contains all unions and informations about the global data analysis

New Segment

analysis.unions.each do |union|
  union.segment => Overlap::Segment#... [1, 4]
  union.segment => Overlap::Segment#... [5, 6]
end
analysis.segments => [ Overlap::Segment#... [1, 4], Overlap::Segment#... [5, 6] ]

All Segments overlapped

analysis.unions.each do |union|
  union.segments => [ Overlap::Segment#... [1, 4], Overlap::Segment#... [2, 3] ]
  union.segments => [ Overlap::Segment#... [5, 6] ]
end

Intersections

analysis.unions.each do |union|
  union.intersections => [1]
  union.intersections => []
end
analysis.intersections => [ 1, 0 ]

Quantity/Distance

analysis.unions.each do |union|
  union.quantity => 3
  union.quantity => 1
end
analysis.quantities => [ 3, 1 ]
analysis.quantity => 4

Quantity/Distance With Intersections

analysis.unions.each do |union|
  union.quantity_with_intersections => 4
  union.quantity_with_intersections => 1
end
analysis.quantities_with_intersections => [ 4, 1 ]
analysis.quantity_with_intersections => 5

Intersections Quantity/Distance

analysis.unions.each do |union|
  union.intersection_quantity => 1
  union.intersection_quantity => 0
end
analysis.intersections => [ 1, 0 ]
analysis.intersection_quantity => 1

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 in version.rb, 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/FinalCAD/overlap. 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.