コード例 #1
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)
コード例 #2
0
def getPermalinkForObjectidv2(request):
    """ Contains a permalink url for the given objectid"""
    try:
        log.info('Receive get permalink request.')
        objectid = request.GET.get('objectid')
        dbsession = request.db
        centroid = Map.getCentroid_byApsObjectid(objectid, dbsession, 900913)     
        mapid = Map.by_apsObjectId(objectid, dbsession).id
        return HTTPFound(location=request.host_url + '/vkviewer/?welcomepage=off&z=5&c=%s,%s&oid=%s'%(centroid[0],centroid[1],mapid))
    except DBAPIError:
        log.error(traceback.format_exc())
        raise HTTPBadRequest(GENERAL_ERROR_MESSAGE)
コード例 #3
0
ファイル: GetPermalink.py プロジェクト: slub/vkviewer
def createPermalink(request, objectid):
    try:
        dbsession = request.db
        centroid = Map.getCentroid(objectid, dbsession, 900913)
        return request.host_url + '/vkviewer/?welcomepage=off&z=5&c=%s,%s&oid=%s'%(centroid[0],centroid[1],objectid)
    except NotFoundException:
        raise NotFoundException('Could not create permalink!')
コード例 #4
0
ファイル: adminjobs.py プロジェクト: UAVE6MN/vkviewer
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'
コード例 #5
0
ファイル: GetWelcomePage.py プロジェクト: slub/vkviewer
def getWelcomePage(request):  
    log.info('Call view get_welcome_page.')
    try:
        dbsession = request.db
        # get occurrence of georeferenced messtischblaetter
        occurrenceGeorefMtbs = Map.getCountIsGeoref(dbsession)
        possibleMtbs = Map.getCountIsActive(dbsession)
        georefRelation = int((float(occurrenceGeorefMtbs) / float(possibleMtbs)) * 100) 
        # get paginator for user ranking list
        paginator = Users.get_paginator(request, dbsession)
        return {'paginator':paginator,'occurrence_mtbs':occurrenceGeorefMtbs, 'possible_mtbs': possibleMtbs, 'georef_rel': georefRelation}
    except Exception:
        log.error('Error while creating paginator for user georeference ranking')
        log.error(Exception)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
コード例 #6
0
def getPage_profileMtb(request):
    try:
        messtischblatt_id = None
        if 'objectid' in request.params:
            maps_id = request.params['objectid']
            log.info('Receive get map profile page for id %s.'%messtischblatt_id)
        
        georef = False
        if 'georef' in request.params and request.params['georef'].lower() == 'true':
            georef = True
        
        if georef:
            permalink = createPermalink(request, maps_id)
            return HTTPFound(location=permalink)
        
        mapObj = Map.by_id(maps_id, request.db)                
        metadata = Metadata.by_id(maps_id, request.db)        
        oai = createOAI(mapObj.id)
        
        return {'zoomify':metadata.imagezoomify,'key':oai,
                'titel_long': metadata.title,'titel_short': metadata.titleshort, 'permalink': metadata.apspermalink}
    except:
        log.error('Internal server error while trying to get profile page. Please try again or contact the page administrator.')
        log.error(traceback.format_exc())
        raise InternalAuthentificationError('Internal server error while trying to get profile page. Please try again or contact the page administrator.')
コード例 #7
0
ファイル: GeoreferenceProfile.py プロジェクト: slub/vkviewer
def georeference_profile_page(request):
    log.info('Request - Get georeference profile page.')
    dbsession = request.db
    userid = checkIsUser(request)
    user = Users.by_username(userid, dbsession)
    try:
        log.debug('Query georeference profile information from database for user %s'%userid)
        queryData = request.db.query(Georeferenzierungsprozess, Metadata, Map).join(Metadata, Georeferenzierungsprozess.mapid == Metadata.mapid)\
            .join(Map, Georeferenzierungsprozess.mapid == Map.id)\
            .filter(Georeferenzierungsprozess.nutzerid == userid)\
            .order_by(desc(Georeferenzierungsprozess.id))

        log.debug('Create response list')
        georef_profile = []
        for record in queryData:
            georef = record[0]
            metadata = record[1]
            mapObj = record[2]
            boundingbox = Map.getBox2d(georef.mapid, dbsession, 900913)
            georef_profile.append({'georef_id':georef.id, 'mapid':georef.mapid, 
                    'clip_params': georef.georefparams, 'time': metadata.timepublish, 'transformed': georef.processed,
                    'isvalide': georef.adminvalidation, 'titel': metadata.title, 'key': mapObj.apsdateiname,
                    'time_georef':georef.timestamp,'boundingbox':boundingbox[4:-1].replace(' ',','),'type':georef.type,
                    'published':georef.processed})
             
        log.debug('Response: %s'%georef_profile) 
        
        return {'georef_profile':georef_profile, 'points':user.bonuspunkte}
    except Exception as e:
        log.error('Error while trying to request georeference history information');
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
コード例 #8
0
def getTimestampsForId(request):
    """ Returns a json document which contains a a list of messtischblatt tuples which
        have the same blattnumber like the given object. """
    try:
        log.info('Receive request for timestamps for a given object number.')
        dbsession = request.db
        object_id = request.GET.get('id')
        metadataObj = Metadata.by_id(object_id, dbsession)
        spatial_relation_objects = VBlattschnittMtb.allForBlattnr(
            metadataObj.blattnr, dbsession)

        #create response
        response = []
        for rel_object in spatial_relation_objects:
            if rel_object.isttransformiert:
                response.append({
                    'id':
                    rel_object.mapid,
                    'time':
                    rel_object.time,
                    'extent':
                    Map.getExtent(rel_object.map, dbsession, DATABASE_SRID)
                })
        return {'maps': response}
    except DBAPIError as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
コード例 #9
0
ファイル: InsertMetadata.py プロジェクト: slub/vkviewer
def getMetadataForMapObj(id, db, logger):
    try:
        logger.debug('Start collection metadata information')
        mapObj = Map.by_id(id, db)
        metadataObj = Metadata.by_id(id, db)
        # metadata_core = MdCore.by_id(mapObj.apsobjectid, db)
        bbox_4326 = Map.getBoundingBoxObjWithEpsg(id, db, 4326)
        
        # create metadata record id 
        oai = createOAI(mapObj.id)

        bbox_srid =  Map.getBoundingBoxObjWithEpsg(mapObj.id, db, DATABASE_SRID)
        onlineResList = getOnlineResourceData(mapObj, metadataObj, metadataObj.timepublish.year, bbox_srid, oai)
        
        logger.debug('Metadata collection finish. Creating response')
        metadata = {
                    'westBoundLongitude':str(bbox_4326.llc.x),
                    'eastBoundLongitude':str(bbox_4326.urc.x),
                    'southBoundLatitude':str(bbox_4326.llc.y),
                    'northBoundLatitude':str(bbox_4326.urc.y),
                    'identifier':oai,
                    'dateStamp': datetime.now().strftime('%Y-%m-%d'),
                    'title': metadataObj.title,
                    'cite_date': str(metadataObj.timepublish.year),
                    'abstract': metadataObj.description,
                    'temporalExtent_begin': '%s-01-01'%metadataObj.timepublish.year,
                    'temporalExtent_end': '%s-12-31'%metadataObj.timepublish.year,
                    'hierarchylevel': 'Messtischblatt' if mapObj.maptype == 'M' else 'Äquidistantenkarte', 
                    'overviews': [
                        'http://fotothek.slub-dresden.de/thumbs/df/dk/0010000/%s.jpg'%mapObj.apsdateiname
                    ],
                    'wms_params': {
                        'westBoundLongitude':str(bbox_srid.llc.x),
                        'southBoundLatitude':str(bbox_srid.llc.y),
                        'eastBoundLongitude':str(bbox_srid.urc.x),
                        'northBoundLatitude':str(bbox_srid.urc.y),
                        'srid':DATABASE_SRID,
                        'time':metadataObj.timepublish.year,
                        'width':256,
                        'height':256
                    },
                    'onlineresource':onlineResList
        }
        return metadata
    except:
        logger.error('Problems while trying to collect the metadata for the messtischblatt with id %s'%id)
        raise
コード例 #10
0
def createPermalink(request, objectid):
    try:
        dbsession = request.db
        centroid = Map.getCentroid(objectid, dbsession, 900913)
        return request.host_url + '/vkviewer/?welcomepage=off&z=5&c=%s,%s&oid=%s' % (
            centroid[0], centroid[1], objectid)
    except NotFoundException:
        raise NotFoundException('Could not create permalink!')
コード例 #11
0
def georeference_profile_page(request):
    log.info('Request - Get georeference profile page.')
    dbsession = request.db
    userid = checkIsUser(request)
    user = Users.by_username(userid, dbsession)
    try:
        log.debug(
            'Query georeference profile information from database for user %s'
            % userid)
        queryData = request.db.query(Georeferenzierungsprozess, Metadata, Map).join(Metadata, Georeferenzierungsprozess.mapid == Metadata.mapid)\
            .join(Map, Georeferenzierungsprozess.mapid == Map.id)\
            .filter(Georeferenzierungsprozess.nutzerid == userid)\
            .order_by(desc(Georeferenzierungsprozess.id))

        log.debug('Create response list')
        georef_profile = []
        for record in queryData:
            georef = record[0]
            metadata = record[1]
            mapObj = record[2]
            boundingbox = Map.getBox2d(georef.mapid, dbsession, 900913)
            georef_profile.append({
                'georef_id':
                georef.id,
                'mapid':
                georef.mapid,
                'clip_params':
                georef.georefparams,
                'time':
                metadata.timepublish,
                'transformed':
                georef.processed,
                'isvalide':
                georef.adminvalidation,
                'titel':
                metadata.title,
                'key':
                mapObj.apsdateiname,
                'time_georef':
                georef.timestamp,
                'boundingbox':
                boundingbox[4:-1].replace(' ', ','),
                'type':
                georef.type,
                'published':
                georef.processed
            })

        log.debug('Response: %s' % georef_profile)

        return {'georef_profile': georef_profile, 'points': user.bonuspunkte}
    except Exception as e:
        log.error(
            'Error while trying to request georeference history information')
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
コード例 #12
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
コード例 #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)
コード例 #14
0
def processGeorefImage(mapObj, georefParams, dbsession, logger):
    clip_polygon = Map.getBoundingBoxObjWithEpsg(
        mapObj.id, dbsession, DATABASE_SRID).asShapefile(
            os.path.join(TMP_DIR, mapObj.apsdateiname + 'clip_polygon'))
    destPath = georeference(
        mapObj.originalimage,
        os.path.join(GEOREF_TARGET_DIR,
                     mapObj.apsdateiname + '.tif'), TMP_DIR, georefParams,
        DATABASE_SRID, DATABASE_SRID, 'polynom', logger, clip_polygon)
    addOverviews(destPath, '2 4 8 16 32', logger)
    return destPath
コード例 #15
0
ファイル: parser.py プロジェクト: slub/vkviewer
def parseMapObjForId(request_data, name, dbsession):
    """ This functions parses a map objectid from an objectid """
    if name in request_data:
        validateId(request_data[name])         
        # @deprecated     
        # do mapping for support of new name schema
        mapObj = Map.by_id(int(request_data[name]), dbsession)
        if mapObj is None:
            raise GeoreferenceParameterError('Missing or wrong objectid parameter.')           
        else:
            return mapObj
    raise GeoreferenceParameterError('Missing or wrong objectid parameter.')  
コード例 #16
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
コード例 #17
0
ファイル: parser.py プロジェクト: UAVE6MN/vkviewer
def parseMapObjForId(request_data, name, dbsession):
    """ This functions parses a map objectid from an objectid """
    if name in request_data:
        validateId(request_data[name])
        # @deprecated
        # do mapping for support of new name schema
        mapObj = Map.by_id(int(request_data[name]), dbsession)
        if mapObj is None:
            raise GeoreferenceParameterError(
                'Missing or wrong objectid parameter.')
        else:
            return mapObj
    raise GeoreferenceParameterError('Missing or wrong objectid parameter.')
コード例 #18
0
def getWelcomePage(request):
    log.info('Call view get_welcome_page.')
    try:
        dbsession = request.db
        # get occurrence of georeferenced messtischblaetter
        occurrenceGeorefMtbs = Map.getCountIsGeoref(dbsession)
        possibleMtbs = Map.getCountIsActive(dbsession)
        georefRelation = int(
            (float(occurrenceGeorefMtbs) / float(possibleMtbs)) * 100)
        # get paginator for user ranking list
        paginator = Users.get_paginator(request, dbsession)
        return {
            'paginator': paginator,
            'occurrence_mtbs': occurrenceGeorefMtbs,
            'possible_mtbs': possibleMtbs,
            'georef_rel': georefRelation
        }
    except Exception:
        log.error(
            'Error while creating paginator for user georeference ranking')
        log.error(Exception)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
コード例 #19
0
def runNewGeoreferenceProcess(georefProcess, dbsession, logger, testing = False):
    """ This function process new georeference result for a given map object.
        
        @param vkviewer.python.models.messtischblatt.AdminJobs: georefProcess
        @param sqlalchemy.orm.session.Session: dbsession
        @param logging.Logger: logger
        @param boolean: testing (Default: False)
    """ 
    logger.info('Run georeference process with type "new" with id %s ...'%georefProcess.id)
    mapObj = Map.by_id(georefProcess.mapid, dbsession)
    logger.info('Activate new georeference processes ...')
    activate(georefProcess, mapObj, dbsession, logger)    
    
    
コード例 #20
0
def createServiceDescription(template_path, target_dir, db, logger, wcs=False):
    logger.debug('Start creating service description')

    # create tempory copy
    mdServiceFile = os.path.join(target_dir, str(uuid.uuid4()) + '.xml')
    shutil.copyfile(template_path, mdServiceFile)

    # Helper method which define the prefix of the namespaces
    for key in Namespaces:
        ET.register_namespace(key, Namespaces[key].strip('}').strip('{'))

    # parse xml template file
    xmlTree = ET.parse(mdServiceFile)
    xmlElementRoot = xmlTree.getroot()

    # search xml element srv:SV_ServiceIdentification
    searchHierarchy = [
        Namespaces['gmd'] + 'identificationInfo',
        Namespaces['srv'] + 'SV_ServiceIdentification'
    ]
    xmlElementServiceId = xmlElementRoot.find('/'.join(searchHierarchy))

    # get all messtischblaetter
    maps = Map.all(db)
    logger.debug('Start appending new messtischblatt resources')
    for mapObj in maps:
        if mapObj.isttransformiert:
            metadataObj = Metadata.by_id(mapObj.id, db)

            if wcs:
                if metadataObj.timepublish.year <= 1900:
                    oai = createOAI(mapObj.id)
                    appendCoupledResource(rootElement=xmlElementServiceId,
                                          resourceId=oai,
                                          resourceTitle=metadataObj.title)
            else:
                oai = createOAI(mapObj.id)
                appendCoupledResource(rootElement=xmlElementServiceId,
                                      resourceId=oai,
                                      resourceTitle=metadataObj.title)

    logger.debug('Save modified file in %s.' % mdServiceFile)

    #     print 'Service document'
    #     print '================'
    #     print ET.tostring(xmlElementRoot, encoding='utf-8', method='xml')

    xmlTree.write(mdServiceFile, encoding="utf-8", xml_declaration=True)
    return mdServiceFile
コード例 #21
0
def createGeneralResponse(mapObj, request):
    log.debug('Create general response ...')

    isAlreadyGeorefProcess = Georeferenzierungsprozess.isGeoreferenced(
        mapObj.id, request.db)
    if isAlreadyGeorefProcess:
        return createResponseForSpecificGeoreferenceProcess(mapObj, request)
    else:
        mtb_extent = Map.getExtent(mapObj.id, request.db)
        gcps = {
            'source':
            'pixel',
            'target':
            'EPSG:4314',
            'gcps': [{
                "source": [],
                "target": [mtb_extent[0], mtb_extent[1]]
            }, {
                "source": [],
                "target": [mtb_extent[0], mtb_extent[3]]
            }, {
                "source": [],
                "target": [mtb_extent[2], mtb_extent[1]]
            }, {
                "source": [],
                "target": [mtb_extent[2], mtb_extent[3]]
            }]
        }

        # get zoomify and metadata information
        log.debug('Create response ...')
        metadata = Metadata.by_id(mapObj.id, request.db)
        return {
            'type': 'new',
            'objectid': mapObj.id,
            'georeferenceid': "",
            'timestamp': "",
            'gcps': gcps,
            'extent': mtb_extent,
            'zoomify': metadata.imagezoomify,
            'metadata': {
                'dateiname': mapObj.apsdateiname,
                'titel_long': metadata.title,
                'titel_short': metadata.titleshort
            }
        }
コード例 #22
0
def createServiceDescription(template_path, target_dir, db, logger, wcs = False):
    logger.debug('Start creating service description')
    
    # create tempory copy
    mdServiceFile = os.path.join( target_dir, str(uuid.uuid4()) + '.xml')
    shutil.copyfile(template_path, mdServiceFile)

    # Helper method which define the prefix of the namespaces
    for key in Namespaces:
        ET.register_namespace(key, Namespaces[key].strip('}').strip('{'))
        
    # parse xml template file
    xmlTree = ET.parse(mdServiceFile)
    xmlElementRoot = xmlTree.getroot()
    
    # search xml element srv:SV_ServiceIdentification
    searchHierarchy = [Namespaces['gmd']+'identificationInfo', Namespaces['srv']+'SV_ServiceIdentification']
    xmlElementServiceId = xmlElementRoot.find('/'.join(searchHierarchy))
        
    # get all messtischblaetter
    maps = Map.all(db)
    logger.debug('Start appending new messtischblatt resources')
    for mapObj in maps:
        if mapObj.isttransformiert:
            metadataObj = Metadata.by_id(mapObj.id, db)
            
            if wcs:
                if metadataObj.timepublish.year <= 1900:
                    oai = createOAI(mapObj.id)
                    appendCoupledResource(rootElement = xmlElementServiceId, resourceId = oai, resourceTitle = metadataObj.title)
            else: 
                oai = createOAI(mapObj.id)
                appendCoupledResource(rootElement = xmlElementServiceId, resourceId = oai, resourceTitle = metadataObj.title)
        

    logger.debug('Save modified file in %s.'%mdServiceFile)        
    
#     print 'Service document'
#     print '================'
#     print ET.tostring(xmlElementRoot, encoding='utf-8', method='xml')
    
    xmlTree.write(mdServiceFile, encoding="utf-8", xml_declaration=True)
    return mdServiceFile
コード例 #23
0
ファイル: updatejobs.py プロジェクト: slub/vkviewer
def runUpdateGeoreferenceProcess(georefProcess, dbsession, logger, testing = False):
    """ This function update the georeference result for a given map object.
        
        @param vkviewer.python.models.messtischblatt.AdminJobs: georefProcess
        @param sqlalchemy.orm.session.Session: dbsession
        @param logging.Logger: logger
        @param boolean: testing (Default: False)
    """ 
    logger.info('Run georeference process with type "update" with id %s ...'%georefProcess.id)
    
    activeGeorefProcess = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(georefProcess.mapid, dbsession)
    mapObj = Map.by_id(georefProcess.mapid, dbsession)
    
    logger.info('Deactivate old georeference processes ...')
    if activeGeorefProcess:
        deactivate(activeGeorefProcess, mapObj, dbsession, logger)
        
    logger.info('Activate new georeference processes ...')
    activate(georefProcess, mapObj, dbsession, logger)    
コード例 #24
0
def chooseGeoreferenceMap(request):
    log.info('Call view getPage_chooseGeorefMtb.')
    if 'blattnr' in request.params:
        log.debug('Look for unreferenced messtischblaetter')
        
        # get response from database
        collection = []
        metadata = Metadata.all_byBlattnr(request.GET.get('blattnr'), request.db)
        for record in metadata:
            map = Map.by_id(record.mapid, request.db)
            if map.istaktiv and not map.isttransformiert and map.hasgeorefparams == 0:
                item = {'mapid':map.id,'title':record.title}
                collection.append(item)
    
        log.debug('Create paginator for collection - %s'%collection)
        page_url = PageURL_WebOb(request)
        return {'paginator': Page(collection, 1, url=page_url, items_per_page=10)}
    else: 
        log.error('Could not find a blattnr parameter value ...')
        log.error(traceback.format_exc())
        raise HTTPBadRequest(ERROR_MSG) 
コード例 #25
0
ファイル: adminjobs.py プロジェクト: UAVE6MN/vkviewer
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
コード例 #26
0
def georeferenceValidation(request):
    log.info('Receive request for processing georeference validation result')
    
    try:
        request_data = None
        if request.method == 'POST':
            request_data = request.json_body
          
        mapObj = parseMapObjForId(request_data, 'id', request.db)
        log.debug('Id is valide: %s'%request_data)
                      
        log.debug('Start creating validation result ...')
        # actual only support this option if target srs is EPSG:4314
        epsg_code = int(str(request_data['georeference']['target']).split(':')[1])
        if request_data['georeference']['source'] == 'pixel' and epsg_code == 4314:
            log.debug('Parse gcps ...')
            gcps = parseGcps(request_data['georeference']['gcps'])
            
            log.debug('Process georeference parameter ...')
            destPath = georeference(mapObj.originalimage, os.path.join(GEOREFERENCE_MAPFILE_FOLDER,mapObj.apsdateiname+"::"+str(getUniqueId())+".vrt"), 
                         GEOREFERENCE_TMP_DIR, gcps, epsg_code, epsg_code, 'polynom', log)
        
            log.debug('Create temporary mapfile ...')
            wms_url = createMapfile(mapObj.apsdateiname, destPath, GEOREFERENCE_MAPFILE_TEMPLATE, GEOREFERENCE_MAPFILE_FOLDER, GEOREFERENCE_MAPFILE_DEFAULT_PARAMS)
            
            log.debug('Create response ...')  
            response = {'wms_url':wms_url,'layer_id':mapObj.apsdateiname,'extent':Map.getExtent(mapObj.id, request.db)}
            return response 
        else:
            raise GeoreferenceParameterError('Wrong or missing service parameter')
    except GeoreferenceParameterError as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPBadRequest(ERROR_MSG) 
    except Exception as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(ERROR_MSG)
コード例 #27
0
def createGeneralResponse(mapObj, request):
    log.debug('Create general response ...')
    
    isAlreadyGeorefProcess = Georeferenzierungsprozess.isGeoreferenced(mapObj.id, request.db)
    if isAlreadyGeorefProcess:
        return createResponseForSpecificGeoreferenceProcess(mapObj, request)
    else: 
        mtb_extent = Map.getExtent(mapObj.id, request.db)
        gcps = {
            'source':'pixel',
            'target':'EPSG:4314',
            'gcps': [
                {"source":[], "target":[mtb_extent[0],mtb_extent[1]]},
                {"source":[], "target":[mtb_extent[0],mtb_extent[3]]},
                {"source":[], "target":[mtb_extent[2],mtb_extent[1]]},
                {"source":[], "target":[mtb_extent[2],mtb_extent[3]]}
            ]
        }
            
        # get zoomify and metadata information
        log.debug('Create response ...')  
        metadata = Metadata.by_id(mapObj.id, request.db)
        return {
                'type':'new',
                'objectid': mapObj.id,
                'georeferenceid':"", 
                'timestamp':"", 
                'gcps':gcps, 
                'extent': mtb_extent,
                'zoomify': metadata.imagezoomify,
                'metadata': {
                    'dateiname': mapObj.apsdateiname,
                    'titel_long': metadata.title,
                    'titel_short': metadata.titleshort
                }            
        }
コード例 #28
0
def runUpdateGeoreferenceProcess(georefProcess,
                                 dbsession,
                                 logger,
                                 testing=False):
    """ This function update the georeference result for a given map object.
        
        @param vkviewer.python.models.messtischblatt.AdminJobs: georefProcess
        @param sqlalchemy.orm.session.Session: dbsession
        @param logging.Logger: logger
        @param boolean: testing (Default: False)
    """
    logger.info('Run georeference process with type "update" with id %s ...' %
                georefProcess.id)

    activeGeorefProcess = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(
        georefProcess.mapid, dbsession)
    mapObj = Map.by_id(georefProcess.mapid, dbsession)

    logger.info('Deactivate old georeference processes ...')
    if activeGeorefProcess:
        deactivate(activeGeorefProcess, mapObj, dbsession, logger)

    logger.info('Activate new georeference processes ...')
    activate(georefProcess, mapObj, dbsession, logger)
コード例 #29
0
def chooseGeoreferenceMap(request):
    log.info('Call view getPage_chooseGeorefMtb.')
    if 'blattnr' in request.params:
        log.debug('Look for unreferenced messtischblaetter')

        # get response from database
        collection = []
        metadata = Metadata.all_byBlattnr(request.GET.get('blattnr'),
                                          request.db)
        for record in metadata:
            map = Map.by_id(record.mapid, request.db)
            if map.istaktiv and not map.isttransformiert and map.hasgeorefparams == 0:
                item = {'mapid': map.id, 'title': record.title}
                collection.append(item)

        log.debug('Create paginator for collection - %s' % collection)
        page_url = PageURL_WebOb(request)
        return {
            'paginator': Page(collection, 1, url=page_url, items_per_page=10)
        }
    else:
        log.error('Could not find a blattnr parameter value ...')
        log.error(traceback.format_exc())
        raise HTTPBadRequest(ERROR_MSG)
コード例 #30
0
ファイル: GetTimestampsForId.py プロジェクト: slub/vkviewer
def getTimestampsForId(request):
    """ Returns a json document which contains a a list of messtischblatt tuples which
        have the same blattnumber like the given object. """
    try:
        log.info('Receive request for timestamps for a given object number.')
        dbsession = request.db
        object_id = request.GET.get('id')
        metadataObj = Metadata.by_id(object_id, dbsession)
        spatial_relation_objects = VBlattschnittMtb.allForBlattnr(metadataObj.blattnr, dbsession)
        
        #create response
        response = []
        for rel_object in spatial_relation_objects:
            if rel_object.isttransformiert:
                response.append({'id':rel_object.mapid,'time':rel_object.time,'extent': Map.getExtent(rel_object.map, dbsession, DATABASE_SRID)})
        return {'maps':response}
    except DBAPIError as e:
        log.error(e)
        log.error(traceback.format_exc())
        raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
コード例 #31
0
ファイル: UploadAPI.py プロジェクト: UAVE6MN/vkviewer
def store_image(request):
    try:
        log.debug('Receive a upload request.')
        username = checkIsUser(request)
        user = Users.by_username(username, request.db)

        # check if need metadata is send
        log.debug('Check if mandatory metadata is send ...')
        params = request.params
        if not 'title' in params or not 'titleshort' in params or \
                not 'imagelicence' in params or not 'imageowner' in params:
            raise MissingQueryParameterError('Missing query parameter ...')

        # register upload process in database
        log.debug('Register upload process to database ...')
        uploadObj = Uploads(userid=user.id,
                            time=getTimestampAsPGStr(),
                            params='%s' % request.params)
        request.db.add(uploadObj)

        log.debug('Create and add mapObj ...')
        mapObj = Map(istaktiv=False,
                     isttransformiert=False,
                     maptype='A',
                     hasgeorefparams=0)
        request.db.add(mapObj)
        request.db.flush()

        # check if image allowed extensions
        # ``filename`` contains the name of the file in string format.
        log.debug('Create filename for persistent saving ...')
        filename = request.POST['file'].filename
        if not allowed_file(filename):
            raise WrongParameterException(
                'Format of the image is not supported through the upload API.')

        # ``input_file`` contains the actual file data which needs to be
        # stored somewhere.
        inputFile = request.POST['file'].file

        # Note that we are generating our own filename instead of trusting
        # the incoming filename since that might result in insecure paths.
        # Please note that in a real application you would not use /tmp,
        # and if you write to an untrusted location you will need to do
        # some extra work to prevent symlink attacks.
        newFilename = '%s.%s' % ('df_dk_%s' % mapObj.id, filename.rsplit(
            '.', 1)[1])
        filePath = os.path.join(UPLOAD_DIR, newFilename)

        # save file to disk
        log.debug('Save file to datastore ...')
        saveFile(inputFile, filePath)

        # process thumbnails
        log.debug('Create thumbnails ...')
        thumbSmall = createSmallThumbnail(filePath, UPLOAD_THUMBS_SMALL_DIR)
        thumbMid = createMidThumbnail(filePath, UPLOAD_THUMBS_MID_DIR)
        log.debug('Create zoomify tiles')
        zoomifyTiles = processZoomifyTiles(filePath, UPLOAD_ZOOMIFY_DIR, log)

        # parse boundinbBox
        pgBoundingBoxStr = parseBoundingBoxFromRequest(request.params)

        # add geometry to map object and update other attributes
        # work around --> should be replaced through adding the geomtry on initial adding
        log.debug('Update mapObj and create metadataObj ...')
        mapObj.apsdateiname = newFilename
        mapObj.originalimage = filePath
        Map.updateGeometry(mapObj.id, pgBoundingBoxStr, request.db)
        request.db.flush()

        # parse and create metadataObj
        if 'title' in request.params:
            title = request.params['title']
        if 'titleshort' in request.params:
            titleshort = request.params['titleshort']
        if 'serientitle' in request.params:
            serientitle = request.params['serientitle']
        if 'description' in request.params:
            description = request.params['description']
        if 'timepublish' in request.params:
            timepublish = request.params['timepublish']
        if 'imagelicence' in request.params:
            imagelicence = request.params['imagelicence']
        if 'scale' in request.params:
            scale = request.params['scale']
        if 'imageowner' in request.params:
            imageowner = request.params['imageowner']

        # create metadata obj
        # the creating of the paths are right now quite verbose
        imagezoomify = UPLOAD_SERVICE_URL_ZOOMIFY + os.path.basename(
            filePath).split('.')[0] + '/ImageProperties.xml'
        thumbssmall = UPLOAD_SERVICE_URL_THUMBS_SMALL + os.path.basename(
            thumbSmall)
        thumbsmid = UPLOAD_SERVICE_URL_THUMBS_MID + os.path.basename(thumbMid)
        metadataObj = Metadata(mapid=mapObj.id,
                               title=title,
                               titleshort=titleshort,
                               serientitle=serientitle,
                               description=description,
                               timepublish="%s-01-01 00:00:00" % (timepublish),
                               imagelicence=imagelicence,
                               imageowner=imageowner,
                               scale=scale,
                               imagezoomify=imagezoomify,
                               thumbssmall=thumbssmall,
                               thumbsmid=thumbsmid)
        request.db.add(metadataObj)

        # update uploadObj and create response
        uploadObj.mapid = mapObj.id

        log.debug('Create response ...')
        target_url = request.route_url('upload-profile')
        return HTTPFound(location=target_url)

    # Exception handling
    except NotFoundException as e:
        log.exception(e)
        ERR_MSG = GENERAL_ERROR_MESSAGE + "We're sorry, but something went wrong. Please be sure that your file respects the upload conditions."
        return HTTPBadRequest(ERR_MSG)
    except DBAPIError as e:
        log.error('Database error within a upload process')
        log.exception(e)
        return HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
    except MissingQueryParameterError or WrongParameterException as e:
        log.exception(e)
        raise HTTPBadRequest(GENERAL_ERROR_MESSAGE)
    except Exception as e:
        log.exception(e)
        raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
コード例 #32
0
ファイル: InsertMetadata.py プロジェクト: slub/vkviewer
        
        mdEditor.saveFile(file)
        return True
    except:
        logger.error('Problems while updating the metadata for the xml file %s'%file)
        raise




if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger('sqlalchemy.engine')
    dbSession = loadDbSession(DBCONFIG_PARAMS, logger) 
    # get all messtischblätter
    maps = Map.all(dbSession)
    counter = 0
    for mapObj in maps:
        if mapObj.isttransformiert:
            counter += 1
        if mapObj.isttransformiert and counter >= 0:
            print "========================"
            oai = createOAI(mapObj.id)
            response = gn_transaction_delete(oai, GN_SETTINGS['gn_username'], GN_SETTINGS['gn_password'], logger)
            print "Response - delete record"
            print "========================"
            response = insertMetadata(id=mapObj.id,db=dbSession,logger=logger)
            print response
            print "========================"
            print "Insert record number %s"%counter
            print "========================"
コード例 #33
0
ファイル: InsertMetadata.py プロジェクト: UAVE6MN/vkviewer
def getMetadataForMapObj(id, db, logger):
    try:
        logger.debug('Start collection metadata information')
        mapObj = Map.by_id(id, db)
        metadataObj = Metadata.by_id(id, db)
        # metadata_core = MdCore.by_id(mapObj.apsobjectid, db)
        bbox_4326 = Map.getBoundingBoxObjWithEpsg(id, db, 4326)

        # create metadata record id
        oai = createOAI(mapObj.id)

        bbox_srid = Map.getBoundingBoxObjWithEpsg(mapObj.id, db, DATABASE_SRID)
        onlineResList = getOnlineResourceData(mapObj, metadataObj,
                                              metadataObj.timepublish.year,
                                              bbox_srid, oai)

        logger.debug('Metadata collection finish. Creating response')
        metadata = {
            'westBoundLongitude':
            str(bbox_4326.llc.x),
            'eastBoundLongitude':
            str(bbox_4326.urc.x),
            'southBoundLatitude':
            str(bbox_4326.llc.y),
            'northBoundLatitude':
            str(bbox_4326.urc.y),
            'identifier':
            oai,
            'dateStamp':
            datetime.now().strftime('%Y-%m-%d'),
            'title':
            metadataObj.title,
            'cite_date':
            str(metadataObj.timepublish.year),
            'abstract':
            metadataObj.description,
            'temporalExtent_begin':
            '%s-01-01' % metadataObj.timepublish.year,
            'temporalExtent_end':
            '%s-12-31' % metadataObj.timepublish.year,
            'hierarchylevel':
            'Messtischblatt'
            if mapObj.maptype == 'M' else 'Äquidistantenkarte',
            'overviews': [
                'http://fotothek.slub-dresden.de/thumbs/df/dk/0010000/%s.jpg' %
                mapObj.apsdateiname
            ],
            'wms_params': {
                'westBoundLongitude': str(bbox_srid.llc.x),
                'southBoundLatitude': str(bbox_srid.llc.y),
                'eastBoundLongitude': str(bbox_srid.urc.x),
                'northBoundLatitude': str(bbox_srid.urc.y),
                'srid': DATABASE_SRID,
                'time': metadataObj.timepublish.year,
                'width': 256,
                'height': 256
            },
            'onlineresource':
            onlineResList
        }
        return metadata
    except:
        logger.error(
            'Problems while trying to collect the metadata for the messtischblatt with id %s'
            % id)
        raise
コード例 #34
0
ファイル: UploadAPI.py プロジェクト: slub/vkviewer
def store_image(request):
    try:
        log.debug('Receive a upload request.')
        username = checkIsUser(request)
        user = Users.by_username(username, request.db)

        # check if need metadata is send
        log.debug('Check if mandatory metadata is send ...')
        params = request.params
        if not 'title' in params or not 'titleshort' in params or \
                not 'imagelicence' in params or not 'imageowner' in params:
            raise MissingQueryParameterError('Missing query parameter ...')
        
        # register upload process in database
        log.debug('Register upload process to database ...')
        uploadObj = Uploads(userid = user.id, time = getTimestampAsPGStr(), params = '%s'%request.params)
        request.db.add(uploadObj)
        
        log.debug('Create and add mapObj ...')
        mapObj = Map(istaktiv = False, isttransformiert = False, maptype = 'A', hasgeorefparams = 0)
        request.db.add(mapObj)
        request.db.flush()
        
        # check if image allowed extensions
        # ``filename`` contains the name of the file in string format.
        log.debug('Create filename for persistent saving ...')
        filename = request.POST['file'].filename
        if not allowed_file(filename):
            raise WrongParameterException('Format of the image is not supported through the upload API.')
            
        
        # ``input_file`` contains the actual file data which needs to be
        # stored somewhere.
        inputFile = request.POST['file'].file
    
        # Note that we are generating our own filename instead of trusting
        # the incoming filename since that might result in insecure paths.
        # Please note that in a real application you would not use /tmp,
        # and if you write to an untrusted location you will need to do
        # some extra work to prevent symlink attacks.    
        newFilename = '%s.%s' % ('df_dk_%s'%mapObj.id, filename.rsplit('.', 1)[1])
        filePath = os.path.join(UPLOAD_DIR, newFilename)
    
        # save file to disk
        log.debug('Save file to datastore ...')
        saveFile(inputFile, filePath)
        
        # process thumbnails
        log.debug('Create thumbnails ...')
        thumbSmall = createSmallThumbnail(filePath, UPLOAD_THUMBS_SMALL_DIR)
        thumbMid = createMidThumbnail(filePath, UPLOAD_THUMBS_MID_DIR)   
        log.debug('Create zoomify tiles')    
        zoomifyTiles = processZoomifyTiles(filePath, UPLOAD_ZOOMIFY_DIR, log)
        
        # parse boundinbBox
        pgBoundingBoxStr = parseBoundingBoxFromRequest(request.params)
            
        # add geometry to map object and update other attributes
        # work around --> should be replaced through adding the geomtry on initial adding
        log.debug('Update mapObj and create metadataObj ...')
        mapObj.apsdateiname = newFilename
        mapObj.originalimage = filePath
        Map.updateGeometry(mapObj.id, pgBoundingBoxStr, request.db)        
        request.db.flush()
        
        # parse and create metadataObj
        if 'title' in request.params:
            title = request.params['title']
        if 'titleshort' in request.params:
            titleshort = request.params['titleshort']    
        if 'serientitle' in request.params:
            serientitle = request.params['serientitle'] 
        if 'description' in request.params:
            description = request.params['description']  
        if 'timepublish' in request.params:
            timepublish = request.params['timepublish']                         
        if 'imagelicence' in request.params:
            imagelicence = request.params['imagelicence']
        if 'scale' in request.params:
            scale = request.params['scale']
        if 'imageowner' in request.params:
            imageowner = request.params['imageowner']
           
        # create metadata obj 
        # the creating of the paths are right now quite verbose
        imagezoomify = UPLOAD_SERVICE_URL_ZOOMIFY + os.path.basename(filePath).split('.')[0] + '/ImageProperties.xml' 
        thumbssmall = UPLOAD_SERVICE_URL_THUMBS_SMALL + os.path.basename(thumbSmall)
        thumbsmid = UPLOAD_SERVICE_URL_THUMBS_MID + os.path.basename(thumbMid)
        metadataObj = Metadata(mapid = mapObj.id, title = title, titleshort = titleshort, 
                serientitle = serientitle, description = description, timepublish = "%s-01-01 00:00:00"%(timepublish), 
                imagelicence = imagelicence, imageowner = imageowner, scale = scale,
                imagezoomify = imagezoomify,
                thumbssmall = thumbssmall,
                thumbsmid = thumbsmid)
        request.db.add(metadataObj)
        
        # update uploadObj and create response
        uploadObj.mapid = mapObj.id
        
        log.debug('Create response ...')
        target_url = request.route_url('upload-profile')
        return HTTPFound(location = target_url)  
    
    # Exception handling     
    except NotFoundException as e:
        log.exception(e)
        ERR_MSG = GENERAL_ERROR_MESSAGE + "We're sorry, but something went wrong. Please be sure that your file respects the upload conditions."
        return HTTPBadRequest(ERR_MSG)
    except DBAPIError as e:
        log.error('Database error within a upload process')
        log.exception(e)
        return HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
    except MissingQueryParameterError or WrongParameterException as e:
        log.exception(e)
        raise HTTPBadRequest(GENERAL_ERROR_MESSAGE)
    except Exception as e:
        log.exception(e)
        raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
コード例 #35
0
ファイル: genericjobs.py プロジェクト: slub/vkviewer
def processGeorefImage(mapObj, georefParams, dbsession, logger):  
    clip_polygon = Map.getBoundingBoxObjWithEpsg(mapObj.id, dbsession, DATABASE_SRID).asShapefile(os.path.join(TMP_DIR, mapObj.apsdateiname+'clip_polygon'))
    destPath = georeference(mapObj.originalimage, os.path.join(GEOREF_TARGET_DIR, mapObj.apsdateiname+'.tif'), 
                TMP_DIR, georefParams, DATABASE_SRID, DATABASE_SRID, 'polynom', logger, clip_polygon)
    addOverviews(destPath, '2 4 8 16 32', logger)
    return destPath
コード例 #36
0
ファイル: InsertMetadata.py プロジェクト: UAVE6MN/vkviewer
        print '============================'

        mdEditor.saveFile(file)
        return True
    except:
        logger.error(
            'Problems while updating the metadata for the xml file %s' % file)
        raise


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger('sqlalchemy.engine')
    dbSession = loadDbSession(DBCONFIG_PARAMS, logger)
    # get all messtischblätter
    maps = Map.all(dbSession)
    counter = 0
    for mapObj in maps:
        if mapObj.isttransformiert:
            counter += 1
        if mapObj.isttransformiert and counter >= 0:
            print "========================"
            oai = createOAI(mapObj.id)
            response = gn_transaction_delete(oai, GN_SETTINGS['gn_username'],
                                             GN_SETTINGS['gn_password'],
                                             logger)
            print "Response - delete record"
            print "========================"
            response = insertMetadata(id=mapObj.id,
                                      db=dbSession,
                                      logger=logger)