Skip to content

Instantly share code, notes, and snippets.

@incanus
Created December 7, 2011 19:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save incanus/1444124 to your computer and use it in GitHub Desktop.
Save incanus/1444124 to your computer and use it in GitHub Desktop.
Shell script to get basic info from the metadata of an MBTiles file.
#!/bin/sh
if [ -z $1 ]; then
echo "Usage: $0 <filename.mbtiles>"
exit 1
fi
sqlite3 -line $1 'select * from metadata;' | sed -e 's/^\(.\{85\}\).*/\1.../' -e 's/^ name = /+++/' -e 's/value = //' | grep -v ^$ | sed -e 's/^\([^+++]\)/ \1/' -e 's/^+++//'
echo "size"
count=`sqlite3 -line $1 'select count(*) from tiles;' | awk '{ print $3 }'`
filesize=$((`stat -f %z $1` / 1024 / 1024))
echo " $count tiles ($filesize MB)"
echo "zooms"
minzoom=`sqlite3 -line $1 'select min(zoom_level) from tiles;' | awk '{ print $3 }'`
maxzoom=`sqlite3 -line $1 'select max(zoom_level) from tiles;' | awk '{ print $3 }'`
if [ minzoom != maxzoom ]; then
echo " $minzoom-$maxzoom"
else
echo " $minzoom"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment