#!/usr/bin/env ruby
# Usage: $0 data/*.geojson
require 'json'
require 'csv'
header = "name,lon1,lat1,lon2,lat2,lon3,lat3\n"
csv = CSV.generate(header, headers: true) do |c|
ARGV.each do |file|
json = JSON.parse(open(file){|f|f.read})
name = json["_umap_options"]["name"]
coords = []
json["features"].each do |f|
g = f["geometry"]
if g["type"] == "Point"
coord = g["coordinates"]
coords += coord
end
end
c << [name] + coords
end
end
puts csv