1 |
# Copyright (c) 2004,2006 by Intevation GmbH vim:encoding=latin-1: |
# Copyright (c) 2004,2006 by Intevation GmbH vim:encoding=latin-1: |
2 |
# Authors: |
# Authors: |
3 |
# Nina H�ffmeyer <[email protected]> |
# Nina Hüffmeyer <[email protected]> |
4 |
# |
# |
5 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
6 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
9 |
# $Source$ |
# $Source$ |
10 |
# $Id$ |
# $Id$ |
11 |
|
|
12 |
# Needed wx-toolkit classes |
# Needed wx.-toolkit classes |
13 |
from wxPython.wx import wxFileDialog, wxOPEN, wxMULTIPLE, wxID_OK |
import wx |
14 |
|
|
15 |
# We need os.path |
# We need os.path |
16 |
import os |
import os |
34 |
map = canvas.Map() |
map = canvas.Map() |
35 |
|
|
36 |
# Get the file to be opened |
# Get the file to be opened |
37 |
dlg = wxFileDialog(canvas, _("Select a data file"), |
dlg = wx.FileDialog(canvas, _("Select a data file"), |
38 |
context.application.Path("data"), "", |
context.application.Path("data"), "", |
39 |
_("Shapefiles (*.shp)") + "|*.shp|" + |
_("Shapefiles (*.shp)") + "|*.shp|" + |
40 |
_("GML files (*.gml)") + "|*.gml|" + |
_("GML files (*.gml)") + "|*.gml|" + |
42 |
_("DGN files (*.dgn)") + "|*.dgn|" + |
_("DGN files (*.dgn)") + "|*.dgn|" + |
43 |
_("CSV files (*.csv)") + "|*.csv|" + |
_("CSV files (*.csv)") + "|*.csv|" + |
44 |
_("All Files (*.*)") + "|*.*|", |
_("All Files (*.*)") + "|*.*|", |
45 |
wxOPEN | wxMULTIPLE) |
wx.OPEN | wx.MULTIPLE) |
46 |
|
|
47 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wx.ID_OK: |
48 |
filenames = dlg.GetPaths() |
filenames = dlg.GetPaths() |
49 |
for filename in filenames: |
for filename in filenames: |
50 |
title = os.path.splitext(os.path.basename(filename))[0] |
title = os.path.splitext(os.path.basename(filename))[0] |
51 |
has_layers = map.HasLayers() |
has_layers = map.HasLayers() |
52 |
layerDlg = ogrdialog.ChooseLayer(canvas, filename) |
layerDlg = ogrdialog.ChooseLayer(canvas, filename) |
53 |
if layerDlg.ShowModal() == wxID_OK: |
if layerDlg.ShowModal() == wx.ID_OK: |
54 |
layername = layerDlg.GetLayer() |
layername = layerDlg.GetLayer() |
55 |
try: |
try: |
56 |
session = context.application.Session() |
session = context.application.Session() |
84 |
|
|
85 |
dlg = ogrdialog.ChooseFileFormat(canvas, session) |
dlg = ogrdialog.ChooseFileFormat(canvas, session) |
86 |
|
|
87 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wx.ID_OK: |
88 |
pass |
pass |
89 |
dlg.Destroy() |
dlg.Destroy() |
90 |
|
|
98 |
session = context.application.Session() |
session = context.application.Session() |
99 |
dlg = ChooseOGRDBTableDialog(canvas, session) |
dlg = ChooseOGRDBTableDialog(canvas, session) |
100 |
|
|
101 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wx.ID_OK: |
102 |
dbconn, connString, dbtable, id_column = dlg.GetTable() |
dbconn, connString, dbtable, id_column = dlg.GetTable() |
103 |
try: |
try: |
104 |
store = OpenDBShapestore(session, dbconn, dbtable, id_column, |
store = OpenDBShapestore(session, dbconn, dbtable, id_column, |
126 |
session = context.application.Session() |
session = context.application.Session() |
127 |
dlg = ogrdialog.OGRConnectionDialog(canvas, session) |
dlg = ogrdialog.OGRConnectionDialog(canvas, session) |
128 |
|
|
129 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wx.ID_OK: |
130 |
dsname = dlg.GetDatasourceName() |
dsname = dlg.GetDatasourceName() |
131 |
|
|
132 |
layerDlg = ogrdialog.ChooseLayer(canvas, dsname) |
layerDlg = ogrdialog.ChooseLayer(canvas, dsname) |
133 |
if layerDlg.ShowModal() == wxID_OK: |
if layerDlg.ShowModal() == wx.ID_OK: |
134 |
layername = layerDlg.GetLayer() |
layername = layerDlg.GetLayer() |
135 |
try: |
try: |
136 |
store = ogrshapes.OGRShapeStore(session, dsname, layername) |
store = ogrshapes.OGRShapeStore(session, dsname, layername) |