class DataAnon::Utils::GeojsonParser

Public Class Methods

address(file_path) click to toggle source
# File lib/utils/geojson_parser.rb, line 8
def self.address file_path
  self.new(file_path).parse 'address'
end
city(file_path) click to toggle source
# File lib/utils/geojson_parser.rb, line 20
def self.city file_path
  self.new(file_path).parse 'city'
end
country(file_path) click to toggle source
# File lib/utils/geojson_parser.rb, line 24
def self.country file_path
  self.new(file_path).parse 'country'
end
new(file_path) click to toggle source
# File lib/utils/geojson_parser.rb, line 28
def initialize file_path
  @places = File.read(file_path).split(/\n/)
end
province(file_path) click to toggle source
# File lib/utils/geojson_parser.rb, line 16
def self.province file_path
  self.new(file_path).parse 'province'
end
zipcode(file_path) click to toggle source
# File lib/utils/geojson_parser.rb, line 12
def self.zipcode file_path
  self.new(file_path).parse 'postcode'
end

Public Instance Methods

parse(property) click to toggle source
# File lib/utils/geojson_parser.rb, line 32
def parse property
  result_list = []
  @places.each do |loc|
    geom = RGeo::GeoJSON.decode(loc, :json_parser => :json)
    result_list.push(geom[property])
  end
  result_list
end