Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pj_get_def(): put quotes around +nadgrids= string if path contains spaces #218

Closed
proj4-bot opened this issue May 22, 2015 · 2 comments
Closed

Comments

@proj4-bot
Copy link

Reported by hamish on 3 Jul 2013 23:58 UTC
Hi,

we experience problems with cs2cs and gdalwarp when using +proj terms to define the CRSs when the full path to the grid file is used with +nadgrids=, and path contains spaces (e.g. C:\Program Files).

It would be nice if when pj_get_def() is building the definition string it could strncmp() for '+nadgrids=', strstr() to look for spaces (etc.) in the param, and if some were found put "quotes" around the part of the string to the right of the '='. If no spaces or other special chars, then no quotes. It might happen earlier when the param string is constructed, but it seems the sort of thing which perhaps shouldn't happen until the very last moment before fprintf(stdout,) since the string isn't always destined for use in a command.

my current approach is to use some ugly regex to try and make the pj_get_def() output string usable as CRS input for cs2cs or gdalwarp on the command line, but it's brittle and less than ideal.

thoughts?

thanks,
Hamish

ps- 4.7.0 as there's no "Version" option for 4.8.0 in trac

Migrated-From: https://trac.osgeo.org/proj/ticket/218

@proj4-bot
Copy link
Author

Comment by hamish on 7 Jul 2013 14:27 UTC
Also, it would be helpful if cs2cs did some more checks for when the given grid file name is bad, exiting with an error instead of silently falling back to the null-gridfile answer:

ok:

$ echo "170 -45" | cs2cs +proj=longlat +datum=WGS84 +to \
   +proj=nzmg +datum=nzgd49 +nadgrids=nzgd2kgrid0005.gsb
2273467.23  5574351.73 0.00

bad:

$ echo "170 -45" | cs2cs +proj=longlat +datum=WGS84 +to \
   +proj=nzmg +datum=nzgd49 +nadgrids=\"nzgd2kgrid0005.gsb\"
2273467.50  5574533.67 0.00

$ echo "170 -45" | cs2cs +proj=longlat +datum=WGS84 +to \
   +proj=nzmg +datum=nzgd49 +nadgrids=anything              
2273467.50  5574533.67 0.00

$ echo "170 -45" | cs2cs +proj=longlat +datum=WGS84 +to \
   +proj=nzmg +datum=nzgd49 +nadgrids=        
2273467.50  5574533.67 0.00

$ echo "170 -45" | cs2cs +proj=longlat +datum=WGS84 +to \
   +proj=nzmg +datum=nzgd49 +nadgrids=@null
2273467.50  5574533.67 0.00

something different again: (the default +towgs84 from proj -ld)

$ echo "170 -45" | cs2cs +proj=longlat +datum=WGS84 +to \
   +proj=nzmg +datum=nzgd49           
2273467.44  5574352.31 -1.53

echo "170 -45" | cs2cs +proj=longlat +datum=WGS84 +to \
   +proj=nzmg +datum=nzgd49 +towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993
2273467.44  5574352.31 -1.53

thanks,
Hamish

@proj4-bot
Copy link
Author

Comment by warmerdam on 21 Oct 2013 04:03 UTC
Hamish,

I just tried:

echo "170 -45" | cs2cs +proj=longlat +datum=WGS84 +to \
?    +proj=nzmg +datum=nzgd49 +nadgrids=\"nzgd2kgrid0005.gsb\"
Rel. 4.9.0, 22 June 2013
<cs2cs>: while processing file: <stdin>, line 1
pj_transform(): failed to load datum shift file
*   * 0.00

This is the behavior I expect. If the nadgrid filename isn't prefixed with "@" then not finding it when needed should be an error.

With regard to pj_get_def() quoting strings with spaces, I spent a bunch of time working on this but came - more or less - to the conclusion that it isn't a good idea. The current definition is suitable for us with pj_init_plus() even without quoting.

It feels wrong for me to try and quote it for the unix command shell (other shells might have other rules). And if I did, then I have to change the parser so that it can ignore quotes. This seems dangerous, in part because quotes really mean something in some contexts.

I was disappointed to discover that cs2cs cannot take a whole definition of a coordinate system as one quoted string and pass it to pj_init_plus() currently, otherwise on unix you could just put single quotes around the whole thing to pass it to cs2cs.

For now I'm not prepared to change pj_get_def() to quote things even though I realize it makes it hard to use on the commandline (in some circumstances).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant