diff --git a/bin/au-dee-npi.awk b/bin/au-dee-npi.awk new file mode 100755 index 0000000..dec11cd --- /dev/null +++ b/bin/au-dee-npi.awk @@ -0,0 +1,16 @@ +# cat file.csv| ./au-dee-npi.awk | mongoimport -d "fuegos" -c "industries" + +gawk -F',' 'NR>1 { \ + gsub(/"/,"",$5); + gsub(/"/,"",$6); + gsub(/\t/,"",$13); + gsub(/\t/,"",$14); + gsub(/\x1a/,"",$13); + gsub(/\x1a/,"",$14); + lon = $14+0; + lat = $13+0; + name= $5", "$6 + gsub(/^, /,"",name); + if (lon != 0 && lat != 0 && lon > -180 && lon < 180 && lat >= -90 && lat <= 90) + printf("{name:\"%s\",geo:{type:\"Point\",coordinates:[%s,%s]},registry:\"4\"}\n" \ + ,name,lon,lat)}' diff --git a/bin/ca-godp-npri.awk b/bin/ca-godp-npri.awk new file mode 100755 index 0000000..e618ec6 --- /dev/null +++ b/bin/ca-godp-npri.awk @@ -0,0 +1,19 @@ +# cat file.csv| ./ca-godp-npri.awk | uniq | mongoimport -d "fuegos" -c "industries" + +gawk -F',' 'NR>1 { \ + gsub(/"/,"",$3); + gsub(/"/,"",$4); + gsub(/\t/,"",$3); + gsub(/\t/,"",$4); + gsub(/\x1a/,"",$3); + gsub(/\x1a/,"",$4); + lon = $16+0; + lat = $15+0; + if ($3 != $4) + name= $3", "$4 + else + name=$3 + gsub(/^, /,"",name); + # if (lon != 0 && lat != 0 && lon > -180 && lon < 180 && lat >= -90 && lat <= 90) + printf("{name:\"%s\",geo:{type:\"Point\",coordinates:[%s,%s]},registry:\"3\"}\n" \ + ,name,lon,lat)}' diff --git a/imports/api/Industries/Industries.js b/imports/api/Industries/Industries.js index d6aba72..dd1fde0 100644 --- a/imports/api/Industries/Industries.js +++ b/imports/api/Industries/Industries.js @@ -6,10 +6,25 @@ import LocationSchema from '/imports/api/Utility/LocationSchema.js'; const Industries = new Mongo.Collection('industries'); +// https://prtr.unece.org/prtr-global-map // For now using: + +// AUSTRALIA +// https://data.gov.au/dataset/npi# +// +// EUROPE // https://www.eea.europa.eu/data-and-maps/data/member-states-reporting-art-7-under-the-european-pollutant-release-and-transfer-register-e-prtr-regulation-16 +// +// CANADA +// https://www.canada.ca/en/environment-climate-change/services/national-pollutant-release-inventory/tools-resources-data/access.html +// +// USA // https://www.epa.gov/enviro/epa-frs-facilities-state-single-file-csv-download +// TODO: +// http://www.nite.go.jp/ +// http://www.retc.cl/datos-retc/ + Industries.allow({ insert: () => false, update: () => false, diff --git a/imports/startup/server/migrations.js b/imports/startup/server/migrations.js index 3f77de7..8605bd0 100644 --- a/imports/startup/server/migrations.js +++ b/imports/startup/server/migrations.js @@ -145,6 +145,19 @@ Meteor.startup(() => { } }); + Migrations.add({ + version: 10, + up: function siteSettingsAddIndex() { + IndustryRegistries.insert({ + _id: '3', name: 'NPRI', agency: 'GCODP', region: 'Canada' + }); + IndustryRegistries.insert({ + _id: '4', name: 'NPI', agency: 'DEE', region: 'Australia' + }); + } + }); + + // Set createdAt in users & subs Migrations.migrateTo('latest');