def activate(georefObj, mapObj, dbsession, logger): """ This function activates a georeference process for a mapObj. :type georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess: georefObj :type georeference.models.vkdb.map.Map: mapObj :type sqlalchemy.orm.session.Session: dbSession :type logging.Logger: logger :return: string """ logger.debug('Activate georeference process with id %s ...' % georefObj.id) logger.debug('Create persistent georeference result ...') destPath = processGeorefImage(mapObj, georefObj, dbsession, logger) # check if the georeferencing was run correctly if destPath is None: logger.error( 'Something went wrong while trying to process a georeference process.' ) raise GeoreferenceProcessingException( 'Something went wrong while trying to process a georeference process.' ) logger.debug('Set map as active and update boundingbox ...') boundingboxFromFile = parseBoundingBoxPolygonFromFile(destPath) sridFromFile = parseSRIDFromFile(destPath) mapObj.setActive(destPath) mapObj.setBoundingBox(boundingboxFromFile, sridFromFile, dbsession) # for proper working of the mapping service update all pending database changes have to be commited if not TEST_MODE: dbsession.commit() # update the tile map service logger.info('Calculating tms cache ...') newTargetDirectory = os.path.join(GEOREFERENCE_PERSITENT_TMS, str(mapObj.maptype).lower()) calculateCompressedTMS(destPath, newTargetDirectory) # push metadata record to elasticsearch index datarecordKey = pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj) # push metadata to catalogue # this method has to be supported again # logger.debug('Push metadata record for map %s to cataloge service ...'%mapObj.id) # pushMapObjToCsw(mapObj, dbsession, logger) # update process georefObj.setActive() # flush session if TEST_MODE: dbsession.flush() return datarecordKey
def activate(georefObj, mapObj, dbsession, logger): """ This function activates a georeference process for a mapObj. :type georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess: georefObj :type georeference.models.vkdb.map.Map: mapObj :type sqlalchemy.orm.session.Session: dbSession :type logging.Logger: logger :return: string """ logger.debug('Activate georeference process with id %s ...'%georefObj.id) logger.debug('Create persistent georeference result ...') destPath = processGeorefImage(mapObj, georefObj, dbsession, logger) # check if the georeferencing was run correctly if destPath is None: logger.error('Something went wrong while trying to process a georeference process.') raise GeoreferenceProcessingException('Something went wrong while trying to process a georeference process.') logger.debug('Set map as active and update boundingbox ...') boundingboxFromFile = parseBoundingBoxPolygonFromFile(destPath) sridFromFile = parseSRIDFromFile(destPath) mapObj.setActive(destPath) mapObj.setBoundingBox(boundingboxFromFile, sridFromFile, dbsession) # for proper working of the mapping service update all pending database changes have to be commited if not TEST_MODE: dbsession.commit() # update the tile map service logger.info('Calculating tms cache ...') newTargetDirectory = os.path.join(GEOREFERENCE_PERSITENT_TMS, str(mapObj.maptype).lower()) calculateCompressedTMS(destPath, newTargetDirectory, mapObj.getSRID(dbsession)) # push metadata record to elasticsearch index datarecordKey = pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj) # push metadata to catalogue # this method has to be supported again # logger.debug('Push metadata record for map %s to cataloge service ...'%mapObj.id) # pushMapObjToCsw(mapObj, dbsession, logger) # update process georefObj.setActive() # flush session if TEST_MODE: dbsession.flush() return datarecordKey
def updateTMSProcess(job): calculateCompressedTMS(job[0], job[1]) return job
jobList = [] dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS), False) maps = Map.all(dbsession) for mapObj in maps: if mapObj.isttransformiert: jobList.append([ mapObj.georefimage, os.path.join(DATA_DIRECTORY_TMS, str(mapObj.maptype).lower()) ]) tmsCachePath = os.path.join(DATA_DIRECTORY_TMS, str(mapObj.maptype).lower()) print jobList if not RUN_IN_PARALLEL_MODE: print 'Update TMS cache serial ...' for record in jobList: calculateCompressedTMS(record[0], record[1]) print 'Finish update TMS cache!' else: print 'Update TMS cache parallel ...' # define parallel process function def updateTMSProcess(job): calculateCompressedTMS(job[0], job[1]) return job pool = mp.Pool(processes=NUMBER_PROCESSES) results = pool.map(updateTMSProcess, jobList) print 'Finish update TMS cache!'
maps = Map.all(dbsession) for mapObj in maps: if mapObj.isttransformiert: jobList.append([ mapObj.georefimage, os.path.join(DATA_DIRECTORY_TMS, str(mapObj.maptype).lower()) ]) tmsCachePath = os.path.join(DATA_DIRECTORY_TMS, str(mapObj.maptype).lower()) print jobList if not RUN_IN_PARALLEL_MODE: print 'Update TMS cache serial ...' for record in jobList: calculateCompressedTMS(record[0], record[1]) print 'Finish update TMS cache!' else: print 'Update TMS cache parallel ...' # define parallel process function def updateTMSProcess(job): calculateCompressedTMS(job[0], job[1]) return job pool = mp.Pool(processes=NUMBER_PROCESSES) results = pool.map(updateTMSProcess, jobList) print 'Finish update TMS cache!'