def testRectifyImageTpsForAKWithoutClip(self):
        destPath = os.path.join(self.dir, 'test-ak-rectified-tps-withoutclip.tif')
        file = os.path.join(self.dir,'test-ak.jpg')
        clip = []
        srs = 4314
        gcps = [
            gdal.GCP(13.322571166912697, 50.869534359847236, 0, 5473, 6079),
            gdal.GCP(13.346566162286086, 50.91926655702792, 0, 5670, 5589),
            gdal.GCP(13.53735995082988, 50.802610870942374, 0, 7020, 6807),
            gdal.GCP(13.667546305614797, 50.89755275702876, 0, 7812, 5913),
            gdal.GCP(13.741126714401176, 51.05625639529854, 0, 8338, 4161),
            gdal.GCP(13.681169234684086, 51.1685499300691, 0, 7942, 2791),
            gdal.GCP(13.47756543137287, 51.16569220735402, 0, 6609, 2882),
            gdal.GCP(13.300067220165836, 51.06061124738151, 0, 5102, 4096),
            gdal.GCP(13.310932518222272, 51.19680951127774, 0, 5295, 2447),
            gdal.GCP(12.921352950966174, 50.83419856543994, 0, 2536, 6561),
            gdal.GCP(12.983108161200633, 50.984707383627985, 0, 3048, 5009),
            gdal.GCP(12.973153769483801, 51.099562229978154, 0, 3091, 3676),
            gdal.GCP(13.119775225375355, 51.12445831286638, 0, 4017, 3228),
            gdal.GCP(13.124513229340627, 50.97154471762153, 0, 4037, 4961),
        ]
        response = rectifyTps(file, destPath, clip, gcps, srs, self.logger, self.dir)

        print '====================='
        print 'Test if testRectifyImageTpsForAKWithoutClip  ...'
        print 'Response: %s'%response
        print '====================='

        self.assertEqual(response, destPath, "Response is not equal to %s"%destPath)
示例#2
0
def processGeorefImage(mapObj, georefObj, dbsession, logger):
    """ Function process a persistent georeference image

    :type georeference.models.vkdb.map.Map: mapObj
    :type georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess: georefObj
    :type sqlalchemy.orm.session.Session: dbsession
    :type logging.Logger: logger
    :return: str """
    gcps = parseGcps(georefObj.georefparams['gcps'])
    georefTargetSRS = stripSRIDFromEPSG(georefObj.georefparams['target'])
    targetPath = os.path.join(GEOREFERENCE_PERSITENT_TARGETDIR, os.path.join(str(mapObj.maptype).lower(), mapObj.apsdateiname+'.tif'))
    transformationAlgorithm = georefObj.georefparams['algorithm'] if 'algorithm' in georefObj.georefparams else 'affine'
    destPath = None

    # create clip shape if exists
    clipShpPath = None
    if georefObj.clip is not None:
        clipShpPath = os.path.join(TMP_DIR, '%s' % uuid.uuid4())
        clipShpPath = createClipShapefile(convertPostgisStringToList(georefObj.clip), clipShpPath, georefObj.getSRIDClip(dbsession))

    logger.debug('Process georeference result ...')
    if transformationAlgorithm == 'affine':
        destPath = rectifyPolynom(mapObj.originalimage, targetPath, [], gcps, georefTargetSRS, logger, TMP_DIR, clipShpPath, order=1)
    elif transformationAlgorithm == 'polynom':
        destPath = rectifyPolynom(mapObj.originalimage, targetPath, [], gcps, georefTargetSRS, logger, TMP_DIR, clipShpPath)
    elif transformationAlgorithm == 'tps':
        destPath = rectifyTps(mapObj.originalimage, targetPath, [], gcps, georefTargetSRS, logger, TMP_DIR, clipShpPath)

    logger.debug('Add overviews to the image ...')
    addOverviews(destPath, '2 4 8 16 32', logger)

    return destPath
示例#3
0
def processGeorefImage(mapObj, georefObj, dbsession, logger):
    """ Function process a persistent georeference image

    :type georeference.models.vkdb.map.Map: mapObj
    :type georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess: georefObj
    :type sqlalchemy.orm.session.Session: dbsession
    :type logging.Logger: logger
    :return: str """
    gcps = parseGcps(georefObj.georefparams['gcps'])
    georefTargetSRS = stripSRIDFromEPSG(georefObj.georefparams['target'])
    targetPath = os.path.join(
        GEOREFERENCE_PERSITENT_TARGETDIR,
        os.path.join(
            str(mapObj.maptype).lower(), mapObj.apsdateiname + '.tif'))
    transformationAlgorithm = georefObj.georefparams[
        'algorithm'] if 'algorithm' in georefObj.georefparams else 'affine'
    destPath = None

    # create clip shape if exists
    clipShpPath = None
    if georefObj.clip is not None:
        clipShpPath = os.path.join(TMP_DIR, '%s' % uuid.uuid4())
        clipShpPath = createClipShapefile(
            convertPostgisStringToList(georefObj.clip), clipShpPath,
            georefObj.getSRIDClip(dbsession))

    logger.debug('Process georeference result ...')
    if transformationAlgorithm == 'affine':
        destPath = rectifyPolynom(mapObj.originalimage,
                                  targetPath, [],
                                  gcps,
                                  georefTargetSRS,
                                  logger,
                                  TMP_DIR,
                                  clipShpPath,
                                  order=1)
    elif transformationAlgorithm == 'polynom':
        destPath = rectifyPolynom(mapObj.originalimage, targetPath, [], gcps,
                                  georefTargetSRS, logger, TMP_DIR,
                                  clipShpPath)
    elif transformationAlgorithm == 'tps':
        destPath = rectifyTps(mapObj.originalimage, targetPath, [], gcps,
                              georefTargetSRS, logger, TMP_DIR, clipShpPath)

    logger.debug('Add overviews to the image ...')
    addOverviews(destPath, '2 4 8 16 32', logger)

    return destPath