#!/bin/bash

set -eu

FILES=$(python3 -m zipfile -l output.zip | awk '{print $1}' | rg '/.')

echo '<OGRVRTDataSource>'
echo '  <OGRVRTUnionLayer name="output">'

for f in $FILES
do
	NAME=${f%.geojson}
	NAME=${NAME#output/}
	echo -n '    <OGRVRTLayer name="'
	echo -n $NAME
	echo '">'
        echo -n '      <SrcDataSource>'
	echo -n /vsizip/output.zip/$f
	echo '</SrcDataSource>'
	echo '    </OGRVRTLayer>'
done

echo '  </OGRVRTUnionLayer>'
echo '</OGRVRTDataSource>'

