def updateMTBLayer(dbsession, logger, withOverviews=False):
    """ Functions update the vrt databasis for a mtb layer

    :type sqlalchemy.orm.session.Session: dbsession
    :type logging.Logger: logger
    :type boolean: withOverviews (Default: False) Be careful with this parameter, because of much more workload todo.
    :return: str """
    logger.info('Update aggregated layer for MTBs ...')

    logger.info('Update database reference of the aggregated layer ...')
    mapObjs = Map.all(dbsession)
    for mapObj in mapObjs:
        if str(mapObj.maptype).lower() == 'mtb':
            if mapObj.isttransformiert:
                pushMapObjToWmsDatabaseIndex(
                    mapObj, AGGREGATED_LAYERID[str(mapObj.maptype).lower()],
                    dbsession)
            else:
                removeMapObjFromWmsDatabaseIndex(
                    mapObj, AGGREGATED_LAYERID[str(mapObj.maptype).lower()],
                    dbsession)

    logger.info('Update vrts for this aggregated layer ... ')
    for value in range(1868, 1946):
        updateVirtualdatasetForTimestamp(
            '%s-01-01 00:00:00' % value,
            os.path.join(GEOREFERENCE_PERSITENT_VRT, 'mtb'), TMP_DIR,
            DBCONFIG_PARAMS, dbsession, logger)

    if withOverviews:
        logger.info('Calculate overviews for vrts ...')
def updateMTBLayer(dbsession, logger, withOverviews=False):
    """ Functions update the vrt databasis for a mtb layer

    :type sqlalchemy.orm.session.Session: dbsession
    :type logging.Logger: logger
    :type boolean: withOverviews (Default: False) Be careful with this parameter, because of much more workload todo.
    :return: str """
    logger.info('Update aggregated layer for MTBs ...')

    logger.info('Update database reference of the aggregated layer ...')
    mapObjs = Map.all(dbsession)
    for mapObj in mapObjs:
        if str(mapObj.maptype).lower() == 'mtb':
            if mapObj.isttransformiert:
                pushMapObjToWmsDatabaseIndex(mapObj, AGGREGATED_LAYERID[str(mapObj.maptype).lower()], dbsession)
            else:
                removeMapObjFromWmsDatabaseIndex(mapObj, AGGREGATED_LAYERID[str(mapObj.maptype).lower()], dbsession)

    logger.info('Update vrts for this aggregated layer ... ')
    for value in range(1868, 1946):
        updateVirtualdatasetForTimestamp('%s-01-01 00:00:00'%value, os.path.join(GEOREFERENCE_PERSITENT_VRT, 'mtb'), TMP_DIR, DBCONFIG_PARAMS, dbsession, logger)

    if withOverviews:
        logger.info('Calculate overviews for vrts ...')
Exemplo n.º 3
0
Copyright (c) 2015 Jacob Mendt

Created on 02.10.15

@author: mendt
@description:
    The following scripts pushs all database records to elasticsearch
'''
import logging
from georeference.settings import DBCONFIG_PARAMS
from georeference.models.meta import getPostgresEngineString
from georeference.models.meta import initializeDb
from georeference.models.vkdb.georeferenzierungsprozess import Georeferenzierungsprozess
from georeference.models.vkdb.map import Map
from georeference.persistent.jobs.genericjobs import pushRecordToSearchIndex
from georeference.persistent.jobs.genericjobs import removeRecordFromSearchIndex

if __name__ == '__main__':
    logging.basicConfig()
    logger = logging.getLogger('Push recrords to ES')
    dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS), False)
    maps = Map.all(dbsession)

    for mapObj in maps:
        if mapObj.istaktiv == True:
            print 'Push map record %s to elastic search ...' % mapObj.id
            georefObj = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(mapObj.id, dbsession)
            pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj)
        else:
            print 'Remove map record %s from elastic search ...' % mapObj.id
            removeRecordFromSearchIndex(mapObj)
Exemplo n.º 4
0
Created on 02.10.15

@author: mendt
@description:
    The following scripts pushs all database records to elasticsearch
'''
import logging
from georeference.settings import DBCONFIG_PARAMS
from georeference.models.meta import getPostgresEngineString
from georeference.models.meta import initializeDb
from georeference.models.vkdb.georeferenzierungsprozess import Georeferenzierungsprozess
from georeference.models.vkdb.map import Map
from georeference.persistent.jobs.genericjobs import pushRecordToSearchIndex
from georeference.persistent.jobs.genericjobs import removeRecordFromSearchIndex

if __name__ == '__main__':
    logging.basicConfig()
    logger = logging.getLogger('Push recrords to ES')
    dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS), False)
    maps = Map.all(dbsession)

    for mapObj in maps:
        if mapObj.istaktiv == True:
            print 'Push map record %s to elastic search ...' % mapObj.id
            georefObj = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(
                mapObj.id, dbsession)
            pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj)
        else:
            print 'Remove map record %s from elastic search ...' % mapObj.id
            removeRecordFromSearchIndex(mapObj)
Exemplo n.º 5
0
@author: mendt
'''
import os
import shutil
from georeference.settings import DBCONFIG_PARAMS
from georeference.models.meta import getPostgresEngineString
from georeference.models.meta import initializeDb
from georeference.models.vkdb.map import Map


DATA_DIRECTORY_ORGINAL = '/srv/vk/data/original'
DATA_DIRECTORY_GEOREF = '/srv/vk/data/georef'

if __name__ == '__main__':
    dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS))
    mapObjs = Map.all(dbsession)
    imageDoesNotExist = []
    oldPaths = []

    for mapObj in mapObjs:
        print 'Update data dirs for %s ...' % mapObj.originalimage

        # update orginal paths
        newPath = os.path.join(DATA_DIRECTORY_ORGINAL, os.path.join(str(mapObj.maptype).lower(), str(mapObj.originalimage).split('/')[-1]))
        if not os.path.exists(newPath):
            # check if path exist in old folder and if yes move the file
            oldPath = os.path.join(DATA_DIRECTORY_ORGINAL, os.path.join('mtb', str(mapObj.originalimage).split('/')[-1]))
            if os.path.exists(oldPath):
                oldPaths.append(oldPath)
                print 'Move file from %s to %s ...' % (oldPath, newPath)
                print 'Copy file ...'