add osm-community-index and parse in communities
This commit is contained in:
parent
26aecfb2bf
commit
59e6cdebdc
3 changed files with 42 additions and 2 deletions
|
@ -1,9 +1,36 @@
|
|||
|
||||
|
||||
# require 'sprockets/railtie'
|
||||
|
||||
class Communities
|
||||
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
|
||||
def self.local_chapters
|
||||
array_string_ = ["Local Chapter 1", "Local Chapter 2", "Local Chapter 3", "Another one", "And Another"]
|
||||
self.load_local_chapters
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def self.load_local_chapters
|
||||
puts Dir.pwd
|
||||
json_file = File.expand_path("node_modules/osm-community-index/dist/completeFeatureCollection.json", Dir.pwd);
|
||||
# json_file = File.expand_path("./node_modules/osm-community-index", Dir.pwd);
|
||||
|
||||
path = File.exist?(json_file) # Dir.pwd # File.open(json_file, "r")
|
||||
community_index = JSON.parse(File.read(json_file))
|
||||
|
||||
array_of_entries = []
|
||||
community_index['features'].each do |feature|
|
||||
feature['properties']['resources'].each do |id, data|
|
||||
data.each do |key, value|
|
||||
if key == "type" and value == "osm-lc"
|
||||
array_of_entries.push(id);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return array_of_entries
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue