瀏覽代碼

Add coordinates: eastings/northings and lat/lon

master
Adrian Short 7 年之前
父節點
當前提交
dff3001403
共有 3 個檔案被更改,包括 13 行新增0 行删除
  1. +1
    -0
      Gemfile
  2. +2
    -0
      Gemfile.lock
  3. +10
    -0
      scraper.rb

+ 1
- 0
Gemfile 查看文件

@@ -8,3 +8,4 @@ source "https://rubygems.org"

gem "scraperwiki", git: "https://github.com/openaustralia/scraperwiki-ruby.git", branch: "morph_defaults"
gem "mechanize"
gem "breasal"

+ 2
- 0
Gemfile.lock 查看文件

@@ -10,6 +10,7 @@ GIT
GEM
remote: https://rubygems.org/
specs:
breasal (0.0.1)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
http-cookie (1.0.3)
@@ -45,6 +46,7 @@ PLATFORMS
ruby

DEPENDENCIES
breasal
mechanize
scraperwiki!



+ 10
- 0
scraper.rb 查看文件

@@ -5,6 +5,7 @@ require 'mechanize'
require 'pp'
require 'time'
require 'date'
require 'breasal'

# Use the column names from planningalerts.org.au:
# https://www.planningalerts.org.au/how_to_write_a_scraper
@@ -29,6 +30,15 @@ def parse(app)
record['comment_url'] = BASEURL + link['href'].strip if link['href'].match(/PlanningComments/)
end

if record['map_url']
matches = record['map_url'].match(/x=(\d+)&y=(\d+)/)
record['easting'] = matches[1].to_i
record['northing'] = matches[2].to_i
en = Breasal::EastingNorthing.new(easting: record['easting'], northing: record['northing'], type: :gb)
record['latitude']= en.to_wgs84[:latitude]
record['longitude'] = en.to_wgs84[:longitude]
end

spans = app.search("span")
record['description'] = spans[0].inner_text
record['address'] = spans[1].inner_text


Loading…
取消
儲存