Created
July 22, 2020 15:09
-
-
Save waynegraham/030786613fe095378cdcfed6b51dfaac to your computer and use it in GitHub Desktop.
Spatial Test
This file contains 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
# frozen_string_literal: true | |
source "https://rubygems.org" | |
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | |
gem 'colorize' | |
gem 'geo_names' | |
gem "geocoder" | |
gem "dotenv" |
This file contains 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
require 'colorize' | |
require 'dotenv' | |
require 'geo_names' | |
Dotenv.load | |
# TODO: titleize and dedupe | |
places = File.readlines('dlme-cho-spatial-values.txt') | |
GeoNames.configure do |config| | |
config.username = ENV['GEONAMES_USERNAME'] | |
end | |
places.each do |place| | |
criteria = { q: place } | |
result = GeoNames::Search.search(criteria) | |
if result['totalResultsCount'] > 0 | |
puts result | |
else | |
puts "Nothing returned for #{place}".red | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment