Skip to content

Instantly share code, notes, and snippets.

@bbttxu
Created December 8, 2012 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbttxu/4238060 to your computer and use it in GitHub Desktop.
Save bbttxu/4238060 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'json'
has_waypoints = true
lat = 34
lon = 118
min = 0.01
max = 0.09
lat_min = lat + min
lat_max = lat + max
lon_min = lon + min
lon_max = lon + max
num = 8
data = {
:start => [ rand * (lat_max - lat_min) + lat_min, rand * (lon_max - lon_min) + lon_min ],
:end => [ rand * (lat_max - lat_min) + lat_min, rand * (lon_max - lon_min) + lon_min ]
}
if has_waypoints
waypoints = []
(0..num).each do |foo|
waypoints << [ rand * (lat_max - lat_min) + lat_min, rand * (lon_max - lon_min) + lon_min ]
end
data[:waypoints] = waypoints
end
# puts data.to_json # production
puts JSON.pretty_generate(data) # testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment