module Terraformer
terraformer.rb - a toolkit for working with geojson in ruby
Constants
- DEFAULT_BUFFER_RESOLUTION
- DEGREES_PER_RADIAN
- EARTH_RADIUS
- GEOGRAPHIC_CRS
- MERCATOR_CRS
- PI
- PRECISION
number of decimal places of precision to limit bigmath calculations to
- RADIANS_PER_DEGREE
- VERSION
Public Class Methods
geojson_io(data)
click to toggle source
open OS's default browser to geojson.io with param data
# File lib/terraformer.rb, line 61 def self.geojson_io data require 'launchy' require 'uri' Launchy.open "http://geojson.io/#data=data:application/json,#{URI.encode_www_form_component data.to_json}" end
parse(geojson)
click to toggle source
parses geojson into a terraformer object. parameter must be a Hash
, String
or File
containing a valid geojson object. return class type is determined by type
property.
# File lib/terraformer.rb, line 45 def self.parse geojson if geojson.is_a?(String) or geojson.respond_to?(:read) geojson = File.read geojson if File.readable? geojson geojson = JSON.parse geojson end raise ArgumentError.new "invalid arg: #{geojson}" unless Hash === geojson if klass = Terraformer.const_get(geojson['type']) klass.new geojson else raise ArgumentError.new 'unknown type: ' + geojson['type'] end end