def testSetBoundingBox(self): mapObj = Map(id=1, georefimage=self.file) # check if response is correct dataset = gdal.Open( self.file, GA_ReadOnly) bounds = getBoundsFromDataset(dataset) polygon = "POLYGON((%(lx)s, %(ly)s, %(lx)s, %(uy)s, %(ux)s, %(uy)s, %(ux)s, %(ly)s, %(lx)s, %(ly)s))"% { "lx": bounds[0], "ly": bounds[1], "ux": bounds[2], "uy": bounds[3] } print polygon print self.file print getBoundsFromDataset(dataset)
def createValidationResult(requestParams, gcps, gcpstargetSrs, LOGGER): """ Function creates a process image and creates a temporary wms. :type requestParams: dict :type gcps: List.<gdal.GCP> :type georefTargetSRS: int :type LOGGER: logging.LOGGER :return: str :raise: vkviewer.python.georef.georeferenceexceptions.ParameterException """ LOGGER.debug('Process georeference result ...') tmpFile = os.path.join(GEOREFERENCE_MAPFILE_FOLDER,requestParams['mapObj'].apsdateiname+"::"+str(uuid.uuid4())+".tif") destPath = None if requestParams['georeference']['algorithm'] == 'affine': destPath = rectifyImageAffine(requestParams['mapObj'].originalimage, tmpFile, [], gcps, gcpstargetSrs, LOGGER) elif requestParams['georeference']['algorithm'] == 'polynom': destPath = rectifyPolynomWithVRT(requestParams['mapObj'].originalimage, tmpFile, gcps, gcpstargetSrs, LOGGER, TMP_DIR) elif requestParams['georeference']['algorithm'] == 'tps': destPath = rectifyTpsWithVrt(requestParams['mapObj'].originalimage, tmpFile, gcps, gcpstargetSrs, LOGGER, TMP_DIR) else: raise ParameterException('Transformation algorithm - %s - is not supported yet.'%requestParams['georeference']['algorithm']) LOGGER.debug('Create temporary mapfile ...') wmsUrl = createMapfile(requestParams['mapObj'].apsdateiname, destPath, gcpstargetSrs, GEOREFERENCE_MAPFILE_TEMPLATE, GEOREFERENCE_MAPFILE_FOLDER, GEOREFERENCE_MAPFILE_DEFAULT_PARAMS) LOGGER.debug('Calculate extent ...') dataset = gdal.Open(destPath, GA_ReadOnly) extent = getBoundsFromDataset(dataset) LOGGER.debug('Deliver results.') return {'wmsUrl':wmsUrl,'layerId':requestParams['mapObj'].apsdateiname, 'extent': extent}
def testSetBoundingBox(self): mapObj = Map(id=1, georefimage=self.file) # check if response is correct dataset = gdal.Open(self.file, GA_ReadOnly) bounds = getBoundsFromDataset(dataset) polygon = "POLYGON((%(lx)s, %(ly)s, %(lx)s, %(uy)s, %(ux)s, %(uy)s, %(ux)s, %(ly)s, %(lx)s, %(ly)s))" % { "lx": bounds[0], "ly": bounds[1], "ux": bounds[2], "uy": bounds[3] } print polygon print self.file print getBoundsFromDataset(dataset)
def testGetBoundsFromDataset(self): dataset = gdal.Open(self.clip_raster, GA_ReadOnly) response = getBoundsFromDataset(dataset) print '=====================' print 'Test if testGetBoundsFromDataset ...' print 'Response: %s' % response print '=====================' self.assertTrue(len(response) == 4, 'Response has not expected form.') del dataset
def testGetBoundsFromDataset(self): dataset = gdal.Open( self.clip_raster, GA_ReadOnly) response = getBoundsFromDataset(dataset) print '=====================' print 'Test if testGetBoundsFromDataset ...' print 'Response: %s'%response print '=====================' self.assertTrue(len(response) == 4, 'Response has not expected form.') del dataset
def createValidationResult(requestParams, gcps, gcpstargetSrs, LOGGER): """ Function creates a process image and creates a temporary wms. :type requestParams: dict :type gcps: List.<gdal.GCP> :type georefTargetSRS: int :type LOGGER: logging.LOGGER :return: str :raise: vkviewer.python.georef.georeferenceexceptions.ParameterException """ LOGGER.debug("Process georeference result ...") tmpFile = os.path.join( GEOREFERENCE_MAPFILE_FOLDER, requestParams["mapObj"].apsdateiname + "::" + str(uuid.uuid4()) + ".tif" ) destPath = None if requestParams["georeference"]["algorithm"] == "affine": destPath = rectifyImageAffine(requestParams["mapObj"].originalimage, tmpFile, [], gcps, gcpstargetSrs, LOGGER) elif requestParams["georeference"]["algorithm"] == "polynom": destPath = rectifyPolynomWithVRT( requestParams["mapObj"].originalimage, tmpFile, gcps, gcpstargetSrs, LOGGER, TMP_DIR ) elif requestParams["georeference"]["algorithm"] == "tps": destPath = rectifyTpsWithVrt( requestParams["mapObj"].originalimage, tmpFile, gcps, gcpstargetSrs, LOGGER, TMP_DIR ) else: raise ParameterException( "Transformation algorithm - %s - is not supported yet." % requestParams["georeference"]["algorithm"] ) LOGGER.debug("Create temporary mapfile ...") wmsUrl = createMapfile( requestParams["mapObj"].apsdateiname, destPath, gcpstargetSrs, GEOREFERENCE_MAPFILE_TEMPLATE, GEOREFERENCE_MAPFILE_FOLDER, GEOREFERENCE_MAPFILE_DEFAULT_PARAMS, ) LOGGER.debug("Calculate extent ...") dataset = gdal.Open(destPath, GA_ReadOnly) extent = getBoundsFromDataset(dataset) LOGGER.debug("Deliver results.") return {"wmsUrl": wmsUrl, "layerId": requestParams["mapObj"].apsdateiname, "extent": extent}