Geocode Coop addresses to lat & long for map

This commit is contained in:
James Mead 2018-11-30 16:56:07 +00:00
parent 8780eca301
commit 3c80693d67
12 changed files with 41 additions and 16 deletions

View File

@ -4,3 +4,5 @@ gem 'jekyll'
# Fixes deprecation warning - see https://github.com/jekyll/jekyll-sass-converter/pull/75 # Fixes deprecation warning - see https://github.com/jekyll/jekyll-sass-converter/pull/75
gem 'jekyll-sass-converter', git: 'https://github.com/jekyll/jekyll-sass-converter.git', branch: 'sassc' gem 'jekyll-sass-converter', git: 'https://github.com/jekyll/jekyll-sass-converter.git', branch: 'sassc'
gem 'geocoder'

View File

@ -19,6 +19,7 @@ GEM
eventmachine (1.2.7) eventmachine (1.2.7)
ffi (1.9.25) ffi (1.9.25)
forwardable-extended (2.6.0) forwardable-extended (2.6.0)
geocoder (1.5.0)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
i18n (0.9.5) i18n (0.9.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@ -62,6 +63,7 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
geocoder
jekyll jekyll
jekyll-sass-converter! jekyll-sass-converter!

View File

@ -6,7 +6,7 @@ website: http://alpha.coop/
email: info@alpha.coop email: info@alpha.coop
twitter: alpha.coop twitter: alpha.coop
github: AlphaCo_op github: AlphaCo_op
telephone: '+441912111938' telephone: "+441912111938"
address: 6 Charlotte Square,Newcastle upon Tyne,United Kingdom,NE1 4XF address: 6 Charlotte Square,Newcastle upon Tyne,United Kingdom,NE1 4XF
latitude: 54.97101 latitude: 54.97101
longitude: -1.61974 longitude: -1.61974

View File

@ -8,8 +8,8 @@ twitter:
github: github:
telephone: '07908 592 835' telephone: '07908 592 835'
address: 44 Arkwright Road,London,NW3 6BH address: 44 Arkwright Road,London,NW3 6BH
latitude: latitude: 51.5509322
longitude: longitude: -0.1833781
clients: clients:
- labour-party - labour-party
- nesta - nesta

View File

@ -8,8 +8,8 @@ twitter: dtc-innovation
github: github:
telephone: 447455921569 telephone: 447455921569
address: London,United Kingdom address: London,United Kingdom
latitude: latitude: 51.5073219
longitude: longitude: -0.1276474
clients: clients:
- bbc - bbc
- data-gouv-fr - data-gouv-fr

View File

@ -8,8 +8,8 @@ twitter: index.html
github: github:
telephone: "+44 7793650013" telephone: "+44 7793650013"
address: Virtual address: Virtual
latitude: latitude: -26.9041798
longitude: longitude: -49.0924112
clients: clients:
services: services:
- branding-and-identity - branding-and-identity

View File

@ -8,8 +8,8 @@ twitter:
github: github:
telephone: telephone:
address: London address: London
latitude: latitude: 51.5073219
longitude: longitude: -0.1276474
clients: clients:
- creating-freedom - creating-freedom
- participatory-economics-uk - participatory-economics-uk

View File

@ -8,8 +8,8 @@ twitter:
github: github:
telephone: "+44 1484 846231" telephone: "+44 1484 846231"
address: Huddersfield address: Huddersfield
latitude: latitude: 53.6466645
longitude: longitude: -1.7822482
clients: clients:
services: services:
- business-analysis - business-analysis

View File

@ -8,8 +8,8 @@ twitter: weareopen
github: hello%40weareopen.html github: hello%40weareopen.html
telephone: N/A telephone: N/A
address: the Internet address: the Internet
latitude: latitude: 19.37218875
longitude: longitude: -72.3346544510523
clients: clients:
- creative-commons - creative-commons
- london-clc - london-clc

View File

@ -0,0 +1,21 @@
require 'bundler/setup'
require 'yaml'
require 'geocoder'
Geocoder.configure(lookup: :nominatim)
root_path = Pathname.new(__dir__).join('..')
Dir[root_path.join('_coops/*.md')].each do |path|
content = File.read(path)
body = content.split("\n").reverse.take_while { |l| l != "---" }.reverse.join("\n")
metadata = YAML.safe_load(content)
address = metadata['address']
latitude, longitude = Geocoder.coordinates(address, params: { region: 'uk' })
metadata['latitude'] ||= latitude
metadata['longitude'] ||= longitude
frontmatter = YAML.dump(metadata)
File.write(path, frontmatter + "---" + "\n" + body)
end