コード例 #1
0
def getGeneralMetadata(mapObj, request):
    """ Query the general metadata for a process response.

    :type mapObj: vkviewer.python.models.vkdb.Map
    :type request: pyramid.request
    :return: dict """
    metadataObj = Metadata.by_id(mapObj.id, request.db)
    return {
        'objectid': mapObj.id,
        'maptype': mapObj.maptype,
        'zoomify': metadataObj.imagezoomify,
        'metadata': {
            'dateiname': mapObj.apsdateiname,
            'title_long': metadataObj.title,
            'title_short': metadataObj.titleshort
        }
    }
コード例 #2
0
def getGeneralMetadata(mapObj, request):
    """ Query the general metadata for a process response.

    :type mapObj: vkviewer.python.models.vkdb.Map
    :type request: pyramid.request
    :return: dict """
    metadataObj = Metadata.by_id(mapObj.id, request.db)
    return {
        'objectid': mapObj.id,
        'maptype': mapObj.maptype,
        'zoomify': metadataObj.imagezoomify,
        'metadata': {
            'dateiname': mapObj.apsdateiname,
            'title_long': metadataObj.title,
            'title_short': metadataObj.titleshort
        }
    }
コード例 #3
0
ファイル: datamodel.py プロジェクト: slub/vk2-georeference
def createSearchRecord(mapObj, dbsession, logger, georefObj=None):
    """ Function creates an elasticsearch record for a given mapObj
        
    :type mapObj: vkviewer.python.models.vkdb.Map
    :type dbsession: sqlalchemy.orm.session.Session
    :type logger: logging.Logger
    :type georefObj: georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess|None
    """
    mapData = {}
    # check if map is georeferenced because only
    # georeferenced map should be published via the index
    metadataObj = Metadata.by_id(mapObj.id, dbsession)
    timepublish = metadataObj.timepublish.date()
    oai = OAI_ID_PATTERN%mapObj.id
    onlineResList = getOnlineResourceData(mapObj, metadataObj, metadataObj.timepublish.year, oai, dbsession)

    mapData["oai:de:slub-dresden:vk:id-%s"%mapObj.id] = {
        "id": mapObj.id,
        "dataid": mapObj.apsdateiname,
        "title": metadataObj.titleshort,
        "titlelong": metadataObj.title,
        "description": metadataObj.description,
        "online-resources": onlineResList,
        "denominator": int(metadataObj.scale.split(':')[1]),
        "keywords": ";".join([metadataObj.type,metadataObj.technic]),
        "time": "%s-%s-%s"%(timepublish.year, timepublish.month, timepublish.day),
        "plink": metadataObj.apspermalink,
        "org":metadataObj.imagejpg,
        "georeference": mapObj.isttransformiert,
        "maptype": mapObj.maptype,
        "thumb": metadataObj.thumbssmall,
        "zoomify":metadataObj.imagezoomify
    }
            
    # if there is a geometry then add it to the record
    boundingbox = None
    try:
        elasticsearchSRS = int(ELASTICSEARCH_SRS.split(':')[1])
        extent = mapObj.getExtent(dbsession, elasticsearchSRS)
        boundingbox = {
            "type": "polygon",
            "coordinates": [[
                [extent[0],extent[1]],
                [extent[0],extent[3]],
                [extent[2],extent[3]],
                [extent[2],extent[1]],
                [extent[0],extent[1]]
            ]]
        } 
    except AttributeError:
        logger.debug('Missing geometry')
        pass
            
    if boundingbox is not None and mapObj.isttransformiert:
        mapData[oai]["geometry"] = boundingbox

    # if georeferenced add tms cache
    if mapObj.isttransformiert:
        # create tms url
        file_name, file_extension = os.path.splitext(os.path.basename(mapObj.georefimage))
        tmsUrl = GEOREFERENCE_PERSITENT_TMS_URL + '/' + os.path.join(str(mapObj.maptype).lower(), file_name)
        mapData[oai]["tms"] = tmsUrl

    if georefObj is not None and georefObj.clip is not None:
        mapData[oai]["clippolygon"] = convertPostgisStringToList(georefObj.getClipAsString(dbsession, stripSRIDFromEPSG(ELASTICSEARCH_SRS.lower())))

    return mapData
コード例 #4
0
def createSearchRecord(mapObj, dbsession, logger, georefObj=None):
    """ Function creates an elasticsearch record for a given mapObj
        
    :type mapObj: vkviewer.python.models.vkdb.Map
    :type dbsession: sqlalchemy.orm.session.Session
    :type logger: logging.Logger
    :type georefObj: georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess|None
    """
    mapData = {}
    # check if map is georeferenced because only
    # georeferenced map should be published via the index
    metadataObj = Metadata.by_id(mapObj.id, dbsession)
    timepublish = metadataObj.timepublish.date()
    oai = OAI_ID_PATTERN % mapObj.id
    onlineResList = getOnlineResourceData(mapObj, metadataObj,
                                          metadataObj.timepublish.year, oai,
                                          dbsession)

    mapData["oai:de:slub-dresden:vk:id-%s" % mapObj.id] = {
        "id": mapObj.id,
        "dataid": mapObj.apsdateiname,
        "title": metadataObj.titleshort,
        "titlelong": metadataObj.title,
        "description": metadataObj.description,
        "online-resources": onlineResList,
        "denominator": int(metadataObj.scale.split(':')[1]),
        "keywords": ";".join([metadataObj.type, metadataObj.technic]),
        "time":
        "%s-%s-%s" % (timepublish.year, timepublish.month, timepublish.day),
        "plink": metadataObj.apspermalink,
        "org": metadataObj.imagejpg,
        "georeference": mapObj.isttransformiert,
        "maptype": mapObj.maptype,
        "thumb": metadataObj.thumbssmall,
        "zoomify": metadataObj.imagezoomify
    }

    # if there is a geometry then add it to the record
    boundingbox = None
    try:
        elasticsearchSRS = int(ELASTICSEARCH_SRS.split(':')[1])
        extent = mapObj.getExtent(dbsession, elasticsearchSRS)
        boundingbox = {
            "type":
            "polygon",
            "coordinates": [[[extent[0], extent[1]], [extent[0], extent[3]],
                             [extent[2], extent[3]], [extent[2], extent[1]],
                             [extent[0], extent[1]]]]
        }
    except AttributeError:
        logger.debug('Missing geometry')
        pass

    if boundingbox is not None and mapObj.isttransformiert:
        mapData[oai]["geometry"] = boundingbox

    # if georeferenced add tms cache
    if mapObj.isttransformiert:
        # create tms url
        file_name, file_extension = os.path.splitext(
            os.path.basename(mapObj.georefimage))
        tmsUrl = GEOREFERENCE_PERSITENT_TMS_URL + '/' + os.path.join(
            str(mapObj.maptype).lower(), file_name)
        mapData[oai]["tms"] = tmsUrl

    if georefObj is not None and georefObj.clip is not None:
        mapData[oai]["clippolygon"] = convertPostgisStringToList(
            georefObj.getClipAsString(
                dbsession, stripSRIDFromEPSG(ELASTICSEARCH_SRS.lower())))

    return mapData