]> git.openstreetmap.org Git - rails.git/blob - app/models/communities.rb
f318157ce4e1fc3eaef36908aaeae1c0437be834
[rails.git] / app / models / communities.rb
1
2 class Communities
3
4   def self.local_chapters
5     @local_chapters ||= self.load_local_chapters
6   end
7
8   protected
9
10   def self.load_local_chapters
11
12     json_file = File.expand_path("node_modules/osm-community-index/dist/completeFeatureCollection.json", Dir.pwd);
13     community_index = JSON.parse(File.read(json_file))
14
15     local_chapters = []
16     community_index['features'].each do |feature|
17       feature['properties']['resources'].each do |id, data|
18         data.each do |key, value|
19           if key == "type" and value == "osm-lc" and data['strings']['community']
20             local_chapters.push({ id: id, name: data['strings']['community'], url: data['strings']['url'] });
21           end
22         end
23       end
24     end
25
26     return local_chapters
27   end
28
29 end