Opened 11 years ago
Closed 8 years ago
#2140 closed defect (fixed)
m.proj does not handle cs2cs failure
Reported by: | wenzeslaus | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.0.5 |
Component: | Projections/Datums | Version: | svn-trunk |
Keywords: | m.proj, cs2cs | Cc: | |
CPU: | All | Platform: | All |
Description
When I input wrong proj strings to m.proj
it calls cs2cs
which fails and m.proj
does not handle its error correctly.
To test (you need to have test.txt
with any content):
m.proj input=test.txt proj_out="bla bla bla" proj_in="another bla bla bla"
The error message is:
Rel. 4.8.0, 6 March 2012 <cs2cs>: projection initialization failure cause: unknown projection id program abnormally terminated Traceback (most recent call last): File "/home/vasek/dev/grass/trunk_clang/dist.i686-pc-linux-gnu/scripts/m.proj", line 292, in <module> main() File "/home/vasek/dev/grass/trunk_clang/dist.i686-pc-linux-gnu/scripts/m.proj", line 271, in main x, y = xy.split('\t') ValueError: need more than 1 value to unpack
I haven't investigated that but checking return code is probably enough.
What is the correct Trac component for this ticket?
Change History (10)
comment:1 by , 11 years ago
comment:2 by , 9 years ago
I think we need to verify the input arguments before the cs2cs.exe tool is called.
I played with the '-e string' option, but the error messages generated by cs2cs are not suppressed. The documentation (https://trac.osgeo.org/proj/wiki/man_cs2cs) for the -e option talks about using the -b, -i, or -o options to return a value. These options appear to be invalid.
comment:3 by , 9 years ago
(un)related:
Even Rouault wrote in the proj ML on Jul 10, 2015:
https://pypi.python.org/pypi/pyproj/ might be a better option for using proj from Python.
follow-up: 6 comment:5 by , 9 years ago
This is interesting...
Output from GRASS GUI Command Console
(Thu Jul 30 20:38:52 2015) m.proj input=test.txt proj_out=bla bla bla proj_in=another bla bla bla Rel. 4.8.0, 6 March 2012 <cs2cs.EXE>: projection initialization failure cause: Unknown error program abnormally terminated ERROR: Using from definition: (Thu Jul 30 20:38:54 2015) Command finished (1 sec)
Output from GRASS Command Line
C:\>m.proj input=test.txt proj_out=bla bla bla proj_in=another bla bla bla
Description:
Converts coordinates from one projection to another (cs2cs frontend).
Keywords:
miscellaneous, projection
Usage:
m.proj.py [-iodec] [coordinates=east,north] [input=name] [output=name]
[separator=character] [proj_in=string] [proj_out=string] [--overwrite] [--help] [--verbose] [--quiet] [--ui]
Flags:
-i Use LL WGS84 as input and current location as output projection -o Use current location as input and LL WGS84 as output projection -d Output long/lat in decimal degrees, or other projections with many decimal places -e Include input coordinates in output file -c Include column names in output file
--o Allow output files to overwrite existing files --h Print usage summary --v Verbose module output --q Quiet module output --ui Force launching GUI dialog
Parameters:
coordinates Input coordinates to reproject
input Name of input coordinate file
'-' for standard input
output Name for output coordinate file (omit to send to stdout)
separator Field separator (format: input[,output])
Special characters: pipe, comma, space, tab, newline
default: pipe
proj_in Input projection parameters (PROJ.4 style)
proj_out Output projection parameters (PROJ.4 style)
ERROR: Sorry <bla> is not a valid option ERROR: Sorry <bla> is not a valid option ERROR: Sorry <bla> is not a valid option ERROR: Sorry <bla> is not a valid option ERROR: Sorry <bla> is not a valid option
C:\>
comment:6 by , 9 years ago
Replying to jrobparsons:
C:\>m.proj input=test.txt proj_out=bla bla bla proj_in=another bla bla bla
...
ERROR: Sorry <bla> is not a valid option ERROR: Sorry <bla> is not a valid option
...
Note that you need to quote the "bla bla..", otherwise the parser will interprete white space as parameter separation.
comment:7 by , 9 years ago
Sent patch to Vaclav Petras.
- PEP8 compliant except for 2 GUI parser 'description' lines.
rp@concepts:~/grass7_trunk/scripts/m.proj$ pep8 m.proj.py m.proj.py:28:80: E501 line too long (85 > 79 characters) m.proj.py:78:80: E501 line too long (97 > 79 characters)
- Replaced tabs with spaces.
indents are on 4 space boundaries.
- Added test for the presence of '+' in proj_in and proj_out strings.
if proj_in:
if '+' in proj_in:
in_proj = proj_in
else:
grass.fatal(_("Invalid PROJ.4 input specification"))
- Removed this comment inserted by previous programmer.
# FIXME: input_x,y needs to split on multiple whitespace between them
This appears to not be a problem.
comment:8 by , 9 years ago
comment:9 by , 9 years ago
Milestone: | 7.0.0 → 7.0.5 |
---|
comment:10 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Closing, feel free to reopen if needed.
In the current version (after r59228) the tests
outputs
which is much better than traceback but still it does not say what is the problem and there is the strange "ERROR: Using from definition:"