Ejemplo n.º 1
0
def rastertile(datagranule_id):
    from namo_app.db.access import SqaAccess
    from namo_app.config import Config, get_env
    from namo_app.db.models import init_mapper, Mask, RasterTile, DataGranule, DataFormat
    from flask import request

    #q	{"filters":[{"name":"datagranule_id","op":"==","val":"3"}]}
    config = Config(env=get_env())
    init_mapper(config.sqa_connection_string())

    mask = request.args.get('mask', None)
    with SqaAccess(conn_str=config.sqa_connection_string()) as sqa:
        tileObjs = sqa.all(RasterTile, filterr={'datagranule_id': datagranule_id})
        response = flask.json.dumps({"tiles": tileObjs})

    return response
Ejemplo n.º 2
0
def rastertile(datagranule_id):
    from namo_app.db.access import SqaAccess
    from namo_app.config import Config, get_env
    from namo_app.db.models import init_mapper, Mask, RasterTile, DataGranule, DataFormat
    from flask import request

    #q	{"filters":[{"name":"datagranule_id","op":"==","val":"3"}]}
    config = Config(env=get_env())
    init_mapper(config.sqa_connection_string())

    mask = request.args.get('mask', None)
    with SqaAccess(conn_str=config.sqa_connection_string()) as sqa:
        tileObjs = sqa.all(RasterTile,
                           filterr={'datagranule_id': datagranule_id})
        response = flask.json.dumps({"tiles": tileObjs})

    return response
Ejemplo n.º 3
0
    return result


def post_get_single(result=None, search_params=None, **kw):
    json_result = geojson_encoder.default(result)
    return json_result


#add cross domain headers
def add_cors_headers(response):
    response.headers['Access-Control-Allow-Origin'] = '*'
    response.headers['Access-Control-Allow-Credentials'] = 'true'
    return response


config = Config(env=get_env())

app = Flask(__name__)
app.after_request(add_cors_headers)

app.config['DEBUG'] = config.debug
app.config['SQLALCHEMY_DATABASE_URI'] = config.sqa_connection_string()
app.json_encoder = GeoJSONEncoder

db = flask.ext.sqlalchemy.SQLAlchemy(app)
engine = create_engine(config.sqa_connection_string())
insp = reflection.Inspector.from_engine(engine)

#discover table names in public schema using flask restless inspector
table_names = insp.get_table_names()
Ejemplo n.º 4
0
def get_ingest_files(files_dir, wildcard="*"):
    data_dir = Config(env=get_env()).datadir
    pattern = os.path.join(data_dir, files_dir, wildcard)
    return glob.glob(pattern)
Ejemplo n.º 5
0
        logger.info("Inserting formats")
        sqa.insert(FORMATS)

        logger.info("Inserting providers")
        sqa.insert(PROVIDERS)


def create_new_geodb(config):
    admin_db_helper = PGDbHelper(conn_str=config.pgsql_postgres_conn_str())

    if check_db_exists(admin_db_helper, config.dbname):
        logger.info("Deleting existing db %s" % config.dbname)
        admin_db_helper.execute("DROP DATABASE %s" % config.dbname)

    if not check_db_exists(admin_db_helper, config.dbname):
        logger.info("Creating new db %s" % config.dbname)
        admin_db_helper.execute("CREATE DATABASE %s" % config.dbname)

    #connect to new db
    ci_db_helper = PGDbHelper(config.pgsql_conn_str())
    logger.info("Enabling geodatabase on %s" % config.dbname)
    ci_db_helper.execute("CREATE EXTENSION POSTGIS;")


if __name__ == '__main__':
    config = Config(env=get_env())
    create_new_geodb(config)

    insert_refdata(config)
    insert_masks(config)
Ejemplo n.º 6
0
    return result


def post_get_single(result=None, search_params=None, **kw):
    json_result =geojson_encoder.default(result)
    return json_result


#add cross domain headers
def add_cors_headers(response):
    response.headers['Access-Control-Allow-Origin'] = '*'
    response.headers['Access-Control-Allow-Credentials'] = 'true'
    return response


config = Config(env=get_env())

app = Flask(__name__)
app.after_request(add_cors_headers)

app.config['DEBUG'] = config.debug
app.config['SQLALCHEMY_DATABASE_URI'] = config.sqa_connection_string()
app.json_encoder = GeoJSONEncoder

db = flask.ext.sqlalchemy.SQLAlchemy(app)
engine = create_engine(config.sqa_connection_string())
insp = reflection.Inspector.from_engine(engine)

#discover table names in public schema using flask restless inspector
table_names = insp.get_table_names()
Ejemplo n.º 7
0
__author__ = 'ujjwal'
from namo_app.config import Config, get_env
from namo_app.db.models import init_mapper


config = Config(env=get_env())
init_mapper(sqa_conn_str=config.sqa_connection_string())