def createNewAdminJob(georeferenceprocess, setto, userid, comment):
    return AdminJobs(georefid=georeferenceprocess.id,
                     processed=False,
                     setto=setto,
                     timestamp=convertTimestampToPostgisString(datetime.now()),
                     comment=comment,
                     userid=userid)
def createNewAdminJob(georeferenceprocess, setto, userid, comment):
    return AdminJobs(georefid = georeferenceprocess.id, processed = False, setto = setto,
                     timestamp = convertTimestampToPostgisString(datetime.now()), comment = comment, userid = userid)
示例#3
0
def georeferenceConfirm(request):
    """ The function persistent saves a georeference confirmation request

        :type request: pyramid.request
        :return: dict
        :raise: HTTPBadRequest
        :raise: HTTPInternalServerError """
    LOGGER.info('Receive georeference validation request with parameters: %s' %
                request.json_body)

    try:
        # extract validation data
        LOGGER.debug('Parse request params ...')
        requestData = parseGeoreferenceParamsFromRequest(request)

        # in case of type new,
        # check if there already exist an actual georeference process for this object with this type
        if requestData[
                'type'] == 'new' and Georeferenzierungsprozess.isGeoreferenced(
                    requestData['mapObj'].id, request.db):
            msg = 'There exists already an active georeference process for this map id. It is therefore not possible to save a georeference process of type "new".'
            LOGGER.debug(msg)

            georeferenceid = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(
                requestData['mapObj'].id, request.db).id
            return {'text': msg, 'georeferenceid': georeferenceid}

        LOGGER.debug('Save georeference parameter in datase ...')
        timestamp = convertTimestampToPostgisString(datetime.now())
        georefParam = str(convertUnicodeDictToUtf(requestData['georeference']))
        overwrites = requestData[
            'overwrites'] if 'overwrites' in requestData else 0
        georefProcess = Georeferenzierungsprozess(
            messtischblattid=requestData['mapObj'].apsobjectid,
            nutzerid=requestData['userid'],
            georefparams=ast.literal_eval(georefParam),
            timestamp=timestamp,
            isactive=False,
            type=requestData['type'],
            overwrites=overwrites,
            adminvalidation='',
            processed=False,
            mapid=requestData['mapObj'].id,
            algorithm=requestData['georeference']['algorithm'])

        request.db.add(georefProcess)
        request.db.flush()

        # add polygon
        if 'clip' in requestData:
            clipParam = convertUnicodeDictToUtf(requestData['clip'])
            polygonAsString = convertListToPostgisString(
                clipParam['polygon'], 'POLYGON')
            georefProcess.setClip(polygonAsString,
                                  stripSRIDFromEPSG(clipParam['source']),
                                  request.db)

        LOGGER.debug('Create response ...')
        # @TODO has to be updated
        points = int(len(requestData['georeference']['gcps']) * 5)
        return {
            'text':
            'Georeference result saved. It will soon be ready for use.',
            'georeferenceid': georefProcess.id,
            'points': points
        }
    except ParameterException as e:
        LOGGER.error(e)
        LOGGER.error(traceback.format_exc())
        raise HTTPBadRequest(ERROR_MSG)
    except Exception as e:
        LOGGER.error(e)
        LOGGER.error(traceback.format_exc())
        raise HTTPInternalServerError(ERROR_MSG)