Created
October 16, 2017 00:35
-
-
Save harry-wood/d5dd2c088a713e9ab3e5bc5f502cee32 to your computer and use it in GitHub Desktop.
Little ruby script to generate a test KML file, with 40 random markers
This file contains hidden or 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
puts '<?xml version="1.0" encoding="UTF-8"?>' | |
puts '<kml xmlns="http://www.opengis.net/kml/2.2">' | |
puts '<Document>' | |
puts " <name>Lots of placemarks #{random_str}</name>" | |
puts ' <description>A test KML file with lots of placemarks</description>' | |
(0..40).each do | |
puts '<Placemark>' | |
puts " <name>placemark name #{random_str}</name>" | |
puts " <description>#{random_str}#{random_str}#{random_str}</description>" | |
puts " <Point><coordinates>#{random_coords},0</coordinates></Point>" | |
puts '</Placemark>' | |
end | |
puts '</Document>' | |
puts '</kml>' | |
def random_str | |
(0...10).map { ('a'..'z').to_a[rand(26)] }.join | |
end | |
def random_coords | |
lat = 51.50774 + (rand - 0.5) * 3 | |
lon = -0.12788 + (rand - 0.5) * 3 | |
"#{lon},#{lat}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment