|
@@ -944,7 +944,7 @@ class MultiImportDialog(wx.Dialog):
|
|
|
if self.inputType == 'dxf':
|
|
|
self.inputTitle = _("Input DXF file")
|
|
|
else:
|
|
|
- self.inputTitle = _("Input directory")
|
|
|
+ self.inputTitle = _("Source name")
|
|
|
|
|
|
self.inputBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
|
|
|
label=" %s " % self.inputTitle)
|
|
@@ -964,22 +964,88 @@ class MultiImportDialog(wx.Dialog):
|
|
|
changeCallback=self.OnSetInput,
|
|
|
fileMask="*.dxf")
|
|
|
else:
|
|
|
- self.inputText = wx.StaticText(self.panel, id=wx.ID_ANY, label=_("Choose directory:"))
|
|
|
- self.input = filebrowse.DirBrowseButton(parent=self.panel, id=wx.ID_ANY,
|
|
|
- size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
|
|
|
- dialogTitle=_('Choose input directory'),
|
|
|
- buttonText=_('Browse'),
|
|
|
- startDirectory=os.getcwd(),
|
|
|
- changeCallback=self.OnSetInput)
|
|
|
- self.formatText = wx.StaticText(self.panel, id=wx.ID_ANY, label=_("Select file extension:"))
|
|
|
- self.format = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY, size=(100, -1),
|
|
|
- value="")
|
|
|
- if self.inputType == 'gdal':
|
|
|
- self.format.SetValue('tif')
|
|
|
- else: # ogr
|
|
|
- self.format.SetValue('shp')
|
|
|
-
|
|
|
+ self.typeRadio = wx.RadioBox(parent = self.panel, id = wx.ID_ANY,
|
|
|
+ label = _('Source type'),
|
|
|
+ style = wx.RA_SPECIFY_COLS,
|
|
|
+ choices = [_("File"),
|
|
|
+ _("Directory"),
|
|
|
+ _("Database"),
|
|
|
+ _("Protocol")])
|
|
|
+ self.typeRadio.SetSelection(0)
|
|
|
+ self.Bind(wx.EVT_RADIOBOX, self.OnChangeType)
|
|
|
+
|
|
|
+ # input widgets
|
|
|
+ inputFile = filebrowse.FileBrowseButton(parent=self.panel, id=wx.ID_ANY,
|
|
|
+ size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
|
|
|
+ dialogTitle=_('Choose input directory'),
|
|
|
+ buttonText=_('Browse'),
|
|
|
+ startDirectory=os.getcwd(),
|
|
|
+ changeCallback=self.OnSetInput)
|
|
|
+
|
|
|
+ inputDir = filebrowse.DirBrowseButton(parent=self.panel, id=wx.ID_ANY,
|
|
|
+ size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
|
|
|
+ dialogTitle=_('Choose input directory'),
|
|
|
+ buttonText=_('Browse'),
|
|
|
+ startDirectory=os.getcwd(),
|
|
|
+ changeCallback=self.OnSetInput)
|
|
|
+ inputDir.Hide()
|
|
|
+
|
|
|
+ inputDb = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY)
|
|
|
+ inputDb.Hide()
|
|
|
+
|
|
|
+ inputPro = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY)
|
|
|
+ inputPro.Hide()
|
|
|
+
|
|
|
+ # format widget
|
|
|
+ self.formatText = wx.StaticText(self.panel, id=wx.ID_ANY, label=_("Format:"))
|
|
|
+ self.format = wx.Choice(parent = self.panel, id = wx.ID_ANY, size=(200, -1))
|
|
|
self.format.Bind(wx.EVT_TEXT, self.OnSetInput)
|
|
|
+
|
|
|
+ if self.inputType == 'gdal':
|
|
|
+ ret = gcmd.RunCommand('r.in.gdal',
|
|
|
+ quiet = True, read = True,
|
|
|
+ flags = 'f')
|
|
|
+ else: # ogr
|
|
|
+ ret = gcmd.RunCommand('v.in.ogr',
|
|
|
+ quiet = True, read = True,
|
|
|
+ flags = 'f')
|
|
|
+
|
|
|
+ self.input = { 'file' : [_("File:"),
|
|
|
+ inputFile,
|
|
|
+ list()],
|
|
|
+ 'dir' : [_("Directory:"),
|
|
|
+ inputDir,
|
|
|
+ list()],
|
|
|
+ 'db' : [_("Database:"),
|
|
|
+ inputDb,
|
|
|
+ list()],
|
|
|
+ 'pro' : [_("Protocol:"),
|
|
|
+ inputPro,
|
|
|
+ list()] }
|
|
|
+
|
|
|
+ if ret:
|
|
|
+ for line in ret.splitlines():
|
|
|
+ format = line.strip().rsplit(' ', 1)[0]
|
|
|
+ if format in ('PostgreSQL', 'SQLite',
|
|
|
+ 'ODBC', 'ESRI Personal GeoDatabase'):
|
|
|
+ self.input['db'][2].append(format)
|
|
|
+ elif format in ('GeoJSON'):
|
|
|
+ self.input['pro'][2].append(format)
|
|
|
+ else:
|
|
|
+ self.input['file'][2].append(format)
|
|
|
+ self.input['dir'][2].append(format)
|
|
|
+
|
|
|
+ self.inputType = 'file'
|
|
|
+
|
|
|
+ self.inputText = wx.StaticText(parent = self.panel, id = wx.ID_ANY,
|
|
|
+ label = self.input[self.inputType][0],
|
|
|
+ size = (75, -1))
|
|
|
+ self.format.SetItems(self.input[self.inputType][2])
|
|
|
+
|
|
|
+ if self.inputType == 'gdal':
|
|
|
+ self.format.SetStringSelection('GTIFF')
|
|
|
+ else:
|
|
|
+ self.format.SetStringSelection('ESRI Shapefile')
|
|
|
|
|
|
#
|
|
|
# list of layers
|
|
@@ -1037,7 +1103,11 @@ class MultiImportDialog(wx.Dialog):
|
|
|
gridSizer.Add(item=self.inputText,
|
|
|
flag=wx.ALIGN_CENTER_VERTICAL)
|
|
|
gridSizer.AddGrowableCol(1)
|
|
|
- gridSizer.Add(item=self.input,
|
|
|
+ self.inputTypeSizer = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
+ self.inputTypeSizer.Add(item=self.input[self.inputType][1], proportion = 1,
|
|
|
+ flag = wx.ALIGN_CENTER_VERTICAL)
|
|
|
+
|
|
|
+ gridSizer.Add(item=self.inputTypeSizer,
|
|
|
flag=wx.EXPAND | wx.ALL)
|
|
|
|
|
|
if self.inputType != 'dxf':
|
|
@@ -1047,7 +1117,9 @@ class MultiImportDialog(wx.Dialog):
|
|
|
|
|
|
inputSizer.Add(item=gridSizer, proportion=1,
|
|
|
flag=wx.EXPAND | wx.ALL)
|
|
|
-
|
|
|
+
|
|
|
+ dialogSizer.Add(item=self.typeRadio, proportion=0,
|
|
|
+ flag=wx.ALL | wx.EXPAND, border=5)
|
|
|
dialogSizer.Add(item=inputSizer, proportion=0,
|
|
|
flag=wx.ALL | wx.EXPAND, border=5)
|
|
|
|
|
@@ -1099,6 +1171,46 @@ class MultiImportDialog(wx.Dialog):
|
|
|
width = self.GetSize()[0]
|
|
|
self.list.SetColumnWidth(col=1, width=width/2 - 50)
|
|
|
|
|
|
+ def OnChangeType(self, event):
|
|
|
+ """!Datasource type changed"""
|
|
|
+ sel = event.GetSelection()
|
|
|
+ win = self.input[self.inputType][1]
|
|
|
+ self.inputTypeSizer.Remove(win)
|
|
|
+ win.Hide()
|
|
|
+
|
|
|
+ if sel == 0: # file
|
|
|
+ self.inputType = 'file'
|
|
|
+ format = self.input[self.inputType][2][0]
|
|
|
+ if format == 'ESRI Shapefile':
|
|
|
+ format += ' (*.shp)|*.shp'
|
|
|
+ else:
|
|
|
+ format += ' (*.*)|*.*'
|
|
|
+ win = filebrowse.FileBrowseButton(parent=self.panel, id=wx.ID_ANY,
|
|
|
+ size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
|
|
|
+ dialogTitle=_('Choose file'),
|
|
|
+ buttonText=_('Browse'),
|
|
|
+ startDirectory=os.getcwd(),
|
|
|
+ changeCallback=self.OnSetInput,
|
|
|
+ fileMask = format)
|
|
|
+ self.input[self.inputType][1] = win
|
|
|
+ elif sel == 1: # directory
|
|
|
+ self.inputType = 'dir'
|
|
|
+ elif sel == 2: # database
|
|
|
+ self.inputType = 'db'
|
|
|
+ elif sel == 3: # protocol
|
|
|
+ self.inputType = 'pro'
|
|
|
+
|
|
|
+ win = self.input[self.inputType][1]
|
|
|
+ self.inputTypeSizer.Add(item = win, proportion = 1,
|
|
|
+ flag = wx.ALIGN_CENTER_VERTICAL)
|
|
|
+ win.Show()
|
|
|
+
|
|
|
+ self.inputText.SetLabel(self.input[self.inputType][0])
|
|
|
+ self.format.SetItems(self.input[self.inputType][2])
|
|
|
+ self.format.SetSelection(0)
|
|
|
+
|
|
|
+ self.inputTypeSizer.Layout()
|
|
|
+
|
|
|
def OnCancel(self, event=None):
|
|
|
"""!Close dialog"""
|
|
|
self.Close()
|