Skip to content

Commit

Permalink
GITC-3042 Added option for overwriting colormap, updated mrfgen tests…
Browse files Browse the repository at this point in the history
…, readme
  • Loading branch information
Matthew Graber committed Sep 25, 2023
1 parent b31aa48 commit 99fc378
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/mrfgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ Directory paths may be different than the example. Directories that do not exist
* mrf_blocksize: The MRF tile size. All tiles are square.
* mrf_compression_type: The internal image of the MRF. Valid values are JPEG, PNG (for RGBA PNGs), PPNG (for 256 color paletted PNGs), EPNG (for encoded PNGs, requires [overtiffpacker.py](overtiffpacker.py)), JPNG (for blended JPEG/PNG MRF), TIFF, or [LERC](https://github.com/Esri/lerc).
* target_x: The full x output size of the MRF image. target_y is calculated to maintain native aspect ratio if not defined in ```<target_y>```. ```<outsize>``` may be used to specify both x and y output size as one parameter.
* mrf_merge: (true/false) Whether overlapping input images should be merged on a last-in basis when performing inserts. Defaults to "false" for faster performance.
* mrf_noaddo: (true/false) Don't run gdaladdo if UNIFORM_SCALE has been set. Defaults to "false".
* mrf_clean: (true/false) run mrf_clean.py script on generated mrf file to reduce file size
* mrf_parallel: (true/false) run mrf_insert calls in parallel to improve performance. See num_cores.
* num_cores: (int) number of cores to use with mrf_parallel. Recommended is 2-4, depending on number of input files.
* mrf_strict_palette: (true/false) Validate that the colors in input files match the MRF colormap. A warning is sent if there are mismatches. Defaults to "false".

These parameters are available but not used in the example above nor necessarily required.

Expand All @@ -123,6 +117,13 @@ These parameters are available but not used in the example above nor necessarily
* email_server: The SMTP server where email notifications are sent from.
* email_recipient: The recipient address(es) for email notifications. Use semi-colon ";" to separate recipients.
* email_sender: The sender address for email notifications.
* mrf_merge: (true/false) Whether overlapping input images should be merged on a last-in basis when performing inserts. Defaults to "false" for faster performance.
* mrf_noaddo: (true/false) Don't run gdaladdo if UNIFORM_SCALE has been set. Defaults to "false".
* mrf_clean: (true/false) run mrf_clean.py script on generated mrf file to reduce file size
* mrf_parallel: (true/false) run mrf_insert calls in parallel to improve performance. See num_cores.
* num_cores: (int) number of cores to use with mrf_parallel. Recommended is 2-4, depending on number of input files.
* mrf_strict_palette: (true/false) Validate that the colors in input files match the MRF colormap. A warning is sent if there are mismatches. Defaults to "false".
* mrf_overwrite_colormap: (true/false) Overwrite the image palette using the GIBS colormap file specified with the "colormap" option. Defaults to "false".

Let's modify the previous sample configuration to reproject the imagery into Web Mercator (EPSG:3857), generate a larger output size, and utilize a colormap:

Expand Down
15 changes: 12 additions & 3 deletions src/mrfgen/mrfgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,14 @@ def log_sig_err(mssg, sigevent_url, count_err=True):
strict_palette = True
except:
strict_palette = False
# overwrite_colormap, defaults to False
try:
if get_dom_tag_value(dom, 'mrf_overwrite_colormap') == "false":
overwrite_colormap = False
else:
overwrite_colormap = True
except:
overwrite_colormap = False
# mrf data
try:
mrf_data_scale = get_dom_tag_value(dom, 'mrf_data_scale')
Expand Down Expand Up @@ -1674,6 +1682,7 @@ def log_sig_err(mssg, sigevent_url, count_err=True):
log_info_mssg(str().join(['config mrf_clean: ', str(mrf_clean)]))
log_info_mssg(str().join(['config mrf_maxsize: ', str(mrf_maxsize)]))
log_info_mssg(str().join(['config mrf_strict_palette: ', str(strict_palette)]))
log_info_mssg(str().join(['config mrf_overwrite_colormap: ', str(overwrite_colormap)]))
log_info_mssg(str().join(['config mrf_z_levels: ', zlevels]))
log_info_mssg(str().join(['config mrf_z_key: ', zkey]))
log_info_mssg(str().join(['config mrf_data_scale: ', mrf_data_scale]))
Expand Down Expand Up @@ -2460,9 +2469,9 @@ def get_extension(compression_type):
mssg='Unrecognized compression type for MRF.'
log_sig_exit('ERROR', mssg, sigevent_url)

# Insert color map into VRT if provided
# TODO This could be problematic if we're overwriting with a different palette than what is in the imagery.
if colormap != '':
# Insert colormap into VRT if a colormap is provided and colormap overwriting is enabled.
# This could be problematic if we're overwriting with a different palette than what is in the imagery.
if overwrite_colormap and colormap != '':
new_vrt_filename = vrt_filename.replace('.vrt','_newcolormap.vrt')
colormap2vrt_command_list=[script_dir+'colormap2vrt.py','--colormap',colormap,'--output',new_vrt_filename,'--merge',vrt_filename]
if add_transparency == True:
Expand Down
1 change: 1 addition & 0 deletions src/test/mrfgen_files/mrfgen_test_config4a.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ limitations under the License.
<mrf_nocopy>true</mrf_nocopy>
<mrf_merge>true</mrf_merge>
<mrf_z_levels>3</mrf_z_levels>
<mrf_overwrite_colormap>true</mrf_overwrite_colormap>
</mrfgen_configuration>
1 change: 1 addition & 0 deletions src/test/mrfgen_files/mrfgen_test_config4b.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ limitations under the License.
<mrf_name>{$parameter_name}%Y%j_.mrf</mrf_name>
<mrf_nocopy>true</mrf_nocopy>
<mrf_merge>true</mrf_merge>
<mrf_overwrite_colormap>true</mrf_overwrite_colormap>
<mrf_z_levels>3</mrf_z_levels>
<mrf_z_key type="string">20151202</mrf_z_key>
</mrfgen_configuration>
1 change: 1 addition & 0 deletions src/test/mrfgen_files/mrfgen_test_config4c.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ limitations under the License.
<mrf_name>{$parameter_name}%Y%j_.mrf</mrf_name>
<mrf_nocopy>true</mrf_nocopy>
<mrf_merge>true</mrf_merge>
<mrf_overwrite_colormap>true</mrf_overwrite_colormap>
<mrf_z_levels>3</mrf_z_levels>
<mrf_z_key type="string">20151202100000</mrf_z_key>
</mrfgen_configuration>
1 change: 1 addition & 0 deletions src/test/mrfgen_files/mrfgen_test_config4d.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ limitations under the License.
<mrf_name>{$parameter_name}%Y%j_.mrf</mrf_name>
<mrf_nocopy>true</mrf_nocopy>
<mrf_merge>true</mrf_merge>
<mrf_overwrite_colormap>true</mrf_overwrite_colormap>
<mrf_z_levels>3</mrf_z_levels>
<mrf_z_key type="string">20151202200000</mrf_z_key>
</mrfgen_configuration>
Binary file modified src/test/mrfgen_files/test_comp13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/test/mrfgen_files/test_comp5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/test/mrfgen_files/test_comp7a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 99fc378

Please sign in to comment.