Ejemplo n.º 1
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')
        object = Messtischblatt.by_id(object_id, dbsession)
        spatial_relation_objects = Messtischblatt.allForBlattnr(
            object.blattnr, dbsession)
        response = []
        for rel_object in spatial_relation_objects:
            if rel_object.isttransformiert:
                time = MdZeit.by_id(rel_object.id, dbsession).datierung
                response.append({
                    'id':
                    rel_object.id,
                    'time':
                    time,
                    'extent':
                    Messtischblatt.getExtent(rel_object.id, dbsession)
                })
        return json.dumps({'maps': response},
                          ensure_ascii=False,
                          encoding='utf-8')
    except DBAPIError:
        return Response(conn_err_msg,
                        content_type='text/plain',
                        status_int=500)
Ejemplo n.º 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
Ejemplo n.º 3
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        
Ejemplo n.º 4
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')
        object = Messtischblatt.by_id(object_id, dbsession)
        spatial_relation_objects = Messtischblatt.allForBlattnr(object.blattnr, dbsession)
        response = []
        for rel_object in spatial_relation_objects:
            if rel_object.isttransformiert:
                time = MdZeit.by_id(rel_object.id, dbsession).datierung
                response.append({'id':rel_object.id,'time':time,'extent':Messtischblatt.getExtent(rel_object.id, dbsession)})
        return json.dumps({'maps':response}, ensure_ascii=False, encoding='utf-8')
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
Ejemplo n.º 5
0
def getMetadataForMesstischblatt(id, db, logger):
    try:
        logger.debug('Start collection metadata information')
        mtb = Messtischblatt.by_id(id, db)
        metadata_core = MdCore.by_id(id, db)
        
        mdZeit = MdZeit.by_id(id, db)
        if mdZeit.datierung is None:
            metadata_time = ''
        else: 
            metadata_time = mdZeit.datierung
        metadata_dataset = MdDatensatz.by_ObjectId(id, db)
        
        logger.debug('Metadata collection finish. Creating response')
        metadata = {
                    'westBoundLongitude':str(mtb.BoundingBoxObj.llc.x),
                    'eastBoundLongitude':str(mtb.BoundingBoxObj.urc.x),
                    'southBoundLatitude':str(mtb.BoundingBoxObj.llc.y),
                    'northBoundLatitude':str(mtb.BoundingBoxObj.urc.y),
                    'identifier':'vk20-md-%s'%mtb.id,
                    'dateStamp': datetime.now().strftime('%Y-%m-%d'),
                    'title': metadata_core.titel,
                    'cite_date': str(metadata_time),
                    'abstract': metadata_core.beschreibung,
                    'temporalExtent_begin': '%s-01-01'%metadata_time,
                    'temporalExtent_end': '%s-12-31'%metadata_time,
                    'permalink': metadata_dataset.permalink, 
                    'hierarchylevel': 'Messtischblatt' if mtb.mdtype == 'M' else 'Äquidistantenkarte', 
                    'overviews': [
#                         'http://fotothek.slub-dresden.de/mids/df/dk/0010000/%s.jpg'%mtb.dateiname,
#                         
#                         TEMPLATE_OGC_SERVICE_LINK['wms_template']%({
#                             'westBoundLongitude':str(mtb.BoundingBoxObj.llc.x),
#                             'southBoundLatitude':str(mtb.BoundingBoxObj.llc.y),
#                             'eastBoundLongitude':str(mtb.BoundingBoxObj.urc.x),
#                             'northBoundLatitude':str(mtb.BoundingBoxObj.urc.y),
#                             'srid':DATABASE_SRID,
#                             'time':metadata_time.datierung,
#                             'width':256,
#                             'height':256
#                         }),
                        'http://fotothek.slub-dresden.de/thumbs/df/dk/0010000/%s.jpg'%mtb.dateiname
                    ],
                    'wms_params': {
                        'westBoundLongitude':str(mtb.BoundingBoxObj.llc.x),
                        'southBoundLatitude':str(mtb.BoundingBoxObj.llc.y),
                        'eastBoundLongitude':str(mtb.BoundingBoxObj.urc.x),
                        'northBoundLatitude':str(mtb.BoundingBoxObj.urc.y),
                        'srid':DATABASE_SRID,
                        'time':metadata_time,
                        'width':256,
                        'height':256
                    },
                    'onlineresource':[
                        {
                            'url':'http://kartenforum.slub-dresden.de/vkviewer/permalink?objectid=%s'%mtb.id,
                            'protocol':'HTTP',
                            'name':'Permalink'
                        },
                        {
                            'url':TEMPLATE_OGC_SERVICE_LINK['wms_template']%({
                                'westBoundLongitude':str(mtb.BoundingBoxObj.llc.x),
                                'southBoundLatitude':str(mtb.BoundingBoxObj.llc.y),
                                'eastBoundLongitude':str(mtb.BoundingBoxObj.urc.x),
                                'northBoundLatitude':str(mtb.BoundingBoxObj.urc.y),
                                'srid':DATABASE_SRID,
                                'time':metadata_time,
                                'width':256,
                                'height':256
                            }),
                            'protocol':'OGC:WMS-1.1.1-http-get-map',
                            'name':'WEB MAP SERVICE (WMS)'
                        },
                        {
                            'url':metadata_dataset.permalink,
                            'protocol':'HTTP',
                            'name':'Permalink'
                        }                        
                    ]
        }
        return metadata
    except:
        logger.error('Problems while trying to collect the metadata for the messtischblatt with id %s'%id)
        raise