Example #1
0
if dd.get('usgs'):
    zoom = 15
    #zoom =  tuple(dd.get('zooms'))
    logging.debug("Zoom level for USGS is: %r" % str(zoom))
    tiles = list(mercantile.tiles(bbox[0], bbox[2], bbox[1], bbox[3], zoom))
    if dd.get('download'):
        # tile/Z/Y/X
        url = "https://basemap.nationalmap.gov/ArcGIS/rest/services/USGSTopo/MapServer/tile/{0}/{2}/{1}"
        mirrors = [url]
        if usgsdb.download(mirrors, tiles):
            logging.info("Done downloading USGS data")
    filespec = outfile + '/' + os.path.basename(
        path[0]) + '-USGS' + str(zoom) + '.txt'
    usgsdb.writeCache(tiles, filespec)
    usgsdb.writeDB(tiles, dbfile, poly.getName(), 'usgs')

if dd.get('topo'):
    # tiles = list(mercantile.tiles(bbox[0], bbox[2], bbox[1], bbox[3], dd.get('zooms')))
    zoom = 15
    #zoom =  tuple(dd.get('zooms'))
    logging.debug("Zoom level for topos is: %r" % str(zoom))
    tiles = list(mercantile.tiles(bbox[0], bbox[2], bbox[1], bbox[3], zoom))
    if dd.get('download') and dd.get('topo'):
        # (OpenTopo uses Z/X/Y.png format
        url = ".tile.opentopomap.org/{0}/{1}/{2}.png"
        mirrors = ["https://a" + url, "https://b" + url, "https://c" + url]
        if topodb.download(mirrors, tiles):
            logging.info("Done downloading Topo data")
    filespec = outfile + '/' + os.path.basename(
        path[0]) + '-Topo' + str(zoom) + '.txt'
Example #2
0
#         self.db.commit()
#         self.db.close()


#
# Main body
#
polyfile = dd.get('poly')
if polyfile is None:
    logging.error("Need to specify a poly file to do anything!")
    dd.usage()

poly = Poly(polyfile)
bbox = poly.getBBox()
logging.info("Bounding box for %r is %r" % (poly.getName(), bbox))

if dd.get('format') == "OSMAND":
    sqlite = dd.get('sqlite')
    osmand = Osmand(sqlite)
    # osmand.createDB()

    osmand.addFromFile(input)

    # osmand.addLevel(bbox, 15)
    # osmand.addLevel(bbox, 16)

    # This writes all the tiles in the sqlite db to disk
    # path = dd.get('outfile')
    # osmand.writeTiles("./foo")