示例#1
0
def getGeoreferenceProcessQueue(dbsession, logger):
    """ This functions build a georeference process queue. For this it looks for entries 
        in the georeference table with status unprocessed and extends it with georeference process
        for which the equivalent map object has status updated. 
        
        Arguments:
            dbsession {sqlalchemy.orm.session.Session}
            logger (Logger)
        Returns:
            dictionary where the key is a timestamp and the value a list object containing 
            tuple which contain orm mapper for the tables georeferenzierungsprozess and
            messtischblatt """
    try:
        # response object
        response = {'georeference': {}, 'reset': []}

        # get unprocessed georeference process
        dictProcessingQueueGeoref = {}
        unprocessedGeorefProcs = Georeferenzierungsprozess.by_getUnprocessedGeorefProcesses(
            dbsession)
        for georefProc in unprocessedGeorefProcs:
            dictProcessingQueueGeoref[georefProc.messtischblattid] = georefProc

        # get updated messtischblätter
        updatedMesstischblaetter = Messtischblatt.getUpdatedMesstischblaetter(
            dbsession)
        for messtischblatt in updatedMesstischblaetter:
            # if there is no process for this mtb in the dictProcessingQueueGeoref than get one and add it
            if not messtischblatt.id in dictProcessingQueueGeoref:
                georefProc = Georeferenzierungsprozess.getLatestGeorefProcessForObjectId(
                    messtischblatt.id, dbsession)
                # if georefProc is None there is no more georeference process and the map object
                # should be resetted
                if georefProc is None:
                    response['reset'].append(messtischblatt.id)
                else:
                    dictProcessingQueueGeoref[messtischblatt.id] = georefProc

        # sort the georeference process by timestamps
        for key in dictProcessingQueueGeoref:
            # get timestamp for the equivalent map object to the georeference process
            time = MdZeit.by_id(
                dictProcessingQueueGeoref[key].messtischblattid,
                dbsession).time.year
            if time in response['georeference']:
                response['georeference'][time].append(
                    dictProcessingQueueGeoref[key])
            else:
                response['georeference'][time] = [
                    dictProcessingQueueGeoref[key]
                ]
        return response
    except:
        logger.error(
            'Unknown error while trying to create the georeference processing queue ...'
        )
        raise
示例#2
0
def getGeoreferenceProcessQueue(dbsession, logger):
    """ This functions build a georeference process queue. For this it looks for entries 
        in the georeference table with status unprocessed and extends it with georeference process
        for which the equivalent map object has status updated. 
        
        Arguments:
            dbsession {sqlalchemy.orm.session.Session}
            logger (Logger)
        Returns:
            dictionary where the key is a timestamp and the value a list object containing 
            tuple which contain orm mapper for the tables georeferenzierungsprozess and
            messtischblatt """
    try:
        # response object 
        response = { 'georeference':{}, 'reset': [] }
        
        # get unprocessed georeference process
        dictProcessingQueueGeoref = {}
        unprocessedGeorefProcs = Georeferenzierungsprozess.by_getUnprocessedGeorefProcesses(dbsession)
        for georefProc in unprocessedGeorefProcs:
            dictProcessingQueueGeoref[georefProc.messtischblattid] = georefProc
            
        # get updated messtischblätter
        updatedMesstischblaetter = Messtischblatt.getUpdatedMesstischblaetter(dbsession)
        for messtischblatt in updatedMesstischblaetter:
            # if there is no process for this mtb in the dictProcessingQueueGeoref than get one and add it
            if not messtischblatt.id in dictProcessingQueueGeoref:
                georefProc = Georeferenzierungsprozess.getLatestGeorefProcessForObjectId(messtischblatt.id, dbsession)
                # if georefProc is None there is no more georeference process and the map object 
                # should be resetted
                if georefProc is None:
                    response['reset'].append(messtischblatt.id)
                else:
                    dictProcessingQueueGeoref[messtischblatt.id] = georefProc
        
        # sort the georeference process by timestamps
        for key in dictProcessingQueueGeoref:
            # get timestamp for the equivalent map object to the georeference process
            time = MdZeit.by_id(dictProcessingQueueGeoref[key].messtischblattid, dbsession).time.year
            if time in response['georeference']:
                response['georeference'][time].append(dictProcessingQueueGeoref[key])
            else:
                response['georeference'][time] = [dictProcessingQueueGeoref[key]]
        return response
    except:
        logger.error('Unknown error while trying to create the georeference processing queue ...')
        raise