#!/usr/bin/env ruby # -*- coding: utf-8 -*- # (C)2016-12-19 by HIROSE, Yuuji [yuuji>at new-hoge.geojson\n\n" STDERR.puts "OffsetDegree defaults to +360" exit 0 end json = JSON.load(open(ARGV[0]){|j|j.read}) offsetlon = (ARGV[1]||360).to_i json["features"].each do |f| g = f["geometry"] if g then co = g["coordinates"] STDERR.puts g["type"].inspect if co then coords = if co[0].is_a?(Numeric) [[co]] elsif co[0][0].is_a?(Numeric) [co] else co end for cs in coords for c in cs if c[0] < 0 then STDERR.printf("%f -> %f\n", c[0], c[0]+offsetlon) c[0] += offsetlon end end end end end end print JSON.pretty_generate(json)