jan: thuban/Extensions/gns2shp gns2shp.py,1.1.2.1,1.1.2.2

cvs@intevation.de cvs at intevation.de
Thu Dec 16 02:06:35 CET 2004


Author: jan

Update of /thubanrepository/thuban/Extensions/gns2shp
In directory doto:/tmp/cvs-serv5650

Modified Files:
      Tag: thuban-1-0-branch
	gns2shp.py 
Log Message:
(gns2shp): Fixed doc-string, fixed some dimensions of fields according
to the GNS documentation which seems to change undocumented.
Now killing trailing \n and/or \r from MODIFY_DATE.
This fixes RT#2453.


Index: gns2shp.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/gns2shp/gns2shp.py,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- gns2shp.py	18 May 2004 21:22:25 -0000	1.1.2.1
+++ gns2shp.py	16 Dec 2004 01:06:33 -0000	1.1.2.2
@@ -1,6 +1,6 @@
-# Copyright (C) 2003 by Intevation GmbH
+# Copyright (C) 2003, 2004 by Intevation GmbH
 # Authors:
-# Jan-Oliver Wagner <jan at intevation.de>
+# Jan-Oliver Wagner <jan at intevation.de> (2003, 2004)
 #
 # This program is free software under the GPL (>=v2)
 # Read the file COPYING coming with Thuban for details.
@@ -18,15 +18,17 @@
 """
 
 __version__ = '$Revision$'
+# $Source$
+# $Id$
 
 import os, sys
 
-# only import GUI when not called as command line tool
+# only import GUI and register when not called as command line tool
 if __name__ != '__main__':
     from wxPython.wx import *
 
     from Thuban.UI.command import registry, Command
-    import Thuban.UI.mainwindow
+    from Thuban.UI.mainwindow import main_menu
     from Thuban import _
     from Thuban.Model.layer import Layer
 
@@ -37,7 +39,7 @@
     """Convert a file from gns textformat into a Shapefile.
 
     The GNS text format is described on
-    http://www.nima.mil/gns/html/cntyfile/gis.html
+    http://www.nima.mil/gns/html/gis.html
 
     src_fname  -- Filename of the GNS standard textfile (including suffix '.txt)
     dest_fname -- Filename where to write the Shapefile components (name
@@ -62,19 +64,19 @@
     dbf.add_field('JOG', dbflib.FTString, 7, 0)
     dbf.add_field('FC', dbflib.FTString, 1, 0)
     dbf.add_field('DSG', dbflib.FTString, 5, 0)
-    dbf.add_field('PC', dbflib.FTInteger, 10, 0)
+    dbf.add_field('PC', dbflib.FTInteger, 1, 0)
     dbf.add_field('CC1', dbflib.FTString, 2, 0)
     dbf.add_field('ADM1', dbflib.FTString, 2, 0)
-    dbf.add_field('ADM2', dbflib.FTString, 2, 0)
+    dbf.add_field('ADM2', dbflib.FTString, 200, 0)
     dbf.add_field('DIM', dbflib.FTInteger, 10, 0)
     dbf.add_field('CC2', dbflib.FTString, 2, 0)
     dbf.add_field('NT', dbflib.FTString, 1, 0)
     dbf.add_field('LC', dbflib.FTString, 2, 0)
-    dbf.add_field('SHORT_FORM', dbflib.FTString, 40, 0)
-    dbf.add_field('GENERIC', dbflib.FTString, 40, 0)
-    dbf.add_field('SORT_NAME', dbflib.FTString, 40, 0)
-    dbf.add_field('FULL_NAME', dbflib.FTString, 40, 0)
-    dbf.add_field('FULL_ND', dbflib.FTString, 40, 0)
+    dbf.add_field('SHORT_FORM', dbflib.FTString, 128, 0)
+    dbf.add_field('GENERIC', dbflib.FTString, 128, 0)
+    dbf.add_field('SORT_NAME', dbflib.FTString, 200, 0)
+    dbf.add_field('FULL_NAME', dbflib.FTString, 200, 0)
+    dbf.add_field('FULL_ND', dbflib.FTString, 200, 0) # FULL_NAME_ND
     dbf.add_field('MODIFY_DATE', dbflib.FTString, 11, 0)
     del dbf
     dbf = dbflib.open(dbf_filename, 'r+b')
@@ -97,6 +99,7 @@
         except: PC = None
         try: DIM = int(DIM)
         except: DIM = None
+        MODIFY_DATE = MODIFY_DATE[0:10] # kill trailing "\n" or "\r\n"
         obj = shapelib.SHPObject(shapelib.SHPT_POINT, i, [[(DD_LONG, DD_LAT)]])
         shp.write_object(-1, obj)
         dbf.write_record(i, { 'RC': RC, 'UFI': UFI, 'UNI': UNI, 'UTM': UTM,
@@ -176,7 +179,6 @@
                      helptext = _('Convert GNS-file into a shapefile')))
 
 # find the extensions menu (create it anew if not found)
-main_menu = Thuban.UI.mainwindow.main_menu
 extensions_menu = main_menu.find_menu('extensions')
 if extensions_menu is None:
     extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions'))





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)