def main(): from geobox.config import GeoBoxConfig, GeoBoxState config = GeoBoxConfig.from_file('./geobox.ini') if not config: sys.exit(1) app_state = GeoBoxState(config) session = app_state.user_db_session() # create test tasks tasks = [] tasks.append( VectorImportTask(db_name='foobar', file_name=path('../example_data/points.shp'))) tasks.append( VectorImportTask(db_name='foobar', file_name=path('../example_data/lines.shp'))) tasks.append( ReplicationTask(db_name='foobar', remote_db_url='http://127.0.0.1:5984', remote_db_name='foobar2', push=True)) tasks.append( ReplicationTask(db_name='foobar', remote_db_url='http://127.0.0.1:5984', remote_db_name='foobar2', pull=True)) source = model.ExternalWMTSSource( name='test', url="http://a.tile.openstreetmap.org/%(z)s/%(x)s/%(y)s.png", format='png') layer = session.query(model.RasterLayer).filter_by(name='osm').all() if layer: layer = layer[0] else: layer = model.RasterLayer(name='osm') import_task = model.RasterImportTask(source=source, layer=layer, zoom_level_start=0, zoom_level_end=5) tasks.append(import_task) tasks.append( ExportProject(title="test project", download_level_start=2, download_level_end=10, raster_tasks=[ RasterExportTask( layer=RasterLayer(name='test raster layer'), export_format='jpeg') ])) for t in tasks: session.add(t) session.commit() # list all tasks for t in session.query(model.Task).with_polymorphic('*'): print t
def webserver_command(config='./geobox.ini'): from geobox.config import GeoBoxConfig, GeoBoxState config = GeoBoxConfig.from_file(config) if not config: sys.exit(1) app_state = GeoBoxState(config) app = create_app(app_state) # scriptine removed sub-command from argv, # but Flask reloader needs complete sys.argv sys.argv[1:1] = ['webserver'] app.run(port=config.get('web', 'port'))
def main(): from geobox.config import GeoBoxConfig, GeoBoxState config = GeoBoxConfig.from_file('./geobox.ini') if not config: sys.exit(1) app_state = GeoBoxState(config) session = app_state.user_db_session() # create test tasks tasks = [] tasks.append(VectorImportTask(db_name='foobar', file_name=path('../example_data/points.shp') )) tasks.append(VectorImportTask(db_name='foobar', file_name=path('../example_data/lines.shp') )) tasks.append(ReplicationTask(db_name='foobar', remote_db_url='http://127.0.0.1:5984', remote_db_name='foobar2', push=True)) tasks.append(ReplicationTask(db_name='foobar', remote_db_url='http://127.0.0.1:5984', remote_db_name='foobar2', pull=True)) source = model.ExternalWMTSSource(name='test', url="http://a.tile.openstreetmap.org/%(z)s/%(x)s/%(y)s.png", format='png') layer = session.query(model.RasterLayer).filter_by(name='osm').all() if layer: layer = layer[0] else: layer = model.RasterLayer(name='osm') import_task = model.RasterImportTask(source=source, layer=layer, zoom_level_start=0, zoom_level_end=5) tasks.append(import_task) tasks.append(ExportProject(title="test project", download_level_start=2, download_level_end=10, raster_tasks=[ RasterExportTask(layer= RasterLayer(name = 'test raster layer') , export_format='jpeg') ])) for t in tasks: session.add(t) session.commit() # list all tasks for t in session.query(model.Task).with_polymorphic('*'): print t