From 3c80693d67dbc9a0e193ed7607fea844ffd3ff94 Mon Sep 17 00:00:00 2001 From: James Mead <3169+floehopper@users.noreply.github.com> Date: Fri, 30 Nov 2018 16:56:07 +0000 Subject: [PATCH] Geocode Coop addresses to lat & long for map --- Gemfile | 2 ++ Gemfile.lock | 2 ++ _coops/alpha-communication.md | 4 ++-- _coops/cetis-llp.md | 2 +- _coops/digital-liberties.md | 4 ++-- _coops/dtc-innovation.md | 4 ++-- _coops/gildedsplinters.md | 4 ++-- _coops/glowbox-design.md | 4 ++-- _coops/mc3.md | 4 ++-- _coops/wave.md | 2 +- _coops/we-are-open.md | 4 ++-- scripts/geocode_coop_addresses.rb | 21 +++++++++++++++++++++ 12 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 scripts/geocode_coop_addresses.rb diff --git a/Gemfile b/Gemfile index caeca37..f5da1e6 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index cce78c0..eed73b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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! diff --git a/_coops/alpha-communication.md b/_coops/alpha-communication.md index d02bc1a..bc3f530 100644 --- a/_coops/alpha-communication.md +++ b/_coops/alpha-communication.md @@ -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 @@ -43,4 +43,4 @@ We deliver on time and within budget. KNOWING After 30 years, we know what we’re doing. -We help you engage with the people you need to reach. +We help you engage with the people you need to reach. \ No newline at end of file diff --git a/_coops/cetis-llp.md b/_coops/cetis-llp.md index 798fd5e..9b3d24b 100644 --- a/_coops/cetis-llp.md +++ b/_coops/cetis-llp.md @@ -25,4 +25,4 @@ technologies: Cetis is a cooperative Limited Liability Partnership and an independent Strategic IT consultancy, specialising in learning, education and training. -We offer impartial strategic and technical advice and guidance in educational technology and process innovation, and we provide discovery services, technology solutions and training services. Our Partners and Associates are globally recognised as leading experts on educational technology innovation, interoperability and technology standards. Cetis LLP was established in 2015 by members of the Jisc Innovation Centres Cetis and OSS Watch. As the Centre for Educational Technology, Interoperability and Standards, Cetis has provided, for nearly two decades, impartial, strategic, technical and pedagogical advice on educational technology innovation, collaboration and standards to funding bodies, standards agencies, government, international organisations, institutions and commercial partners. +We offer impartial strategic and technical advice and guidance in educational technology and process innovation, and we provide discovery services, technology solutions and training services. Our Partners and Associates are globally recognised as leading experts on educational technology innovation, interoperability and technology standards. Cetis LLP was established in 2015 by members of the Jisc Innovation Centres Cetis and OSS Watch. As the Centre for Educational Technology, Interoperability and Standards, Cetis has provided, for nearly two decades, impartial, strategic, technical and pedagogical advice on educational technology innovation, collaboration and standards to funding bodies, standards agencies, government, international organisations, institutions and commercial partners. \ No newline at end of file diff --git a/_coops/digital-liberties.md b/_coops/digital-liberties.md index 6367c67..5b0423c 100644 --- a/_coops/digital-liberties.md +++ b/_coops/digital-liberties.md @@ -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 diff --git a/_coops/dtc-innovation.md b/_coops/dtc-innovation.md index 199333e..cbf08ec 100644 --- a/_coops/dtc-innovation.md +++ b/_coops/dtc-innovation.md @@ -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 diff --git a/_coops/gildedsplinters.md b/_coops/gildedsplinters.md index fd1ff12..3ad9163 100644 --- a/_coops/gildedsplinters.md +++ b/_coops/gildedsplinters.md @@ -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 diff --git a/_coops/glowbox-design.md b/_coops/glowbox-design.md index 4ef7a22..be07d5b 100644 --- a/_coops/glowbox-design.md +++ b/_coops/glowbox-design.md @@ -8,8 +8,8 @@ twitter: github: telephone: address: London -latitude: -longitude: +latitude: 51.5073219 +longitude: -0.1276474 clients: - creating-freedom - participatory-economics-uk diff --git a/_coops/mc3.md b/_coops/mc3.md index db080a5..2563d04 100644 --- a/_coops/mc3.md +++ b/_coops/mc3.md @@ -8,8 +8,8 @@ twitter: github: telephone: "+44 1484 846231" address: Huddersfield -latitude: -longitude: +latitude: 53.6466645 +longitude: -1.7822482 clients: services: - business-analysis diff --git a/_coops/wave.md b/_coops/wave.md index c2a110a..d539798 100644 --- a/_coops/wave.md +++ b/_coops/wave.md @@ -80,4 +80,4 @@ We are a design co-operative specialising in creative print and web design for t Our services range from brand and identity development, campaign material, print publications and exhibitions to photography, illustration, web design and development, animation, interactive applications and games! -Please see case studies for some **recent work**. +Please see case studies for some **recent work**. \ No newline at end of file diff --git a/_coops/we-are-open.md b/_coops/we-are-open.md index 84b7b93..b7ccbaa 100644 --- a/_coops/we-are-open.md +++ b/_coops/we-are-open.md @@ -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 diff --git a/scripts/geocode_coop_addresses.rb b/scripts/geocode_coop_addresses.rb new file mode 100644 index 0000000..9fd0036 --- /dev/null +++ b/scripts/geocode_coop_addresses.rb @@ -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