jan: thuban/Extensions/gns2shp gns2shp.py,1.5,1.6

cvs@intevation.de cvs at intevation.de
Sat Dec 18 23:57:05 CET 2004


Author: jan

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

Modified Files:
	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.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gns2shp.py	16 Nov 2004 21:15:17 -0000	1.5
+++ gns2shp.py	18 Dec 2004 22:57:03 -0000	1.6
@@ -39,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
@@ -64,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')
@@ -99,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,





More information about the Thuban-devel mailing list

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