Ejemplo n.º 1
0
def createResponseForSpecificGeoreferenceProcess(objectid, georeferenceid, request):
    log.debug('Create response for specific georeference process ...')
    messtischblatt = Messtischblatt.by_id(objectid, request.db)
    mtb_extent = Messtischblatt.getExtent(objectid, request.db)
    georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db)
    pure_clipparameters = ast.literal_eval(str(georeferenceprocess.clipparameter))
    gcps = None
    if 'new' in pure_clipparameters:
        # in case of an update process
        gcps = pure_clipparameters['new']
    else:
        # in case of a new registered clip_parameter
        gcps = pure_clipparameters
          
    # get zoomify and metadata information
    log.debug('Create response ...')  
    metadata = MdCore.by_id(messtischblatt.id, request.db)
    return {
            'type':'update',
            'objectid': messtischblatt.id,
            'georeferenceid':georeferenceid, 
            'timestamp':str(georeferenceprocess.timestamp), 
            'gcps':gcps, 
            'extent': mtb_extent,
            'zoomify': {
                'properties': messtischblatt.zoomify_properties,
                'width': messtischblatt.zoomify_width,
                'height': messtischblatt.zoomify_height
            },
            'metadata': {
                'dateiname': messtischblatt.dateiname,
                'titel_long': metadata.titel,
                'titel_short': metadata.titel_short
            }            
    }
Ejemplo n.º 2
0
def publishGeorefParameters(request):
    log.info('Request - Publish georeference result.')
    try:
        log.debug('Parse parameters ...')
        objectid = request.params['objectid']
        georeferenceid = request.params['georeferenceid']
        messtischblatt = Messtischblatt.by_id(objectid, request.db)
        georeferenceprocess = Georeferenzierungsprozess.by_id(
            georeferenceid, request.db)

        log.debug('Udpate parameters')
        georeferenceprocess.publish = True
        messtischblatt.updated = False

        return json.dumps(
            {
                'message':
                'The georeference process is now published. The georeference map will soon be updated and than ready for accessing.'
            },
            ensure_ascii=False,
            encoding='utf-8')
    except Exception as e:
        log.error(
            'Error while trying to request georeference history information')
        log.error(e)
        return {}
Ejemplo n.º 3
0
def georeferenceGetProcess(request):
    log.info('Receive request GetGeoreferenceProcess')
    
    try:
        request_data = None
        if request.method == 'POST':
            request_data = request.json_body     
               
        if 'georeferenceid' in request_data:
            georeferenceid = int(request_data['georeferenceid'])
            log.debug('Parsed parameters - georeferenceid: %s'%georeferenceid)
            mapObj = Map.by_id(int(Georeferenzierungsprozess.by_id(georeferenceid, request.db).mapid), request.db)
            response = createResponseForSpecificGeoreferenceProcess(mapObj, request, georeferenceid)
        elif 'objectid' in request_data:
            mapObjId = request_data['objectid']
            log.debug('Parsed parameters - mapid: %s'%mapObjId)
            mapObj = Map.by_id(int(mapObjId), request.db)
            response = createGeneralResponse(mapObj, request)
        else:
            log.error('Could not find a georeferenceid or and objectid in the post request parameters ...')
            raise GeoreferenceParameterError
        return response    
    except GeoreferenceParameterError as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPBadRequest(ERROR_MSG) 
    except ProcessIsInvalideException as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPBadRequest('This georeference process is blocked for further work!')
    except Exception as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(ERROR_MSG)
Ejemplo n.º 4
0
def setIsValide(job, dbsession, logger, testing = False):
    """ This function sets a georeference process as 'isvalide' and if there is no other
        newer georeference process for this map its activate this georeference process for this 
        map.
        
        @param vkviewer.python.models.messtischblatt.AdminJobs: job
        @param sqlalchemy.orm.session.Session: dbsession
        @param logging.Logger: logger
        @param boolean: testing (Default: False)
    """ 
    logger.debug('Set georeference process for id %s to isvalide ...'%(job.georefid))
    
    # set georeferenceprocess to isvalide
    georefProcess = Georeferenzierungsprozess.by_id(job.georefid, dbsession)
    
    # check if there is an other process which is newer and more up to date
    activeGeorefProcess = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(georefProcess.mapid, dbsession)
    mapObj = Map.by_id(georefProcess.mapid, dbsession)
    if activeGeorefProcess and activeGeorefProcess.id >= georefProcess.id:
        logger.info('The georeference process with the id %s or younger process is already active for this map object.'%georefProcess.id)
        pass
    elif activeGeorefProcess and activeGeorefProcess.id < georefProcess.id:
        logger.info('Activate the is valide georeference process and deactive old one ...')
        deactivate(activeGeorefProcess, mapObj, dbsession, logger)
        activate(georefProcess, mapObj, dbsession, logger)
    else:
        logger.info('Activate georeference process %s for the map object %s ...'%(georefProcess.id, georefProcess.mapid))
        activate(georefProcess, mapObj, dbsession, logger)
        
        if georefProcess.adminvalidation == 'invalide':
            mapObj.hasgeorefparams = mapObj.hasgeorefparams + 1
        
    georefProcess.adminvalidation = 'isvalide'
Ejemplo n.º 5
0
def getGeoreferencePage(request):
    log.info('Call view getGeoreferencePage.')
    if 'id' in request.params:
        return {'objectid':request.params['id']}
    elif 'georeferenceid' in request.params:
        georefProcess = Georeferenzierungsprozess.by_id(request.params['georeferenceid'], request.db)
        return {'objectid':georefProcess.mapid}
Ejemplo n.º 6
0
def getGeoreferencePage(request):
    log.info('Call view getGeoreferencePage.')
    if 'id' in request.params:
        return {'objectid': request.params['id']}
    elif 'georeferenceid' in request.params:
        georefProcess = Georeferenzierungsprozess.by_id(
            request.params['georeferenceid'], request.db)
        return {'objectid': georefProcess.mapid}
Ejemplo n.º 7
0
def createResponseForSpecificGeoreferenceProcess(mapObj,
                                                 request,
                                                 georeferenceid=None):
    log.debug('Create response for specific georeference process ...')
    mtb_extent = Map.getExtent(mapObj.id, request.db)
    if georeferenceid is None:
        georeferenceprocess = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(
            mapObj.id, request.db)
    else:
        georeferenceprocess = Georeferenzierungsprozess.by_id(
            georeferenceid, request.db)
    pure_clipparameters = georeferenceprocess.georefparams

    # get the actual valide gcps
    gcps = None
    if georeferenceprocess.type == 'new':
        # in case of a new registered clip_parameter
        gcps = pure_clipparameters
    else:
        # in case of an update process
        gcps = pure_clipparameters['new']

    # get zoomify and metadata information
    log.debug('Create response ...')
    metadata = Metadata.by_id(mapObj.id, request.db)
    response = {
        'type': 'update',
        'objectid': mapObj.id,
        'georeferenceid': georeferenceprocess.id,
        'timestamp': str(georeferenceprocess.timestamp),
        'gcps': gcps,
        'extent': mtb_extent,
        'zoomify': metadata.imagezoomify,
        'metadata': {
            'dateiname': mapObj.apsdateiname,
            'titel_long': metadata.title,
            'titel_short': metadata.titleshort
        }
    }

    # check if there is an other user is working on this map right now
    # @TODO use babel lingua fpr translation
    try:
        areTherePendingUpdateProcesses = Georeferenzierungsprozess.arePendingProcessForMapId(
            mapObj.id, request.db)

        if areTherePendingUpdateProcesses:
            if request.locale_name == 'de':
                warnMsg = 'Aktuell wird das Kartenblatt von anderen Nutzern bearbeitet. Um Informationsverluste zu vermeiden versuchen Sie es bitte noch einmal in ein 15 Minuten.'
            else:
                warnMsg = 'Right now another users is working on the georeferencing of this map sheet. For preventing information losses please try again in 15 minutes.'
            response['warn'] = warnMsg
        return response
    except ProcessIsInvalideException as e:
        pass
    return response
Ejemplo n.º 8
0
def createResponseForSpecificGeoreferenceProcess(mapObj, request, georeferenceid = None):
    log.debug('Create response for specific georeference process ...')
    mtb_extent = Map.getExtent(mapObj.id, request.db)
    if georeferenceid is None:
        georeferenceprocess = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(mapObj.id, request.db)
    else:
        georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db)
    pure_clipparameters = georeferenceprocess.georefparams
    
    # get the actual valide gcps
    gcps = None
    if georeferenceprocess.type == 'new':
        # in case of a new registered clip_parameter
        gcps = pure_clipparameters
    else:
        # in case of an update process
        gcps = pure_clipparameters['new']
          

    # get zoomify and metadata information
    log.debug('Create response ...')  
    metadata = Metadata.by_id(mapObj.id, request.db)
    response = {
            'type':'update',
            'objectid': mapObj.id,
            'georeferenceid':georeferenceprocess.id, 
            'timestamp':str(georeferenceprocess.timestamp), 
            'gcps':gcps, 
            'extent': mtb_extent,
            'zoomify': metadata.imagezoomify,
            'metadata': {
                'dateiname': mapObj.apsdateiname,
                'titel_long': metadata.title,
                'titel_short': metadata.titleshort
            }
    }    
                
    # check if there is an other user is working on this map right now
    # @TODO use babel lingua fpr translation
    try:
        areTherePendingUpdateProcesses = Georeferenzierungsprozess.arePendingProcessForMapId(mapObj.id, request.db)
        
        if areTherePendingUpdateProcesses:
            if request.locale_name == 'de':
                warnMsg = 'Aktuell wird das Kartenblatt von anderen Nutzern bearbeitet. Um Informationsverluste zu vermeiden versuchen Sie es bitte noch einmal in ein 15 Minuten.'
            else:
                warnMsg = 'Right now another users is working on the georeferencing of this map sheet. For preventing information losses please try again in 15 minutes.'
            response['warn'] = warnMsg         
        return response
    except ProcessIsInvalideException as e:
        pass
    return response
Ejemplo n.º 9
0
 def confirmExistingGeoreferenceProcess(self, georefid, isvalide=False, typeValidation='user'):
         # get georef data from database and parse them
         georefProc = Georeferenzierungsprozess.by_id(georefid, self.dbsession)
         
         # change valdation status of georeference process in database
         georefProc.isvalide = isvalide
         georefProc.typevalidierung = typeValidation
         self.dbsession.flush()
         self.logger.debug("Change validation status of georeference process with id %s!"%georefid)
         
         # register passpunkte
         #self.updatePasspunkte(georefProc)
         #self.dbSession.commit()
         #self.logger.info("Ground control points for georeference process with id %s registered!"%georefid)
         return georefid       
Ejemplo n.º 10
0
def getLastValidGeoreferenceProcess(overwritesId, dbsession, logger):
    """ This function goes down the overwrite chain and looks for the last valid
        georeference process
        
        @param Integer: job
        @param sqlalchemy.orm.session.Session: dbsession
        @param logging.Logger: logger
    """ 
    georefProcess = Georeferenzierungsprozess.by_id(overwritesId, dbsession)
    if georefProcess.adminvalidation == 'isvalide' or georefProcess.adminvalidation == '':
        return georefProcess
    elif georefProcess.overwrites > 0:
        return getLastValidGeoreferenceProcess(georefProcess.overwrites, dbsession, logger)
    else:
        return None
Ejemplo n.º 11
0
def publishGeorefParameters(request):
    log.info('Request - Publish georeference result.')
    try:
        log.debug('Parse parameters ...')            
        objectid = request.params['objectid']
        georeferenceid = request.params['georeferenceid']
        messtischblatt = Messtischblatt.by_id(objectid, request.db)
        georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db)
        
        log.debug('Udpate parameters')
        georeferenceprocess.publish = True
        messtischblatt.updated = False
        
        return json.dumps({'message':'The georeference process is now published. The georeference map will soon be updated and than ready for accessing.'}, ensure_ascii=False, encoding='utf-8')  
    except Exception as e:
        log.error('Error while trying to request georeference history information');
        log.error(e)
        return {}
Ejemplo n.º 12
0
def deleteGeorefParameters(request):
    log.info('Request - Delete georeference result.')
    try:           
        # remove georeference process
        georeferenceid = request.params['georeferenceid']
        georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db)
        messtischblattid = georeferenceprocess.messtischblattid
        request.db.delete(georeferenceprocess)
        
        # mark the messtischblatt as updated
        messtischblatt = Messtischblatt.by_id(messtischblattid, request.db)
        messtischblatt.udpated = True
                
        return json.dumps({'message':'The georeference process has been removed.'}, ensure_ascii=False, encoding='utf-8') 
    except Exception as e:
        log.error('Error while trying to request georeference history information');
        log.error(e)
        return {}
Ejemplo n.º 13
0
def georeferenceGetProcess(request):
    log.info('Receive request GetGeoreferenceProcess')

    try:
        request_data = None
        if request.method == 'POST':
            request_data = request.json_body

        if 'georeferenceid' in request_data:
            georeferenceid = int(request_data['georeferenceid'])
            log.debug('Parsed parameters - georeferenceid: %s' %
                      georeferenceid)
            mapObj = Map.by_id(
                int(
                    Georeferenzierungsprozess.by_id(georeferenceid,
                                                    request.db).mapid),
                request.db)
            response = createResponseForSpecificGeoreferenceProcess(
                mapObj, request, georeferenceid)
        elif 'objectid' in request_data:
            mapObjId = request_data['objectid']
            log.debug('Parsed parameters - mapid: %s' % mapObjId)
            mapObj = Map.by_id(int(mapObjId), request.db)
            response = createGeneralResponse(mapObj, request)
        else:
            log.error(
                'Could not find a georeferenceid or and objectid in the post request parameters ...'
            )
            raise GeoreferenceParameterError
        return response
    except GeoreferenceParameterError as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPBadRequest(ERROR_MSG)
    except ProcessIsInvalideException as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPBadRequest(
            'This georeference process is blocked for further work!')
    except Exception as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(ERROR_MSG)
Ejemplo n.º 14
0
def deleteGeorefParameters(request):
    log.info("Request - Delete georeference result.")
    try:
        # remove georeference process
        georeferenceid = request.params["georeferenceid"]
        georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db)
        messtischblattid = georeferenceprocess.messtischblattid
        request.db.delete(georeferenceprocess)

        # mark the messtischblatt as updated
        messtischblatt = Messtischblatt.by_id(messtischblattid, request.db)
        messtischblatt.udpated = True

        return json.dumps(
            {"message": "The georeference process has been removed."}, ensure_ascii=False, encoding="utf-8"
        )
    except Exception as e:
        log.error("Error while trying to request georeference history information")
        log.error(e)
        return {}
Ejemplo n.º 15
0
    def confirmExistingGeoreferenceProcess(self,
                                           georefid,
                                           isvalide=False,
                                           typeValidation='user'):
        # get georef data from database and parse them
        georefProc = Georeferenzierungsprozess.by_id(georefid, self.dbsession)

        # change valdation status of georeference process in database
        georefProc.isvalide = isvalide
        georefProc.typevalidierung = typeValidation
        self.dbsession.flush()
        self.logger.debug(
            "Change validation status of georeference process with id %s!" %
            georefid)

        # register passpunkte
        #self.updatePasspunkte(georefProc)
        #self.dbSession.commit()
        #self.logger.info("Ground control points for georeference process with id %s registered!"%georefid)
        return georefid
Ejemplo n.º 16
0
def setProcessToIsValide(request):
    log.info('Request - Set admin evaluation of georeference process to isvalide ....')
    try:           
        # remove georeference process
        if 'georeferenceid' in request.params:
            georeferenceid = request.params['georeferenceid']
            userid = checkIsUser(request)
            comment = '' if 'comment' not in request.params else request.params['comment']
            
            # check if georeference id exist
            georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db)
            if georeferenceprocess:
                newJob = createNewAdminJob(georeferenceprocess, 'isvalide', userid, comment)
                request.db.add(newJob)
                
            return {'message':'The georeference process has been set to isvalide.'}
        else:
            raise Exception('Missing parameter (georeferenceid) ...')
    except Exception as e:
        log.error(e)
        log.error(traceback.format_exc())
        return HTTPBadRequest(GENERAL_ERROR_MESSAGE);
Ejemplo n.º 17
0
def setInValide(job, dbsession, logger, testing = False):
    """ This function sets a georeference process as 'isvalide' and if there is no other
        newer georeference process for this map its activate this georeference process for this 
        map.
        
        @param vkviewer.python.models.messtischblatt.AdminJobs: job
        @param sqlalchemy.orm.session.Session: dbsession
        @param logging.Logger: logger
        @param boolean: testing (Default: False)
    """ 
    logger.debug('Set georeference process for id %s to isvalide ...'%(job.georefid))
    
    # set georeferenceprocess to isvalide
    georefProcess = Georeferenzierungsprozess.by_id(job.georefid, dbsession)
    
    # update map object and datasource
    mapObj = Map.by_id(georefProcess.mapid, dbsession)
    if georefProcess.isactive == True and georefProcess.overwrites > 0:
        logger.info('Deactive georeference process and activate georeference process with id %s ...'%georefProcess.overwrites)
        
        # deactive the georeference process
        deactivate(georefProcess, mapObj, dbsession, logger)
            
        # look if there is a valid overwrite id and if yes activate the matching 
        # process
        newGeorefProcess = getLastValidGeoreferenceProcess(georefProcess.overwrites, dbsession, logger)
        if newGeorefProcess:
            activate(newGeorefProcess, mapObj, dbsession, logger)   
            
    elif georefProcess.isactive == True and georefProcess.overwrites == 0:
        logger.info('Deactive georeference process %s ...'%georefProcess.overwrites)
        
        # deactive the georeference process
        deactivate(georefProcess, mapObj, dbsession, logger)
        
    logger.debug('Set georeference process with id %s to inactive ...'%georefProcess.overwrites)        
    if georefProcess.adminvalidation != 'invalide':
        georefProcess.adminvalidation = 'invalide'
        mapObj.hasgeorefparams = 0 if mapObj.hasgeorefparams - 1 < 0 else mapObj.hasgeorefparams - 1
Ejemplo n.º 18
0
def createResponseForSpecificGeoreferenceProcess(objectid, georeferenceid,
                                                 request):
    log.debug('Create response for specific georeference process ...')
    messtischblatt = Messtischblatt.by_id(objectid, request.db)
    mtb_extent = Messtischblatt.getExtent(objectid, request.db)
    georeferenceprocess = Georeferenzierungsprozess.by_id(
        georeferenceid, request.db)
    pure_clipparameters = ast.literal_eval(
        str(georeferenceprocess.clipparameter))
    gcps = None
    if 'new' in pure_clipparameters:
        # in case of an update process
        gcps = pure_clipparameters['new']
    else:
        # in case of a new registered clip_parameter
        gcps = pure_clipparameters

    # get zoomify and metadata information
    log.debug('Create response ...')
    metadata = MdCore.by_id(messtischblatt.id, request.db)
    return {
        'type': 'update',
        'objectid': messtischblatt.id,
        'georeferenceid': georeferenceid,
        'timestamp': str(georeferenceprocess.timestamp),
        'gcps': gcps,
        'extent': mtb_extent,
        'zoomify': {
            'properties': messtischblatt.zoomify_properties,
            'width': messtischblatt.zoomify_width,
            'height': messtischblatt.zoomify_height
        },
        'metadata': {
            'dateiname': messtischblatt.dateiname,
            'titel_long': metadata.titel,
            'titel_short': metadata.titel_short
        }
    }