From 5f4fc15c253247acac1965a46b1392c171e1af7b Mon Sep 17 00:00:00 2001 From: David Hoese <david.hoese@ssec.wisc.edu> Date: Tue, 21 Jan 2020 10:24:00 -0600 Subject: [PATCH] Add basic layer_times CGI script as workaround for no time information --- mapserver/Dockerfile | 5 +++-- mapserver/cgi-bin/layer_times.py | 13 +++++++++++++ mapserver/site-conf | 6 ++++++ tile_gen/README.md | 15 +++++++++++++++ tile_gen/run.sh | 6 +++++- 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100755 mapserver/cgi-bin/layer_times.py diff --git a/mapserver/Dockerfile b/mapserver/Dockerfile index 60192ff..855decd 100644 --- a/mapserver/Dockerfile +++ b/mapserver/Dockerfile @@ -50,11 +50,12 @@ RUN cd /build_deps && apt-get -y install apache2 libapache2-mod-fcgid && \ COPY site-conf /etc/apache2/sites-available/cspp_geo.conf # disable the default which would conflict with our custom RUN a2ensite cspp_geo && a2dissite 000-default +COPY cgi-bin/* /usr/lib/cgi-bin/ # Point apache to the mapserver binary RUN ln -s /usr/local/bin/mapserv /usr/lib/cgi-bin/mapserv && \ - chown ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /usr/lib/cgi-bin/mapserv && \ - chown -h ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /usr/lib/cgi-bin/mapserv + chown ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /usr/lib/cgi-bin/* && \ + chown -h ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /usr/lib/cgi-bin/* COPY mapfiles/ /work/mapfiles/ COPY html/ /var/www/html/ diff --git a/mapserver/cgi-bin/layer_times.py b/mapserver/cgi-bin/layer_times.py new file mode 100755 index 0000000..68f0757 --- /dev/null +++ b/mapserver/cgi-bin/layer_times.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import cgi +import json +import fiona + +form = cgi.FieldStorage() +layer = form['layer'].value +with fiona.open(layer, 'r') as shp_file: + times = [x['properties']['time'] for x in shp_file] + +print("Content-Type: application/json") +print() # blank line, end of headers +print(json.dumps(times)) diff --git a/mapserver/site-conf b/mapserver/site-conf index dbc6922..0c812d2 100644 --- a/mapserver/site-conf +++ b/mapserver/site-conf @@ -30,7 +30,13 @@ # Custom CSPP Geo # LoadModule rewrite_module modules/mod_rewrite.so RewriteEngine on + # /wms/goes16/abi/fldk/ RewriteRule "^/wms/([^/]+)/([^/]+)/([^/]+)/l1b?(.*)" "/cgi-bin/mapserv?map=/work/mapfiles/$1_$2_$3_l1b.map&$4" [PT,QSA] + # /wms_times/g16/abi/radf/true_color + RewriteRule "^/wms_times/([^/]+)/([^/]+)/([^/]+)/([^/]+)" "/cgi-bin/layer_times.py?layer=/data/tiles/$1/$2/$3/$4/$4.shp" [PT,QSA] + # FIXME: We need to include the sector + # /data/goes/grb/goes16/2020/2020_01_21_021/abi/L1b/RadF/GOES-16_ABI_RadF_C01_20200121_000016_GOES-East.tif + # "/data/tiles/g16/abi/radf/true_color/true_color" LogLevel alert rewrite:trace6 </VirtualHost> diff --git a/tile_gen/README.md b/tile_gen/README.md index 6c06158..f8534ce 100644 --- a/tile_gen/README.md +++ b/tile_gen/README.md @@ -12,3 +12,18 @@ docker push gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-web-viewer/tile_gen:late ```bash docker run -d --rm --network cspp-geo-rabbit --cpus 2 --name cspp-geo-tilegen-g16-radf -e AMQPFIND_TOPIC="data.goes.g16.abi.radf.l1b.geotiff.complete" -v cspp-geo-abi-l1b-geotiffs:/data gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-web-viewer/tile_gen:latest ``` + +To run the version of tile generation that remaps to EPSG:4326: + +```bash +docker run -d --rm --network cspp-geo-rabbit --cpus 6 --name cspp-geo-tilegen-g16-radf-ll -e AMQPFIND_TOPIC="data.goes.g16.abi.radf.l1b.geotiff.complete" -e TILE_ARGS="--remap --shape-file {product}_LL.shp" -v cspp-geo-abi-l1b-geotiffs:/data gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-web-viewer/tile_gen:latest ./run.sh +``` + +NOTE: For full disk the above can take a really long time and fall behind. +It may be best to limit this to one or two products for testing by adding: + +``` +-e G2G_PRODUCTS="true_color" +``` + +And adding more CPUs. \ No newline at end of file diff --git a/tile_gen/run.sh b/tile_gen/run.sh index 051058d..2b27502 100755 --- a/tile_gen/run.sh +++ b/tile_gen/run.sh @@ -48,7 +48,11 @@ run_tile_gen() { # and resample geotiff if necessary # FUTURE: TileDB will be updated in-place # generate_tiles.py will make a temporary directory - out_dir="${dst_dir}/tiles/${satellite_family}/${satellite_id}/${instrument}" + out_dir="${dst_dir}/tiles/${satellite_id}/${instrument}/${data_type}" + # if we are going to remap, separate the geotiffs and shapefile from unremapped + if [[ ${TILE_ARGS} == *"--remap" ]]; then + out_dir="${out_dir}_ll" + fi mkdir -p ${out_dir} # add string formatting portion to separate add 'product' sub-directory out_dir="${out_dir}/{product}" -- GitLab