Skip to content
Snippets Groups Projects
Commit 73da4329 authored by benjamin.jakimow@geo.hu-berlin.de's avatar benjamin.jakimow@geo.hu-berlin.de
Browse files

VRT_SHARED_SOURCE=0 to not crash when loading massive number of VRTs

parent 46e16462
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,8 @@ from PyQt4.QtCore import * ...@@ -12,6 +12,8 @@ from PyQt4.QtCore import *
from PyQt4.QtXml import * from PyQt4.QtXml import *
from osgeo import gdal, ogr from osgeo import gdal, ogr
gdal.SetConfigOption('VRT_SHARED_SOURCE', '0') #!important. really. do not change this.
import numpy as np import numpy as np
from timeseriesviewer import DIR_REPO, DIR_EXAMPLES, dprint, jp, findAbsolutePath from timeseriesviewer import DIR_REPO, DIR_EXAMPLES, dprint, jp, findAbsolutePath
...@@ -187,17 +189,20 @@ def verifyInputImage(path, vrtInspection=''): ...@@ -187,17 +189,20 @@ def verifyInputImage(path, vrtInspection=''):
if not os.path.exists(path): if not os.path.exists(path):
print('{}Image does not exist: '.format(vrtInspection, path)) print('{}Image does not exist: '.format(vrtInspection, path))
return False return False
ds = gdal.Open(path) ds = gdal.Open(path)
if not ds: if not ds:
print('{}GDAL unable to open: '.format(vrtInspection, path)) print('{}GDAL unable to open: '.format(vrtInspection, path))
return False return False
if ds.GetDriver().ShortName == 'VRT': if ds.GetDriver().ShortName == 'VRT':
vrtInspection = 'VRT Inspection {}\n'.format(path) vrtInspection = 'VRT Inspection {}\n'.format(path)
validSrc = [verifyInputImage(p, vrtInspection=vrtInspection) for p in set(ds.GetFileList()) - set([path])] nextFiles = set(ds.GetFileList()) - set([path])
validSrc = [verifyInputImage(p, vrtInspection=vrtInspection) for p in nextFiles]
if not all(validSrc): if not all(validSrc):
return False return False
else: return True
return True
def pixel2coord(gt, x, y): def pixel2coord(gt, x, y):
"""Returns global coordinates from pixel x, y coords""" """Returns global coordinates from pixel x, y coords"""
...@@ -220,7 +225,7 @@ class TimeSeriesDatum(QObject): ...@@ -220,7 +225,7 @@ class TimeSeriesDatum(QObject):
if verifyInputImage(p): if verifyInputImage(p):
try: try:
tsd =TimeSeriesDatum(None, p) tsd = TimeSeriesDatum(None, p)
except : except :
pass pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment