0.02
No commit activity in last 3 years
No release in over 3 years
toolkit for working with GeoJSON in pure Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.4
 Project Readme

terraformer-ruby

terraformer-ruby is a toolkit for working with GeoJSON in pure Ruby. Inspired by terraformer.

Installation

In your application's Gemfile:

gem 'terraformer'

Or install it manually:

$ gem install terraformer

Usage

require 'terraformer'
Create a Terraformer primitive from GeoJSON
polygon = Terraformer.parse '{
  "type": "Polygon",
  "coordinates": [
    [
      [-122.66589403152467, 45.52290150862236],
      [-122.66926288604736, 45.52291654238294],
      [-122.67115116119385, 45.518406234030586],
      [-122.67325401306151, 45.514000817199715],
      [-122.6684260368347, 45.5127377671934],
      [-122.66765356063841, 45.51694782364431],
      [-122.66589403152467, 45.52290150862236 ]
    ]
  ]
}'

point = Terraformer.parse '{
  "type": "Point",
  "coordinates": [-122.66947746276854, 45.51775972687403]
}'

Now that you have a point and a polygon primitive you can use the primitive helper methods.

# add a new vertex to our polygon
new_point = Terraformer::Point.new -122.6708507537842, 45.513188859735436
polygon.insert_vertex 2, new_point

You can also have Terraformer perform many geometric operations like convex hulls and bounding boxes.

# returns convex hull
convex_hull = polygon.convex_hull

point.within? convex_hull
=> true

# returns the bounding box
bounding_box = polygon.bbox

Contributing

After checking out the source, run the tests:

$ git clone git@github.com:kenichi/terraformer-ruby.git
$ cd terraformer-ruby
$ bundle install
$ bundle exec rake test

You can also generate RDoc:

$ bundle exec rdoc --main README.md