5
0
mirror of https://git.coop/cotech/website.git synced 2024-11-21 22:33:05 +00:00

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
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)
ffi (1.9.25)
forwardable-extended (2.6.0)
geocoder (1.5.0)
http_parser.rb (0.6.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
@ -62,6 +63,7 @@ PLATFORMS
ruby
DEPENDENCIES
geocoder
jekyll
jekyll-sass-converter!

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,8 +8,8 @@ twitter: weareopen
github: hello%40weareopen.html
telephone: N/A
address: the Internet
latitude:
longitude:
latitude: 19.37218875
longitude: -72.3346544510523
clients:
- creative-commons
- 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