Skip to content

Commit

Permalink
Top10-extract geschikt gemaakt voor werkwijze met args-bestanden
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteggink committed Jun 10, 2016
1 parent 3a5850d commit 55d31e6
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 76 deletions.
4 changes: 2 additions & 2 deletions top10nl/etl/conf/etl-top10nl-v1.2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ schema = {schema}
# The source input ZIP-file(s) from dir, producing 'records' with ZIP file name and inner file names
[input_zip_file]
class=inputs.fileinput.ZipFileInput
file_path = {gml_files}
file_path = {input_dir}
filename_pattern = *.[zZ][iI][pP]
name_filter=.*\.[gG][mM][lL]
name_filter=*.[gG][mM][lL]

# Filter to extract a ZIP file one by one to a temporary location
[extract_zip_file]
Expand Down
37 changes: 37 additions & 0 deletions top10nl/etl/etl-top10nl.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
:: ETL voor TOP10NL GML met gebruik Stetl.
::
:: Dit is een front-end/wrapper batch-script om uiteindelijk Stetl met een configuratie
:: (etl-top10nl-v1.2.cfg) en parameters (options\myoptions.args) aan te roepen. Dit script is
:: gebaseerd op het shell-script ../../brk/etl-brk.sh.
::
:: Author: Frank Steggink
@echo off

setlocal

:: Gebruik Stetl meegeleverd met NLExtract (kan in theorie ook Stetl via pip install stetl zijn)
if "%STETL_HOME%"=="" (
set STETL_HOME=../../externals/stetl
)

:: Nodig voor imports
if "%PYTHONPATH%"=="" (
set PYTHONPATH=%STETL_HOME%
) else (
set PYTHONPATH=%STETL_HOME%;%PYTHONPATH%
)

:: Default argumenten/opties
set options_file=options\default.args

:: Overrule eventueel het default optiebestand door het gebruik van een host-gebaseerd optiebestand
:: options\<hostnaam>.args.
if exist options\%COMPUTERNAME%.args set options_file=options\%COMPUTERNAME%.args

:: Evt via commandline overrulen: etl-top10nl.cmd <mijn optiebestand>
if not "%~1"=="" set options_file=%1

:: Uiteindelijke commando. Kan ook gewoon "stetl -c etl-top10nl-v1.2.cfg -a ..." worden indien Stetl installed
python %STETL_HOME%\stetl\main.py -c conf\etl-top10nl-v1.2.cfg -a %options_file%

endlocal
21 changes: 16 additions & 5 deletions top10nl/etl/etl-top10nl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
# ETL voor Top10NL GML met gebruik Stetl.
#
# Dit is een front-end/wrapper shell-script om uiteindelijk Stetl met een configuratie
# (etl-top10nl.cfg) en parameters (in options.sh) aan te roepen.
# (etl-top10nl.cfg) en parameters (options/myoptions.args) aan te roepen.
#
# Author: Just van den Broecke
#

. options.sh

# Gebruik Stetl meegeleverd met NLExtract (kan in theorie ook Stetl via pip install stetl zijn)
if [ -z "$STETL_HOME" ]; then
STETL_HOME=../../externals/stetl
Expand All @@ -22,5 +20,18 @@ else
export PYTHONPATH=$STETL_HOME:$PYTHONPATH
fi

# Uiteindelijke commando. Kan ook gewoon "stetl -c etl-top10nl.cfg -a ..." worden indien Stetl installed
python $STETL_HOME/stetl/main.py -c conf/etl-top10nl-v1.2.cfg -a "$pg_options temp_dir=temp max_features=$max_features gml_files=$gml_files $multi $spatial_extent"
# Default arguments/options
options_file=options/default.args

# Optionally overules default options file by using a host-based file options/<your hostname>.args
# To add your localhost add <your hostname>.args in options directory
host_options_file=options/`hostname`.args

[ -f "$host_options_file" ] && options_file=$host_options_file

# Evt via commandline overrulen: etl-top10nl.sh <my options file>
[ -f "$1" ] && options_file=$1

# Uiteindelijke commando. Kan ook gewoon "stetl -c conf/etl-top10nl-v1.2.cfg -a ..." worden indien Stetl installed
# python $STETL_HOME/stetl/main.py -c conf/etl-top10nl-v1.2.cfg -a "$pg_options temp_dir=temp max_features=$max_features gml_files=$gml_files $multi $spatial_extent"
python $STETL_HOME/stetl/main.py -c conf/etl-top10nl-v1.2.cfg -a $options_file
53 changes: 0 additions & 53 deletions top10nl/etl/options.sh

This file was deleted.

3 changes: 2 additions & 1 deletion top10nl/etl/options/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.sh
*.sh
*.args
42 changes: 42 additions & 0 deletions top10nl/etl/options/default.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Default options for the Stetl TOP10NL extract command
# These values are substituted into the ETL conf in conf/etl-top10nl-v1.2.cfg, see the {arg} strings there

# INPUT: gml files, point to directory or file(s) pattern
input_dir=test/v1_2/nlextract

# Files pattern: files filter volgens Python glob.glob patronen: https://docs.python.org/2/library/glob.html
# NB moeten op dit moment .zip files zijn!
zip_files_pattern=*.[zZ][iI][pP]

# Match files binnen zip-archieven, default is alle .gml files
# filename_match=[!bgt_plaatsbepalingspunt]* om bijv de plaatsbepalingspunten te excluden
filename_match=*.gml

# OPTIONS
# Temp dir voor GFS
temp_dir=temp

# GFS template: bepaalt mapping van GML-velden naar PostGIS table kolommen
gfs_template=gfs/top10-v1.2.gfs

# OUTPUT: PostGIS settings
host=localhost
port=5432
user=postgres
password=postgres
database=top10nl
schema=test

# OPTION: attribuut waarden bijv typeWeg die meerdere keren in XML voorkomen, wat daarmee te doen
# Zie ogr2ogr opties
# May use: these options
# multi_opts=-splitlistfields -maxsubfields 1
# multi_opts=-splitlistfields
multi_opts=-fieldTypeToString StringList

# Welk gebied (clip), zet leeg voor alles
# spatial_extent=120000 450000 160000 500000
spatial_extent=

# Maximaal aantal features
max_features=20000
15 changes: 0 additions & 15 deletions top10nl/etl/options/options-sunda.sh

This file was deleted.

0 comments on commit 55d31e6

Please sign in to comment.