>
> ========================================================================
>
> Here is the cut-down program...
>
> ========================================================================
> #!/usr/bin/tclsh
> set lat_degrees [expr [lindex $argv 0]]
> set long_degrees [expr [lindex $argv 1]]
> set radius [expr [lindex $argv 2]]
Not sure why you are using expr in the above (i.e. you probably don't need
it)...but
that's not the problem. Also, if you are using Tcl 8.5, you can use lassign as
well:
lassign $argv lat_degrees long_degress radius
> load /usr/lib/sqlite-3.6.17/libtclsqlite3.so
> sqlite3 db :memory:
> # Note: GIS convention has longitude negative in the western hemisphere.
> # But end-users will get annoyed at having to enter the minus sign all the
> # time. So the conversion is done internally in the distance() function.
> proc sql_distance {lat1, long1, lat2, long2} {
The variable "lat1" does not exist, but the variable "lat1," does. Tcl
procedures do not use commas to
separate args...just spaces...so:
proc sql_distance {lat1 long1 lat2 long2} {
> set radian [expr 180 / 3.1415926]
> set lat1 [expr $lat1 / $radian ]
> set long1 [expr $long1 / $radian * (-1) ]
> set lat2 [expr $lat2 / $radian ]
> set long2 [expr $long2 / $radian ]
Just a tip, most of the time you want to brace expr args to avoid Tcl's double
substitution.
No harm, just has a slight performance impact. For example:
set lat1 [expr {$lat1 / $radian}]
HTH,
--brett
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users