[Proj] quoting +nadgrids ?

Greg Troxel gdt at ir.bbn.com
Thu Aug 26 05:32:05 PDT 2010


Normally I'm in the "people should learn not to use spaces in file
names" camp.  I find that the set of people who can fix problems from
spaces is a subset of the people who know enough not to use spaces.
That said:

I think the problem is that cs2cs doesn't parse quotes.  One should pass
a single argument whose contents are shown within the / characters:

  /+nadgrids=/tmp/nad test/nzgd2kgrid0005.gsb/

but using ' inside of " causes the variable IN_PROJ to have ' in it.

The following shell script may be helpful in figuring this out.  Note
that the attempt to remove ' doesn't work because the argument is broken
on the space inside the '.


#!/bin/sh

rm -rf "/tmp/nad test"
mkdir "/tmp/nad test"
cp /usr/pkg/share/proj/nzgd2kgrid0005.gsb "/tmp/nad test/"

#IN_PROJ="'+proj=nzmg' '+lat_0=-41' '+lon_0=173' '+x_0=2510000' '+y_0=6023150' '+no_defs' '+a=6378388' '+rf=297' '+nadgrids=/tmp/nad test/nzgd2kgrid0005.gsb' '+to_meter=1'"

IN_PROJ="+proj=nzmg +lat_0=-41 +lon_0=173 +x_0=2510000 +y_0=6023150 +no_defs +a=6378388 +rf=297 +nadgrids=/tmp/nad\ test//nzgd2kgrid0005.gsb +to_meter=1"

OUT_PROJ="+proj=longlat +datum=WGS84"

echo IN_PROJ /$IN_PROJ/
echo OUT_PROJ /$OUT_PROJ/

echo "WITHOUT QUOTES:"
for i in $IN_PROJ; do
    echo /$i/
done
echo "."

echo "WITH QUOTES:"
for i in "$IN_PROJ"; do
    echo /$i/
done
echo "."

set -x
echo "2006797  5490896" | \
   cs2cs -w5 "$IN_PROJ" +to `echo $OUT_PROJ`

echo "2006797  5490896" | \
   cs2cs -w5 "`for i in $IN_PROJ; do echo $i | sed "s/'//g"; done`" +to `echo $OUT_PROJ`


echo "2006797  5490896" | cs2cs -w5 '+proj=nzmg' '+lat_0=-41' '+lon_0=173' \
    '+x_0=2510000' '+y_0=6023150' '+no_defs' '+a=6378388' '+rf=297' \
    '+nadgrids=/tmp/nad test/nzgd2kgrid0005.gsb' '+to_meter=1' \
    +to +proj=longlat +datum=WGS84
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20100826/b7ffcaa4/attachment.sig>


More information about the Proj mailing list