Exemplo n.º 1
0
    def testProcessGeorefImage(self):
        print "--------------------------------------------------------------------------------------------"
        print "\n"
        print "Test if testProcessGeorefImage runs correctly ..."

        response = processGeorefImage(self.map, self.process, self.dbsession, self.logger)
        self.assertTrue(isinstance(response, str))
Exemplo n.º 2
0
def activate(georefObj, mapObj, dbsession, logger):
    """ This function activates a georeference process for a mapObj.

    :type georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess: georefObj
    :type georeference.models.vkdb.map.Map: mapObj
    :type sqlalchemy.orm.session.Session: dbSession
    :type logging.Logger: logger
    :return: string """
    logger.debug('Activate georeference process with id %s ...' % georefObj.id)

    logger.debug('Create persistent georeference result ...')
    destPath = processGeorefImage(mapObj, georefObj, dbsession, logger)

    # check if the georeferencing was run correctly
    if destPath is None:
        logger.error(
            'Something went wrong while trying to process a georeference process.'
        )
        raise GeoreferenceProcessingException(
            'Something went wrong while trying to process a georeference process.'
        )

    logger.debug('Set map as active and update boundingbox ...')
    boundingboxFromFile = parseBoundingBoxPolygonFromFile(destPath)
    sridFromFile = parseSRIDFromFile(destPath)
    mapObj.setActive(destPath)
    mapObj.setBoundingBox(boundingboxFromFile, sridFromFile, dbsession)

    # for proper working of the mapping service update all pending database changes have to be commited
    if not TEST_MODE:
        dbsession.commit()

    # update the tile map service
    logger.info('Calculating tms cache ...')
    newTargetDirectory = os.path.join(GEOREFERENCE_PERSITENT_TMS,
                                      str(mapObj.maptype).lower())
    calculateCompressedTMS(destPath, newTargetDirectory)

    # push metadata record to elasticsearch index
    datarecordKey = pushRecordToSearchIndex(mapObj, dbsession, logger,
                                            georefObj)

    # push metadata to catalogue
    # this method has to be supported again
    # logger.debug('Push metadata record for map %s to cataloge service ...'%mapObj.id)
    # pushMapObjToCsw(mapObj, dbsession, logger)

    # update process
    georefObj.setActive()

    # flush session
    if TEST_MODE:
        dbsession.flush()

    return datarecordKey
Exemplo n.º 3
0
def activate(georefObj, mapObj, dbsession, logger):
    """ This function activates a georeference process for a mapObj.

    :type georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess: georefObj
    :type georeference.models.vkdb.map.Map: mapObj
    :type sqlalchemy.orm.session.Session: dbSession
    :type logging.Logger: logger
    :return: string """
    logger.debug('Activate georeference process with id %s ...'%georefObj.id)

    logger.debug('Create persistent georeference result ...')
    destPath = processGeorefImage(mapObj, georefObj, dbsession, logger)

    # check if the georeferencing was run correctly
    if destPath is None:
        logger.error('Something went wrong while trying to process a georeference process.')
        raise GeoreferenceProcessingException('Something went wrong while trying to process a georeference process.')

    logger.debug('Set map as active and update boundingbox ...')
    boundingboxFromFile = parseBoundingBoxPolygonFromFile(destPath)
    sridFromFile = parseSRIDFromFile(destPath)
    mapObj.setActive(destPath)
    mapObj.setBoundingBox(boundingboxFromFile, sridFromFile, dbsession)

    # for proper working of the mapping service update all pending database changes have to be commited
    if not TEST_MODE:
        dbsession.commit()

    # update the tile map service
    logger.info('Calculating tms cache ...')
    newTargetDirectory = os.path.join(GEOREFERENCE_PERSITENT_TMS, str(mapObj.maptype).lower())
    calculateCompressedTMS(destPath, newTargetDirectory, mapObj.getSRID(dbsession))

    # push metadata record to elasticsearch index
    datarecordKey = pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj)

    # push metadata to catalogue
    # this method has to be supported again
    # logger.debug('Push metadata record for map %s to cataloge service ...'%mapObj.id)
    # pushMapObjToCsw(mapObj, dbsession, logger)

    # update process
    georefObj.setActive()

    # flush session
    if TEST_MODE:
        dbsession.flush()

    return datarecordKey