Skip to content

Commit

Permalink
MapTiler 1.0 Alpha2
Browse files Browse the repository at this point in the history
git-svn-id: http://maptiler.googlecode.com/svn/trunk@5 8e3b7fcf-6a54-0410-9c54-8fc88ded019e
  • Loading branch information
klokan committed Jan 16, 2009
1 parent 1bb8751 commit b87ed9a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 47 deletions.
4 changes: 2 additions & 2 deletions maptiler/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version = "1.0 alpha1"
version = "1.0 alpha2"

profile = 'mercator'
files = []
nodata = None
srs = "EPSG:4326"
srs = ""
srsformat = 0
tminz = 0
tmaxz = 0
Expand Down
10 changes: 3 additions & 7 deletions maptiler/gdal2tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@
# DEALINGS IN THE SOFTWARE.
#******************************************************************************

try:
from osgeo import gdal
from osgeo import osr
except ImportError:
import gdal
import osr
from osgeo import gdal
from osgeo import osr

import sys
import os
Expand Down Expand Up @@ -2218,4 +2214,4 @@ def generate_openlayers( self ):
argv = gdal.GeneralCmdLineProcessor( sys.argv )
if argv:
gdal2tiles = GDAL2Tiles( argv[1:] )
gdal2tiles.process()
gdal2tiles.process()
20 changes: 9 additions & 11 deletions maptiler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def __init__(self, *args, **kwds):
self.rendering = False
self.resume = False

# begin wxGlade: MainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)

Expand Down Expand Up @@ -92,10 +91,8 @@ def __init__(self, *args, **kwds):

self.__set_properties()
self.__do_layout()
# end wxGlade

def __set_properties(self):
# begin wxGlade: MainFrame.__set_properties
self.SetTitle(_("MapTiler - Map Tile Generator for Mashups"))
#self.SetIcon( icons.getIconIcon() )
self.SetBackgroundColour(wx.Colour(253, 253, 253))
Expand All @@ -110,10 +107,8 @@ def __set_properties(self):
self.label_9.SetFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
self.button_back.Enable(False)
self.button_continue.SetDefault()
# end wxGlade

def __do_layout(self):
# begin wxGlade: MainFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
sizer_5 = wx.BoxSizer(wx.VERTICAL)
Expand Down Expand Up @@ -148,7 +143,6 @@ def __do_layout(self):
self.Layout()
self.Centre(wx.BOTH)
#self.SetMinSize((700, 500))
# end wxGlade

def OnQuit(self,Event):
self.Destroy()
Expand Down Expand Up @@ -235,7 +229,12 @@ def OnContinue(self, event):
wx.MessageBox("""Sorry the file you have specified does not have georeference.\n\nClick on the 'Georeference' button and give a bounding box or \ncreate a world file (.wld) for the specified file.""", "Missing georeference", wx.ICON_ERROR)
return
if step == 2:
srs = gdalpreprocess.SRSInput(config.srsformat, config.srs)
print config.srs
try:
srs = gdalpreprocess.SRSInput(config.srsformat, config.srs)
except:
print "!!! Exception in SRS reading"
print srs
if config.profile != 'raster' and not srs:
wx.MessageBox("""You have to specify refenrece system of your coordinates.\n\nTIP: for latitude/longitude in WGS84 you should type 'EPSG:4326'""", "Not valid spatial reference system", wx.ICON_ERROR)
return
Expand Down Expand Up @@ -289,12 +288,11 @@ def _renderstart(self):

def createParams(self):

config.srs = "EPSG:4326"
params = ['--profile',config.profile,
'--s_srs',config.srs,
'--zoom',"%i-%i" % (config.tminz, config.tmaxz)
#'--title',config.title,
#'--copyright',config.copyright,
'--zoom',"%i-%i" % (config.tminz, config.tmaxz),
'--title',config.title,
'--copyright',config.copyright
]
viewer = 'none'
if config.google:
Expand Down
23 changes: 14 additions & 9 deletions maptiler/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,17 @@ def Preprocess(argv):
projection = file_infos[0].projection

for fi in file_infos:
if fi.geotransform[1] != psize_x or fi.geotransform[5] != psize_y:
print "All files must have the same scale; %s does not" \
% fi.filename
sys.exit(1)

if fi.geotransform[2] != 0 or fi.geotransform[4] != 0:
print "No file must be rotated/skewed; %s is.\nTODO: gdalwarp -of vrt %s %s.vrt" % (fi.filename, fi.filename, fi.filename)
sys.exit(1)
pass
# MAPTILER COMMENT
#if fi.geotransform[1] != psize_x or fi.geotransform[5] != psize_y:
# print "All files must have the same scale; %s does not" \
# % fi.filename
# sys.exit(1)

# MAPTILER COMMENT
#if fi.geotransform[2] != 0 or fi.geotransform[4] != 0:
# print "No file must be rotated/skewed; %s is.\nTODO: gdalwarp -of vrt %s %s.vrt" % (fi.filename, fi.filename, fi.filename)
# sys.exit(1)

#TODO: During initialization create temporary files by AutoCreateWarpedVRT for those

Expand All @@ -287,7 +290,9 @@ def Preprocess(argv):
# % fi.filename
# sys.exit(1)

geotransform = (ulx, psize_x, 0.0, uly, 0.0, psize_y)
# MAPTILER COMMENT
#geotransform = (ulx, psize_x, 0.0, uly, 0.0, psize_y)
geotransform = file_infos[0].geotransform

gcpprojection = file_infos[0].gcpprojection
gcps = file_infos[0].gcps
Expand Down
44 changes: 26 additions & 18 deletions maptiler/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import config
from wxgdal2tiles import wxGDAL2Tiles

from unicodedata import normalize, combining
strip_diacritics = lambda text: filter(lambda i: not combining(i), normalize('NFKD', text))
#from unicodedata import normalize, combining
#strip_diacritics = lambda text: filter(lambda i: not combining(i), normalize('NFKD', text))

class WizardHtmlWindow(wx.html.HtmlWindow):
def __init__(self, parent, id):
Expand All @@ -30,24 +30,29 @@ def GetActiveStep(self):
def SetStep(self, step):
self.step = step
if step >= len(steps):
self.SetPage(stepfinal % config.outputdir)
self.SetPage(stepfinal % (config.outputdir, config.outputdir) )
return
self.SetPage(steps[step])
if step == 0:
self.FindWindowByName('mercator').SetValue(1)
elif step == 1:
pass
elif step == 2:
if config.files[0][6] != '':
if not config.srs:
config.srs = config.files[0][6]
if config.profile == 'raster' and not config.srs:
config.srs = "EPSG:4326"
self.FindWindowByName('srs').SetValue(config.srs)
elif step == 3:
g2t = wxGDAL2Tiles(['--profile',config.profile,'--s_srs', config.srs, str(config.files[0][2]) ])
g2t.open_input()
config.tminz = g2t.tminz
config.tmaxz = g2t.tmaxz
config.kml = g2t.kml
del g2t
try:
g2t = wxGDAL2Tiles(['--profile',config.profile,'--s_srs', config.srs, str(config.files[0][2]) ])
g2t.open_input()
config.tminz = g2t.tminz
config.tmaxz = g2t.tmaxz
config.kml = g2t.kml
del g2t
except:
print "!!! Exception: GDAL2Tiles initialization - for getting the default values"
self.FindWindowByName('tminz').SetValue(config.tminz)
self.FindWindowByName('tmaxz').SetValue(config.tmaxz)
elif step == 4:
Expand Down Expand Up @@ -106,7 +111,8 @@ def SaveStep(self, step):
config.nodata = self.FindWindowByName('nodatapanel').GetColor()
print config.nodata
elif step == 2:
config.srs = str(strip_diacritics(self.FindWindowByName('srs').GetValue()))
config.oldsrs = config.srs
config.srs = self.FindWindowByName('srs').GetValue().encode('utf-8').strip()
config.srsformat = self.FindWindowByName('srs').GetSelection()
print config.srs
elif step == 3:
Expand All @@ -129,10 +135,12 @@ def SaveStep(self, step):
print config.openlayers
print config.kml
elif step == 6:
config.title = self.FindWindowByName('title').GetValue()
config.copyright = self.FindWindowByName('copyright').GetValue()
config.googlekey = self.FindWindowByName('googlekey').GetValue()
config.yahookey = self.FindWindowByName('yahookey').GetValue()
config.title = self.FindWindowByName('title').GetValue().encode('utf8')
if not config.title:
config.title = os.path.basename( config.files[0][0] ).encode('utf8')
config.copyright = self.FindWindowByName('copyright').GetValue().encode('utf8')
config.googlekey = self.FindWindowByName('googlekey').GetValue().encode('utf8')
config.yahookey = self.FindWindowByName('yahookey').GetValue().encode('utf8')
print config.title
print config.copyright
print config.googlekey
Expand Down Expand Up @@ -362,9 +370,9 @@ def UpdateRenderText(self, text):
<p>
<font color="#DC5309" size="large"><b>Available results:</b></font>
<p>
The generated tiles and also the viewers are available in this directory:
The generated tiles and also the viewers are available in the output directory:
<p>
<b>%s</b>
<b><a href="file://%s">%s</a></b>
<!--
<ul>
<li>Open the <a href="">Google Maps presentation</a>
Expand All @@ -383,4 +391,4 @@ def UpdateRenderText(self, text):
</center>
"""

steps = [step1, step2, step3, step4, step5, step6, step7, step8 ]
steps = [step1, step2, step3, step4, step5, step6, step7, step8 ]

0 comments on commit b87ed9a

Please sign in to comment.