Election results in the London Borough of Sutton.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031
  1. # Convert OSGB36 eastings and northings to WGS84 latitudes and longitudes
  2. # $ ruby en2latlon.rb infile.csv > outfile.csv
  3. # http://adrianshort.org/2013/01/23/converting-eastings-and-northings-to-latitudes-and-longitudes-in-ruby/
  4. require 'csv'
  5. require_relative './OSGB36'
  6. lines = CSV.read(ARGV[0]) # read the whole file into an array of arrays
  7. easting_col = nil
  8. northing_col = nil
  9. (0..lines.size - 1).each do |i|
  10. if i == 0
  11. easting_col = lines[i].index("Eastings")
  12. northing_col = lines[i].index("Northings")
  13. lines[i] << "lat"
  14. lines[i] << "lng"
  15. else
  16. ll = OSGB36.en_to_ll(lines[i][easting_col].to_f, lines[i][northing_col].to_f)
  17. lines[i] << ll[:latitude]
  18. lines[i] << ll[:longitude]
  19. end
  20. end
  21. csv_str = CSV.generate do |csv|
  22. lines.each do |line|
  23. csv << line
  24. end
  25. end
  26. puts csv_str