Skip to content

Instantly share code, notes, and snippets.

@venj
Last active August 29, 2015 13:57
Show Gist options
  • Save venj/9909778 to your computer and use it in GitHub Desktop.
Save venj/9909778 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding = UTF-8
# 模拟导航数据转换GPS坐标算法
# 接受一个参数,指定模拟导航数据文件的名字
path = ARGV[0]
open("result.txt", "w+") do |f|
open(path).each_line do |line|
x, y = line.sub("[", "").sub("]", "").split(",").map {|i|
tmp = i.to_f / 100
tmp.floor + (tmp - tmp.floor) / 0.6
}
f.printf "%.9f,%.9f\n", x, y
end
end
#!/usr/bin/env ruby
# encoding = UTF-8
# 由iPhone采集的数据生成安卓用的测试数据
require "fileutils"
include FileUtils
cd ARGV[0] do
Dir["*.txt"].each do |file|
filename = File.basename(file, ".txt")
open("#{filename}.db", "w+") do |db|
open(file, "r+").each_line do |line|
parts = line.split(",")
db.puts "#{parts[0]},#{parts[1]}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment