Open aproposinfosystems opened 8 years ago
well, may be instead of creating new plugin you can make a pull-request?
I deprecated TileCache creator instead of updating it when I found QTiles has a nicer implementation of similar capability. My plugin is a stop-gap measure and I would be happy to retire it when these two issues are addressed.
can you make a pull-request?
Code from Trevor:
from PyQt4 import QtGui, QtSql
import os
#
# Input Variables:
# - dbFileName - the name of the mbtiles database with full path
#
def enableGeoODK(dbFileName):
result = False
messageText = 'Unknown failure'
if os.path.exists(dbName):
db = QtSql.QSqlDatabase.addDatabase('QSQLITE')
db.setDatabaseName(dbName)
db.open()
model = QtSql.QSqlTableModel()
model.setTable('images')
if not model.select():
query = QtSql.QSqlQuery()
try:
query.exec_("CREATE TABLE images (tile_data blob, tile_id text);")
db.close()
messageText = "Required table created in %s." % dbName
result = TrueS
except:
messageText = "Unable to create required table in %s." % dbName
else:
messageText = "Required table already exists in %s." % dbName
return(result,messageText)
#
# Input Variables:
# - tileCachePath - the path to the disk tile cache
# - imageFileExtension - jpg, png, etc
# - tmsStyle - boolean indicating if the user has selected to use TMS style naming of tiles
# - minZoom - the minimum zoom in the tile cache
# - maxZoom - the maximum zoom in the tile cache
# - name - the name of the cache dir (also used by qtiles to name the json file)
# - attribution - the full name for the tile cache that could be the same as the name or a longer name if preferred
# - extents - the extent values in a list exactly matching the order in the current QTiles json output file format
#
def writeTileLayerConfigFile(tileCachePath,imageFileExtension,tmsStyle,minZoom,maxZoom,name,attribution,extents):
if tmsStyle == True:
tileType = 0
else:
tileType = 1
outLine = "%s\t%s\t" % (name,attribution)
outLine += "file:///%s/{z}/{x}/{y}.%s\t" % (tileCachePath,imageFileExtension)
outLine += "%d\t%d\t%d\t" % (tileType,minZoom,maxZoom)
outLine += "%s\t%s\t%s\t%s\n" % (extents[0],extents[1],extents[2],extents[3])
fName = os.path.join(tileCachePath,name + '.tsv')
f = open(fName,'w')
f.write(outLine)
f.close()
Hi, We are trying to use the plugin to generate MBTiles for GeoOdk, but as mentioned previously, these are currently not compatible. We would like to know if this feature has a chance to be added soon? (Unfortunately I do not think we have the skills to help you with this implementation)
It's opensource so there is always hope. But we're not users of ODK and don't know much about it. Try NextGIS Mobile.
sign-pnrnm,
The code above does work on tests I've done with GeoODK but I've not had time to add it. I am disappointed that the NextGIS folks have not included it given it was submitted more than 6 months ago.
For now you can, from my private plugin repository below, use a the QTiles Tools plugin that will transform the MBTiles database to work with GeoODK.
https://aproposinfosystems.com/qgis-repo/plugins.xml
TSW
For now you can, from my private plugin repository below, use a the QTiles Tools plugin that will transform the MBTiles database to work with GeoODK.
Thanks a lot ! I just tested, and it worked perfectly in GeoODK! 👍
QTiles creates disk caches of files that could be used with the TileLayer plugin. However it doesn't create that config file.
Also QTiles mbtiles databases don't work with the current version of GeoODK Collect.
I've created a quick fix plugin here: https://github.com/tsw-apropos/qtilestools that provides simple tools to do these two tasks. The amount of working code is very very small and would be a worthwhile inclusion for a future release of QTiles.