[GRASS-SVN] r60362 - grass-addons/grass6/raster/r.out.mbtiles_prep

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 19 21:59:03 PDT 2014


Author: hamish
Date: 2014-05-19 21:59:03 -0700 (Mon, 19 May 2014)
New Revision: 60362

Modified:
   grass-addons/grass6/raster/r.out.mbtiles_prep/r.out.mbtiles_prep
Log:
sorting the names is much more efficient than sorting the data, check if tar is installed, comment out redundant instructions

Modified: grass-addons/grass6/raster/r.out.mbtiles_prep/r.out.mbtiles_prep
===================================================================
--- grass-addons/grass6/raster/r.out.mbtiles_prep/r.out.mbtiles_prep	2014-05-20 03:36:58 UTC (rev 60361)
+++ grass-addons/grass6/raster/r.out.mbtiles_prep/r.out.mbtiles_prep	2014-05-20 04:59:03 UTC (rev 60362)
@@ -508,26 +508,21 @@
    # perhaps try 'md5sum | sort | uniq -d' to weed out duplicates?
    # see https://github.com/geopaparazzi/geopaparazzi/wiki/mbtiles-Implementation
    (
-   for file in `find "$OUTFILE" -name "*.$ext"` ; do
+   for file in `find "$OUTFILE" -name "*.$ext" | sort -n -t / -k 2` ; do
       zoomcolrow=`echo "$file" | sed -e "s|.*$OUTFILE/||" -e "s|\.$ext||" -e 's|/|, |g'`
 
       echo "INSERT INTO tiles VALUES ($zoomcolrow, X'`hexdump -v -e '1/1 "%.2x"' $file`');"
    done
-   ) > "${TMPFILE}_tiles.sql"
+   ) >> "$TMPFILE.sql"
 
-
-   sort -n "${TMPFILE}_tiles.sql" >> "$TMPFILE.sql"
-
    echo "COMMIT TRANSACTION;" >> "$TMPFILE.sql"
 
    if [ `wc -l < "${TMPFILE}_tiles.sql"` -gt 65535 ] ; then
       echo "FIXME: insert some 'COMMIT TRANSACTION; BEGIN TRANSACTION;' inline the sql every 65535 inserts or so"
    fi
 
-   mv "$TMPFILE.sql" "$OUTFILE.sql"
-
    g.message "Populating SQLite database ..."
-   cat "$OUTFILE.sql" | sqlite3 "$OUTFILE.mbtiles"
+   cat "$TMPFILE.sql" | sqlite3 "$OUTFILE.mbtiles"
 
 fi
 
@@ -535,6 +530,11 @@
 cleanup
 
 if [ "$GIS_FLAG_T" -eq 1 ] ; then
+   if [ ! -x "`which tar`" ] ; then
+      g.message -e "tar is required, please install it first."
+      exit 1
+   fi
+
    cd `dirname "$OUTFILE"`
    tar cf `basename "$OUTFILE"`.tar `basename "$OUTFILE"` `basename "$OUTFILE"`.mapurl
 fi
@@ -542,7 +542,9 @@
 
 g.message message=""
 g.message "Done."
-g.message "Next copy the '$OUTFILE' directory and mapurl file to \
-/sdcard/maps/ on your Android device and select the mapurl file as the \
-tile source in Geopaparazzi. The MBTiles SQLite database will then \
-be populated in the background."
+
+#g.message "Next copy the '$OUTFILE' directory and mapurl file to \
+# /sdcard/maps/ on your Android device and select the mapurl file as the \
+# tile source in Geopaparazzi. The MBTiles SQLite database will then \
+# be populated in the background."
+



More information about the grass-commit mailing list