浏览代码

More robust parsing of cs2cs output

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48251 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 13 年之前
父节点
当前提交
1c8af04334
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      scripts/m.proj/m.proj.py

+ 7 - 4
scripts/m.proj/m.proj.py

@@ -263,16 +263,19 @@ def main():
 	if include_header:
 	    outf.write("x%sy%sz\n" % (ofs, ofs))
 	for line in p.stdout:
-	    x, yz = line.split('\t')
-	    y, z = yz.split(' ')
+	    xy, z = line.split(' ', 1)
+	    x, y = xy.split('\t')
 	    outf.write('%s%s%s%s%s\n' % \
                        (x.strip(), ofs, y.strip(), ofs, z.strip()))
     else:
 	if include_header:
 	    outf.write("input_x%sinput_y%sx%sy%sz\n" % (ofs, ofs, ofs, ofs))
 	for line in p.stdout:
-	    inX, therest, z = line.split(' ')
-	    inY, x, y = therest.split('\t')
+            print line
+            inXYZ, x, rest = line.split('\t')
+            print inXYZ
+            inX, inY = inXYZ.split(' ')[:2]
+	    y, z = rest.split(' ', 1)
 	    outf.write('%s%s%s%s%s%s%s%s%s\n' % \
                        (inX.strip(), ofs, inY.strip(), ofs, x.strip(), \
 		        ofs, y.strip(), ofs, z.strip()))