Skip to content
Snippets Groups Projects
Commit 10898db6 authored by David Hoese's avatar David Hoese
Browse files

Merge branch 'feature-mapcache-overlays' into 'master'

Add remaining layers to mapcache

Closes #4

See merge request cspp_geo/cspp-geo-web-viewer!16
parents ed9afd2f 8bdb3b5e
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,8 @@ RUN ln -s /usr/local/bin/mapserv /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/*
RUN pip3 install jinja2
COPY render.py run.sh abi_l1b_template.map /work/
COPY mapfiles/ /work/mapfiles/
COPY html/ /var/www/html/
......@@ -103,4 +105,4 @@ RUN apache2ctl configtest
STOPSIGNAL WINCH
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-DFOREGROUND"]
CMD ["/work/run.sh"]
MAP
NAME "{{ platform_long_name }} ABI {{ sector_long_name }} L1b Layers"
STATUS ON
IMAGETYPE rgb
SIZE 256 256
EXTENT -5434894.885 -5434894.885 5434894.885 5434894.885
PROJECTION
"{{ projection }}"
END
WEB
METADATA
"wms_title" "CSPP Geo Geo2Grid Viewer"
"wms_onlineresource" "https://myhost/mapserv"
"wms_enable_request" "*"
END
END
INCLUDE '/work/mapfiles/output_formats.map'
{% for product in products %}
# {{ product.replace('_', ' ').title() }} #
LAYER
NAME "{{ product }}_index"
TYPE TILEINDEX
DATA "{{ layer_base_dir }}/{{ platform }}/abi/{{ sector }}/{{ product }}/{{ product }}"
END
LAYER
NAME "{{ product }}"
TYPE RASTER
TILEITEM "location"
TILEINDEX "{{ product }}_index"
# Comment below to default to transparency
#OFFSITE 0 0 0
PROJECTION
"{{ projection }}"
END
PROCESSING "RESAMPLE=AVERAGE"
METADATA
"wms_title" "{{ platform_long_name }} ABI {{ product.replace('_', ' ').title() }}"
"wms_extent" "-180 -90 180 90"
"wms_timeextent" "2017-01-01/2040-12-31"
"wms_timeformat" "YYYY-MM-DDTHH:MM:SS"
"wms_timeitem" "time" # time is a metadata item
"wms_timedefault" "2019-12-12T19:20:18"
"wms_enable_request" "*"
END
FILTER (`[time]` = `2019-12-12T19:20:18`)
END # goes raster layer ends here
{% endfor %}
END # end of map file
MAP
NAME "GOES-16 ABI Full Disk L1b Layers"
STATUS ON
IMAGETYPE rgba
SIZE 256 256
EXTENT -5434894.885 -5434894.885 5434894.885 5434894.885
#EXTENT -180 -90 180 90
PROJECTION
"init=epsg:930916"
END
WEB
METADATA
"wms_title" "CSPP Geo Geo2Grid Viewer"
"wms_onlineresource" "https://myhost/mapserv"
"wms_enable_request" "*"
END
END
INCLUDE '/work/mapfiles/output_formats.map'
##############
# True Color #
##############
LAYER
NAME "true_color_index"
TYPE TILEINDEX
DATA "/data/tiles/g16/abi/radf/true_color/true_color"
END
LAYER
NAME "true_color"
TYPE RASTER
TILEITEM "location"
TILEINDEX "true_color_index"
# Comment below to default to transparency
# OFFSITE 0 0 0
PROJECTION
"init=epsg:930916"
END
METADATA
"wms_title" "GOES-16 ABI True Color"
"wms_extent" "-180 -90 180 90"
"wms_timeextent" "2017-01-01/2020-12-31"
"wms_timeformat" "YYYY-MM-DDTHH:MM:SS"
"wms_timeitem" "time" # time is a metadata item
"wms_timedefault" "2019-12-12T19:20:18"
"wms_enable_request" "*"
END
FILTER (`[time]` = `2019-12-12T19:20:18`)
END # goes raster layer ends here
######################
# True Color Lat/Lon #
######################
LAYER
NAME "true_color_index_ll"
TYPE TILEINDEX
DATA "/data/tiles/g16/abi/radf_ll/true_color_ll/true_color_ll"
END
LAYER
NAME "true_color_ll"
TYPE RASTER
TILEITEM "location"
TILEINDEX "true_color_index_ll"
# Comment below to default to transparency
# OFFSITE 0 0 0
PROJECTION
"init=epsg:4326"
END
METADATA
"wms_title" "GOES-16 ABI True Color"
"wms_extent" "-180 -90 180 90"
"wms_timeextent" "2017-01-01/2020-12-31"
"wms_timeformat" "YYYY-MM-DDTHH:MM:SS"
"wms_timeitem" "time" # time is a metadata item
"wms_timedefault" "2019-12-12T19:20:18"
"wms_enable_request" "*"
END
FILTER (`[time]` = `2019-12-12T19:20:18`)
END # goes raster layer ends here
###################
# True Color Fake #
###################
LAYER
NAME "true_color_test"
TYPE RASTER
TILEITEM "location"
TILEINDEX "true_color_index"
# Comment below to default to transparency
# OFFSITE 0 0 0
PROJECTION
"init=epsg:930916"
END
METADATA
"wms_title" "GOES-16 ABI True Color"
"wms_extent" "-180 -90 180 90"
"wms_timeextent" "2017-01-01/2020-12-31"
"wms_timeformat" "YYYY-MM-DDTHH:MM:SS"
"wms_timeitem" "time" # time is a metadata item
"wms_timedefault" "2019-12-12T19:20:18"
"wms_enable_request" "*"
END
FILTER (`[time]` = `2019-12-12T19:20:18`)
END # goes raster layer ends here
END # end of map file
......@@ -13,8 +13,8 @@
NAME "rgb"
DRIVER AGG/PNG
MIMETYPE "image/png"
IMAGEMODE RGBA
TRANSPARENT ON
IMAGEMODE RGB
TRANSPARENT OFF
EXTENSION "png"
END
......
......@@ -4,7 +4,7 @@ MAP
MAXSIZE 5000
SIZE 1024 1024
IMAGECOLOR 128 128 128
IMAGETYPE rgb
IMAGETYPE rgba
EXTENT -5434894.885 -5434894.885 5434894.885 5434894.885
FONTSET "/work/mapfiles/fonts.list"
......
#!/usr/bin/env python3
"""Convert a template mapfile config to a full config.
We do this rendering when the container is started to allow for complete
control per mapserver instance (even though there is usually only one).
"""
import os
import sys
import jinja2
sectors = "radm1 radm2 radc radf"
sectors = os.getenv("WMS_SECTORS", sectors).split(" ")
products = ["C{:02d}".format(x) for x in range(1, 17)] + ["true_color"]
products = os.getenv("WMS_PRODUCTS", " ".join(products)).split(" ")
platforms = "g16 g17"
platforms = os.getenv("WMS_PLATFORMS", platforms).split(" ")
layer_base_dir = os.environ['LAYER_BASE_DIR']
SECTOR_LONG_NAMES = {
'radm1': 'Mesoscale 1',
'radm2': 'Mesoscale 2',
'radc': 'CONUS',
'radf': 'Full disk',
}
PLATFORM_LONG_NAMES = {
'g16': 'GOES-16',
'g17': 'GOES-17',
}
PLATFORM_EPSGS = {
'g16': 'EPSG:930916',
'g17': 'EPSG:930917',
}
PLATFORM_POS_NAMES = {
'g16': 'GOES-EAST',
'g17': 'GOES-WEST',
}
LAYER_TO_FORMAT = {
'C01': 'gray',
'true_color': 'rgba'
}
def main():
import argparse
parser = argparse.ArgumentParser(description="Render mapfile template to complete mapfile config.")
parser.add_argument("template_fn",
help="Template XML file to render")
parser.add_argument('output_pattern',
help='Format string for each output mapfiles.')
args = parser.parse_args()
for platform in platforms:
for sector in sectors:
tmpl_vars = {
'sector': sector,
'platform': platform,
'products': products,
'layer_base_dir': layer_base_dir,
'platform_long_name': PLATFORM_LONG_NAMES[platform],
'sector_long_name': SECTOR_LONG_NAMES[sector],
'projection': "init=" + PLATFORM_EPSGS[platform].lower(),
'PLATFORM_EPSGS': PLATFORM_EPSGS,
'PLATFORM_POS_NAMES': PLATFORM_POS_NAMES,
}
output_fn = args.output_pattern.format(**tmpl_vars)
with open(args.template_fn, 'r') as tmpl_file, open(output_fn, 'w') as mapfile:
template = jinja2.Template(tmpl_file.read())
mapfile.write(template.render(tmpl_vars))
if __name__ == "__main__":
sys.exit(main())
\ No newline at end of file
#!/bin/bash -le
# Load environment variable options to overwrite in the config
export LAYER_BASE_DIR=${LAYER_BASE_DIR:-"/data/tiles"}
# Update the mapcache.xml file with the real host and port name
mf_tmpl="/work/abi_l1b_template.map"
export WMS_PLATFORMS=${WMS_PLATFORMS:-"g16 g17"}
export WMS_SECTORS=${WMS_SECTORS:-"radm1 radm2 radc radf"}
python3 /work/render.py $mf_tmpl "/work/mapfiles/{platform}_abi_{sector}_l1b.map"
/usr/sbin/apache2ctl configtest
/usr/sbin/apache2ctl -DFOREGROUND
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment