Beispiel #1
0
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
Beispiel #2
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
Beispiel #3
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
Beispiel #4
0
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