#!/bin/bash

for i in \
    azimuthalEqualArea \
    azimuthalEquidistant \
    conicConformal \
    conicEqualArea \
    conicEquidistant \
    equirectangular \
    gnomonic \
    mercator \
    naturalEarth1 \
    orthographic \
    stereographic \
    transverseMercator; do
  test/render-world $i > test/output/$i.png \
      && [ "$(gm compare -metric rmse img/$i.png test/output/$i.png 2>&1)" = "Image Difference (RootMeanSquaredError):
           Normalized    Absolute
          ============  ==========
     Red: 0.0000000000        0.0
   Green: 0.0000000000        0.0
    Blue: 0.0000000000        0.0
   Total: 0.0000000000        0.0" ] \
      && echo -e "\x1B[1;32m✓ $2\x1B[0mtest/output/$i.png" \
      && rm -f -- test/output/$i-difference.png \
      || (gm compare -type TrueColor -highlight-style assign -highlight-color red -file test/output/$i-difference.png test/output/$i.png img/$i.png; \
          echo -e "\x1B[1;31m✗ $2\x1B[0mtest/output/$i.png\n  test/output/$i-difference.png")
done

for i in \
    albers \
    albersUsa; do
  test/render-us $i > test/output/$i.png \
      && [ "$(gm compare -metric rmse img/$i.png test/output/$i.png 2>&1)" = "Image Difference (RootMeanSquaredError):
           Normalized    Absolute
          ============  ==========
     Red: 0.0000000000        0.0
   Green: 0.0000000000        0.0
    Blue: 0.0000000000        0.0
   Total: 0.0000000000        0.0" ] \
      && echo -e "\x1B[1;32m✓ $2\x1B[0mtest/output/$i.png" \
      && rm -f -- test/output/$i-difference.png \
      || (gm compare -type TrueColor -highlight-style assign -highlight-color red -file test/output/$i-difference.png test/output/$i.png img/$i.png; \
          echo -e "\x1B[1;31m✗ $2\x1B[0mtest/output/$i.png\n  test/output/$i-difference.png")
done
