Permalink
Browse files

Merge branch 'hotfix/1.0.3'

  • Loading branch information...
2 parents 175036a + 2fcb426 commit ce78b897f87cb7a26a6e397837b49998cd4f7081 @mathuin committed Oct 21, 2012
Showing with 16 additions and 7 deletions.
  1. +1 −1 pymclevel
  2. +15 −6 region.py
View
@@ -58,7 +58,7 @@ class Region:
maxdepth = 32
# tileheight is height of map in Minecraft units
- tileheight = 256 # mclevel.MCInfdevOldLevel.Height
+ tileheight = mclevel.MCInfdevOldLevel.Height
# headroom is room between top of terrain and top of map
headroom = 16
@@ -472,8 +472,9 @@ def buildvrts(self):
(compbase, compext) = os.path.splitext(compfile)
fullfile = os.path.join(layerdir, compfile)
datasubdir = os.path.join(layerdir, compbase)
+ compfile = '%s.%s' % (compbase, iType)
# tar (at least) expects Unix pathnames
- compimage = '/'.join([compbase, "%s.%s" % (compbase, iType)])
+ compimage = '/'.join([compbase, compfile])
cleanmkdir(datasubdir)
if (Region.zipfileBroken == False):
if (cType == "tgz"):
@@ -487,15 +488,21 @@ def buildvrts(self):
cFile = tarfile.open(fullfile)
cFile.extract(compimage, layerdir)
elif (cType == "zip"):
- omfgcompimage = os.path.join(compbase, '%s.%s' % (compbase, iType))
+ omfgcompimage = os.path.join(compbase, compfile)
os.mkdir(os.path.dirname(os.path.join(datasubdir, compimage)))
cFile = zipfile.ZipFile(fullfile)
cFile.extract(omfgcompimage, datasubdir)
os.rename(os.path.join(datasubdir, omfgcompimage), os.path.join(layerdir, compimage))
cFile.close()
- vrtfile = '%s.vrt' % layerID
- buildvrtcmd = 'gdalbuildvrt %s %s' % (vrtfile, ' '.join(['"%s"' % x for x in locate('*.%s' % iType, layerdir)]))
- os.system('cd %s && %s' % (layerdir, buildvrtcmd))
+ # convert tif to good SRS
+ rawfile = os.path.join(layerdir, compbase, compfile)
+ goodfile = os.path.join(layerdir, compbase, "%s.good%s" % (compbase, iType))
+ warpcmd = 'gdalwarp -q -multi -t_srs "%s" %s %s' % (Region.t_srs, rawfile, goodfile)
+ os.system('%s' % warpcmd)
+
+ vrtfile = os.path.join(layerdir, '%s.vrt' % layerID)
+ buildvrtcmd = 'gdalbuildvrt %s %s' % (vrtfile, ' '.join(['"%s"' % x for x in locate('*.good*', root=layerdir)]))
+ os.system('%s' % buildvrtcmd)
def getfiles(self):
"""Get files from USGS."""
@@ -615,6 +622,8 @@ def buildmap(self, wantCL=True):
values = vrtband.ReadAsArray(0, 0, vrtds.RasterXSize, vrtds.RasterYSize)
# nodata is treated as water, which is 11
vrtnodata = vrtband.GetNoDataValue()
+ if (vrtnodata == None):
+ vrtnodata = 0
values[values == vrtnodata] = 11
values = values.flatten()
vrtband = None

0 comments on commit ce78b89

Please sign in to comment.