Skip to content

Instantly share code, notes, and snippets.

@fujimura
Created March 2, 2018 11:30
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 fujimura/bc238dd5d6a75aac31051d36d04a737a to your computer and use it in GitHub Desktop.
Save fujimura/bc238dd5d6a75aac31051d36d04a737a to your computer and use it in GitHub Desktop.
require 'json'
def get_lonlat_in_spiral(i)
v = Complex.polar i, i/4.9 * Math::PI/2
angle = v.angle
magnitude = v.magnitude
[magnitude * Math.cos(angle), magnitude * Math.sin(angle)]
end
r = 10.upto(30).map { |i| get_lonlat_in_spiral(i) }
coords = r.map {|x, y| [139.6 + y * 0.01, 35.7 + x * 0.01] }
puts JSON.generate(
type: "MultiPolygon",
coordinates: [coords.map {|y, x| [y.floor(5), x.floor(5)] }.map { |y, x|
[
[y, x],
[y, x + 0.01],
[y - 0.01, x + 0.01],
[y - 0.01, x],
[y, x]
]
}]
)
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment