Skip to content

Instantly share code, notes, and snippets.

@kenichi
Last active August 29, 2015 14:02
Show Gist options
  • Save kenichi/d39a340bb4483d97b78b to your computer and use it in GitHub Desktop.
Save kenichi/d39a340bb4483d97b78b to your computer and use it in GitHub Desktop.
How to get Geotrigger polygons into an editable map on geojson.io in 4 easy steps
require 'terraformer'
require 'geotrigger'
require 'launchy'
# create a new FeatureCollection
#
fc = Terraformer::FeatureCollection.new
# create a Geotrigger Application session with credentials stored in ~/.geotrigger under the :foo key
#
a = Geotrigger::Application.new config: :foo
# iterate each trigger in the application with a tag of 'foo', parsing the geometry GeoJSON
# fragments into features, and adding them to the FeatureCollection
#
a.triggers(tags: 'foo').each {|t| fc << Terraformer.parse(t.condition['geo']['geojson']).to_feature}
# pipe the FeatureCollection to the http://geojson.io editor
#
Launchy.open "http://geojson.io/#data=data:application/json,#{URI.encode_www_form_component fc.to_json}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment