# logging.debug("Closing the database %r" % self.db) # 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")
if dd.get('verbose') == 1: root = logging.getLogger() root.setLevel(logging.DEBUG) ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.DEBUG) formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s') ch.setFormatter(formatter) root.addHandler(ch) outfile = dd.get('outfile') mod = 'action="modifiy"' poly = Poly() bbox = poly.getBBox(dd.get('poly')) #logging.info("Bounding box is %r" % bbox) # XAPI uses: # minimum latitude, minimum longitude, maximum latitude, maximum longitude xbox = "%s,%s,%s,%s" % (bbox[2], bbox[0], bbox[3], bbox[1]) #logging.info("Bounding xbox is %r" % xbox) print("------------------------") #xapi = "(\n way(%s);\n node(%s);\n rel(%s);\n <;\n >;\n);\nout meta;" % (box , xbox, xbox) #print(xapi) # osmc.createChanges() # osmc.applyChanges() #xapi = '[adiff: "2018-03-29T00:26:13Z","2019-05-13T17:27:18-06:00"];' + xapi
outfile = dd.get('outfile') infile = dd.get('infile') dbname = dd.get('database') kmz = outfile.replace(".kml", ".kmz") post = Postgis() if dd.get('poly') is not None: polyfilter = Poly(poly) wkt = polyfilter.getWkt() # post.addPolygon(polyfilter) if dd.get('xapi') is True: if dd.get('poly') is not None: # polyfilter = Poly() bbox = polyfilter.getBBox(poly) osm = outfile.replace('.kml', '.osm') xapi = OverpassXAPI(bbox, osm) if xapi.getData() is True: post.importOSM(osm, dbname) else: quit() else: logging.error("Need to specify a poly to download!") dd.usage() elif infile is not None and dbname is not None and poly is None: post.importOSM(infile, dbname) elif infile is not None and poly is not None: oc = osmConvert() osm = outfile.replace('.kml', '.osm') oc.applyPoly(poly, infile, osm)