[GRASS-dev] g.proj to create a new location

Michael Barton michael.barton at asu.edu
Tue Feb 13 09:23:34 EST 2007


Thanks Hamish. This is very helpful. When is this available to write the
wrapper for?

Michael


On 2/13/07 2:42 AM, "Hamish" <hamish_nospam at yahoo.com> wrote:

> Michael Barton wrote:
>> 
>> Actually, looking at this, maybe it is more correct to do the
>> following...
>> 
>> # first run g.proj to see if there are more than the default
>> # parameters to choose from
>> set input [open "|g.proj epsg=$epsgcode epsgloc=$epsgloc datumtrans=-1"]
>> set dtrans [read $input]
>> close $input
>> if {$dtrans==""} {
>>     # I assume that $dtrans=="" if there is only one default parameter.
>>     # so use the default parameter.
>>     open "|g.proj epsg=$epsgcode epsgloc=$epsgloc datumtrans=1"
>> else {
>>     # do some kind of selection dialog here where the user
>>     # picks the desired datum transformation from the list in
>>     # dtrans and "set dtsel [integer of user datum trans selection]"
>>     open "|g.proj epsg=$epsgcode epsgloc=$epsgloc datumtrans=$dtsel"
>> }
> 
> 
> (it's location= not "epsgloc=")
> 
> I have no idea about tcl and little idea about system calls, so I'll
> just run through the logic and hope it is easy to translate into tcl.
> 
> 
> First pass once the user selects an EPSG code is to find datum transform
> parms. -c and location=$name are not needed at this point.
> 
> # e.g., an EPSG code with 3 options (and 0 = "none")
> 
> G63> g.proj epsg=27200 datumtrans=-1  2> /dev/null
> ---
> 1
> Used in whole nzgd49 region
> towgs84=54.400,-20.100,183.100
> Default 3-Parameter Transformation (May not be optimum for older datums; use
> this only if no more appropriate options are available.)
> ---
> 2
> Used in New Zealand
> nadgrids=nzgd2kgrid0005.gsb
> LINZ NZGD49 NTv2 Distortion Model, accuracy 10-30cm
> ---
> 3
> Used in New Zealand
> towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993
> Accuracy approx. 4m
> 
> 
> 
> The default will always come first.
> 
> Each record is 5 lines in stdout,
> 1 ---
> 2 #
> 3 text: where it's used
> 4 text: proj4 parms
> 5 text: comment
> 
> from general/g.proj/datumtrans.c:
> 
> fprintf(stdout, "---\n%d\nUsed in %s\n%s\n%s\n",
> list->count, list->where_used,
> list->params, list->comment);
> 
> That's what you have to parse.
> 
> 
> Here is what that looks likes if there are no options:
>  (ie the EPSG code already specified them)
> 
> G63> g.proj epsg=2193 datumtrans=-1
> G63> echo $?
> 0
> 
> So if the first pass "g.proj epsg=#### datumtrans=-1" exits
> successfully, but sends nothing to stdout, you can go straight to:
> 
>  g.proj -c location=$name epsg=####
> 
> and you're done.
> 
> 
> If you put in a bad EPSG code you get this:
> 
> G63> g.proj epsg=99999 datumtrans=-1
> ERROR 6: EPSG PCS/GCS code 99999 not found in EPSG support files.  Is this a
> valid EPSG coordinate system?
> ERROR: Can't parse PROJ.4-style parameter string
> G63> echo $?
> 1
> 
> which you can pick up from the non-zero exit code.
> 
> 
> Back to the case that needs to be parsed:
> If there is option text you need to create a dialog window from the
> options, as well as a "0: leave unspecified" option at the bottom.
> Then once the user has selected something from that,
>  g.proj -c location=$name epsg=#### datumtrans=$number
> 
> and you're done.
> 
> 
> make sense?
> 
> Hamish

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton





More information about the grass-dev mailing list