Skip to content

Commit

Permalink
download and transform has been converted from sh to js and updated t…
Browse files Browse the repository at this point in the history
…o latest version of @artsdatabanken/lastejobb
  • Loading branch information
Myrdrahl committed Mar 13, 2023
1 parent 0bd1fdc commit 93850d5
Show file tree
Hide file tree
Showing 13 changed files with 4,857 additions and 3,078 deletions.
7,839 changes: 4,796 additions & 3,043 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"main": "node_modules/lastejobb/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"download": "node node_modules/lastejobb/lastejobb stages/download",
"transform": "node node_modules/lastejobb/lastejobb stages/transform",
"download": "node node_modules/@artsdatabanken/lastejobb/lastejobb stages/download",
"transform": "node node_modules/@artsdatabanken/lastejobb/lastejobb stages/transform",
"build": "npm run download && npm run transform",
"deploy": "node node_modules/lastejobb/lastejobb stages/deploy"
},
Expand All @@ -16,6 +16,6 @@
"license": "ISC",
"repository": "https://github.com/Artsdatabanken/kommune-kart-lastejobb",
"dependencies": {
"lastejobb": "^3.8.3"
"@artsdatabanken/lastejobb": "^4.0.7"
}
}
2 changes: 1 addition & 1 deletion stages/download/01_download_kartverket_geometri.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { http, log } = require("lastejobb");
const { http, log } = require("@artsdatabanken/lastejobb");

const downloads = {
kommune:
Expand Down
2 changes: 1 addition & 1 deletion stages/transform/02_kartverket_decompress.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { archive } = require("lastejobb");
const { archive } = require("@artsdatabanken/lastejobb");

archive.unzip("kommune_geometri.zip");
archive.unzip("fylke_geometri.zip");
2 changes: 1 addition & 1 deletion stages/transform/03_filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { io, json } = require("lastejobb");
const { io, json } = require("@artsdatabanken/lastejobb");

map("Basisdata_0000_Norge_25833_Fylker_GeoJSON.geojson", "fylke");
map("Basisdata_0000_Norge_25833_Kommuner_GeoJSON.geojson", "kommune");
Expand Down
13 changes: 13 additions & 0 deletions stages/transform/04_simpler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { dops } = require("@artsdatabanken/lastejobb");

main();

function main(){
// start container / image
var n = dops.start_ogr_containerNImage(dops.create_container_name('simplify'));
//simplify fylke
dops.exec_docker(n, "ogr2ogr -nln polygons -f GeoJSON -simplify 1 /tmp/fylke_25833.geojson /tmp/fylke.geojson");
//simplify kommune
dops.exec_docker(n, "ogr2ogr -nln polygons -f GeoJSON -simplify 1 /tmp/kommune_25833.geojson /tmp/kommune.geojson");
dops.clean_container(n); // dispose of container when finished
}
10 changes: 0 additions & 10 deletions stages/transform/04_simpler.sh

This file was deleted.

22 changes: 15 additions & 7 deletions stages/transform/05_reproject.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
const execSync = require("child_process").execSync;
const { dops } = require("@artsdatabanken/lastejobb");

reproject("fylke_25833.geojson", "fylke_4326.geojson");
reproject("kommune_25833.geojson", "kommune_4326.geojson");
try{

var n = dops.start_ogr_containerNImage(dops.create_container_name('reproject'));

reproj_w_docker(n, "fylke_25833.geojson", "fylke_4326.geojson");
reproj_w_docker(n, "kommune_25833.geojson", "kommune_4326.geojson");
dops.clean_container(n);
}catch(e){
console.error(e);
console.error(e.stack);
}

function reproject(src, target, epsg = "EPSG:4326") {
execSync(
`ogr2ogr -nln polygons -f GeoJSON -t_srs ${epsg} temp/${target} temp/${src}`
);
function reproj_w_docker(dc_cont_name, src, target, epsg = "EPSG:25833"){
var cmd = `ogr2ogr -f GeoJSON -t_srs ${epsg} tmp/${target} tmp/${src}`
dops.exec_docker(dc_cont_name, cmd);
}
2 changes: 1 addition & 1 deletion stages/transform/06_meta_from_4326_projection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { geospatial, io } = require("lastejobb");
const { geospatial, io } = require("@artsdatabanken/lastejobb");

areal("fylke");
areal("kommune");
Expand Down
2 changes: 1 addition & 1 deletion stages/transform/06_meta_from_utm_projection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { geospatial, io, json } = require("lastejobb");
const { geospatial, io, json } = require("@artsdatabanken/lastejobb");

bbox("fylke");
bbox("kommune");
Expand Down
2 changes: 1 addition & 1 deletion stages/transform/10_output.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { io } = require("lastejobb");
const { io } = require("@artsdatabanken/lastejobb");

map("fylke_25833.geojson", "fylke_25833");
map("kommune_25833.geojson", "kommune_25833");
Expand Down
24 changes: 24 additions & 0 deletions stages/transform/20_punkt_oppslag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { dops } = require("@artsdatabanken/lastejobb");

main();

function main() {
console.log("punkt oppslag");
let srcFolder = 'build';
var n = dops.start_gdal(dops.create_container_name('punktOppslag'), srcFolder);
let cmd = `gdal_rasterize -a autorkode -tr 100 100 /tmp/kommune_25833.geojson /tmp/kommune.tif`
dops.exec_docker(n, cmd);
dops.clean_container(n);
}


/* from 20_punkt_oppslag.sh
#!/bin/bash
set -e
gdal_rasterize() {
echo gdal_rasterize $@
docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest gdal_rasterize $@
}
gdal_rasterize -a autorkode -tr 100 100 $PWD/build/kommune_25833.geojson $PWD/build/kommune.tif */
9 changes: 0 additions & 9 deletions stages/transform/20_punkt_oppslag.sh

This file was deleted.

0 comments on commit 93850d5

Please sign in to comment.