/[thuban]/branches/WIP-pyshapelib-bramz/Extensions/ogr/ogrstart.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Extensions/ogr/ogrstart.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2577 by nhueffme, Fri Mar 4 15:07:59 2005 UTC revision 2713 by bernhard, Thu Oct 26 16:37:42 2006 UTC
# Line 1  Line 1 
1  # Copyright (c) 2004 by Intevation GmbH  # 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  #  #
# Line 54  def open_with_ogr(context): Line 54  def open_with_ogr(context):
54                  layername = layerDlg.GetLayer()                  layername = layerDlg.GetLayer()
55                  try:                  try:
56                      session = context.application.Session()                      session = context.application.Session()
57                      store = OpenFileShapestore(session, filename, layername)                      store = OpenFileShapestore(context.mainwindow, session,
58                                                   filename, layername)
59                      session.AddShapeStore(store)                      session.AddShapeStore(store)
60                  except:                  except:
61                      # the layer couldn't be opened                      # the layer couldn't be opened
62                      context.mainwindow.RunMessageBox(("Add Layer"),                      context.mainwindow.RunMessageBox(_("Add Layer"),
63                                  ("Can't open the file '%s'.")%filename)                                  _("Can't open the file '%s'.") % filename)
64                  else:                  else:
65                      if store is not None:                      if store is not None:
66                          layer = Layer(title, store)                          layer = Layer(title, store)
# Line 148  def open_OGRConnection(context): Line 149  def open_OGRConnection(context):
149                      canvas.FitMapToWindow()                      canvas.FitMapToWindow()
150      dlg.Destroy()      dlg.Destroy()
151    
152  def OpenFileShapestore(session, filename, layername):  def OpenFileShapestore(mainwindow, session, filename, layername):
153      """Open a datasource and add the required layer.      """Open a datasource and add the required layer.
154      """      """
155      try:      try:
156          store = ogrshapes.OGRShapeStore(session, filename, layername)          store = ogrshapes.OGRFileShapeStore(session, filename, layername)
157          return store          return store
158      except:      except:
159          # Some error occured while initializing the layer          # Some error occured while initializing the layer
160          context.mainwindow.RunMessageBox(_("Open datasource"),          mainwindow.RunMessageBox(_("Open datasource"),
161                             _("Can't open the datasource '%s'")                             _("Can't open the datasource '%s'")
162                             % filename)                             % filename)
163      else:          return None
         return null  
164    
165  def OpenDBShapestore(session, dbconn, layername, id_column, geo_column):  def OpenDBShapestore(session, dbconn, layername, id_column, geo_column):
166      """Open a datasource and add the required layer.      """Open a datasource and add the required layer.
# Line 199  from Thuban.UI.mainwindow import main_me Line 199  from Thuban.UI.mainwindow import main_me
199    
200    
201  # find the map menu (create a new if not found)  # find the map menu (create a new if not found)
202  map_menu = main_menu.FindOrInsertMenu('map', _('Map'))  #map_menu = main_menu.FindOrInsertMenu('map', _('Map'))
203  ogr_menu = Menu("ogr", _("Open layer via OGR"),[])  #ogr_menu = Menu("ogr", _("Open layer via OGR"),[])
204    # as long as there we are not stable, better add to "Extentions" marked "beta"
205    map_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions'))
206    ogr_menu = Menu("ogr", _("(testing) Open layer via OGR"),[])
207    
208    
209  ogrsupport = ogrshapes.has_ogr_support()  ogrsupport = ogrshapes.has_ogr_support()
210    

Legend:
Removed from v.2577  
changed lines
  Added in v.2713

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26