add osm-community-index and parse in communities

This commit is contained in:
Adam Hoyle 2021-08-11 23:45:44 +01:00
parent 26aecfb2bf
commit 59e6cdebdc
3 changed files with 42 additions and 2 deletions

View file

@ -1,9 +1,36 @@
# require 'sprockets/railtie'
class Communities class Communities
# include Sprockets::Helpers::RailsHelper
def self.local_chapters def self.local_chapters
array_string_ = ["Local Chapter 1", "Local Chapter 2", "Local Chapter 3", "Another one", "And Another"] self.load_local_chapters
end 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 end

View file

@ -8,6 +8,7 @@
"js-cookie": "^3.0.0", "js-cookie": "^3.0.0",
"leaflet": "^1.6.0", "leaflet": "^1.6.0",
"leaflet.locatecontrol": "^0.74.0", "leaflet.locatecontrol": "^0.74.0",
"osm-community-index": "^5.1.2",
"qs": "^6.9.4" "qs": "^6.9.4"
}, },
"devDependencies": { "devDependencies": {

View file

@ -229,6 +229,11 @@ deep-is@^0.1.3:
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
diacritics@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/diacritics/-/diacritics-1.3.0.tgz#3efa87323ebb863e6696cebb0082d48ff3d6f7a1"
integrity sha1-PvqHMj67hj5mls67AILUj/PW96E=
doctrine@^3.0.0: doctrine@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961"
@ -654,6 +659,13 @@ optionator@^0.9.1:
type-check "^0.4.0" type-check "^0.4.0"
word-wrap "^1.2.3" word-wrap "^1.2.3"
osm-community-index@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/osm-community-index/-/osm-community-index-5.1.2.tgz#dbae073ce3f10177bfc1749623b632e62b12eeaf"
integrity sha512-4kYj81tFZZwDBYY1Kl+JyACNuwYPBqNrwlmxWEK7+tFCqmIg/pYBKzSDP1M5z+NuNfyuAtLR4opwN3dpCUI/uQ==
dependencies:
diacritics "^1.3.0"
parent-module@^1.0.0: parent-module@^1.0.0:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"