/[thuban]/trunk/thuban/Extensions/gns2shp/gns2shp.py
ViewVC logotype

Diff of /trunk/thuban/Extensions/gns2shp/gns2shp.py

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

revision 1721 by jan, Mon Sep 22 10:32:04 2003 UTC revision 2356 by jan, Tue Sep 28 19:31:05 2004 UTC
# Line 18  of some country files. Line 18  of some country files.
18  """  """
19    
20  __version__ = '$Revision$'  __version__ = '$Revision$'
21    # $Source$
22    # $Id$
23    
24  import os, sys  import os, sys
25    
26  # only import GUI when not called as command line tool  # only import GUI and register when not called as command line tool
27  if __name__ != '__main__':  if __name__ != '__main__':
28      from wxPython.wx import *      from wxPython.wx import *
29    
30      from Thuban.UI.command import registry, Command      from Thuban.UI.command import registry, Command
31      import Thuban.UI.mainwindow      from Thuban.UI.mainwindow import main_menu
32      from Thuban import _      from Thuban import _
33      from Thuban.Model.layer import Layer      from Thuban.Model.layer import Layer
34    
35    from Thuban.UI.extensionregistry import ExtensionDesc, ext_registry
36    
37  import shapelib  import shapelib
38  import dbflib  import dbflib
39    
40    
41    ext_registry.add(ExtensionDesc(
42        name = 'gns2shp',
43        version = '1.0.0',
44        authors= [ 'Jan-Oliver Wagner' ],
45        copyright = '2003, 2004 Intevation GmbH',
46        desc = _("Converts GNS (Geographical Name Service\n" \
47                 "of NIMA) to Shapefile format and\n" \
48                 "displays the data.")))
49    
50    
51  def gns2shp(src_fname, dest_fname):  def gns2shp(src_fname, dest_fname):
52      """Convert a file from gns textformat into a Shapefile.      """Convert a file from gns textformat into a Shapefile.
53    
# Line 75  def gns2shp(src_fname, dest_fname): Line 90  def gns2shp(src_fname, dest_fname):
90      dbf.add_field('SORT_NAME', dbflib.FTString, 40, 0)      dbf.add_field('SORT_NAME', dbflib.FTString, 40, 0)
91      dbf.add_field('FULL_NAME', dbflib.FTString, 40, 0)      dbf.add_field('FULL_NAME', dbflib.FTString, 40, 0)
92      dbf.add_field('FULL_ND', dbflib.FTString, 40, 0)      dbf.add_field('FULL_ND', dbflib.FTString, 40, 0)
93      dbf.add_field('MODIFY_DATE', dbflib.FTString, 10, 0)      dbf.add_field('MODIFY_DATE', dbflib.FTString, 11, 0)
94      del dbf      del dbf
95      dbf = dbflib.open(dbf_filename, 'r+b')      dbf = dbflib.open(dbf_filename, 'r+b')
96    
# Line 176  registry.Add(Command('gns2shp', _('gns2s Line 191  registry.Add(Command('gns2shp', _('gns2s
191                       helptext = _('Convert GNS-file into a shapefile')))                       helptext = _('Convert GNS-file into a shapefile')))
192    
193  # find the extensions menu (create it anew if not found)  # find the extensions menu (create it anew if not found)
194  main_menu = Thuban.UI.mainwindow.main_menu  extensions_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions'))
 extensions_menu = main_menu.find_menu('extensions')  
 if extensions_menu is None:  
     extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions'))  
195    
196  # finally add the new entry to the extensions menu  # finally add the new entry to the extensions menu
197  extensions_menu.InsertItem('gns2shp')  extensions_menu.InsertItem('gns2shp')

Legend:
Removed from v.1721  
changed lines
  Added in v.2356

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26