Created
December 8, 2012 01:29
-
-
Save bbttxu/4238060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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