🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

simplify_rb

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simplify_rb

0.4.0
Rubygems
Version published
Maintainers
1
Created
Source

SimplifyRb - Polyline simplification

Build Status Gem Version

SimplifyRb is a Ruby port of simplify.js by Vladimir Agafonkin.

You can use this gem to reduce the number of points in a complex polyline / polygon, making use of an optimized Douglas-Peucker algorithm.

Usage

require 'simplify_rb'

points = [
  { x: 51.5256, y: -0.0875 },
  { x: 51.7823, y: -0.0912 }
]
tolerance = 1
high_quality = true

SimplifyRb::Simplifier.new.process(points, tolerance, high_quality)

points: An array of hashes, containing x,y coordinates.

tolerance: (optional, 1 by default): Affects the amount of simplification that occurs (the smaller, the less simplification).

high_quality: (optional, False by default): Flag to exclude the distance pre-processing. Produces higher quality results when true is passed, but runs slower.

Custom points

You can also use custom points, such as a struct or object which responds to :x and :y, rather than hashes:

CustomPointStruct = Struct.new(:x, :y)

custom_points = [
  CustomPointStruct.new(51.5256, -0.0875),
  CustomPointStruct.new(51.7823, -0.0912)
]

tolerance = 1
high_quality = true

SimplifyRb::Simplifier.new.process(custom_points, tolerance, high_quality)

Installation

Add this line to your application's Gemfile:

gem 'simplify_rb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simplify_rb

FAQs

Package last updated on 20 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

OSZAR »