# Command covered: geomap. Console commands only. # # This script file tests the commands in the tclgeomap package. See the # tclgeomap man page for a description of the package. See the tcltest # man page for a description of Tcl's testing proc's. # # Copyright (c) 2004 Gordon D. Carrie. All rights reserved. # # Licensed under the Open Software License version 2.1 # # Please address questions and feedback to user0@tkgeomap.org # # @(#) $Id: tcl_geomap.test,v 1.4 2004/09/22 21:57:51 tkgeomap Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import ::tcltest::* } package require tclgeomap 2 namespace eval geomap { test tclgeomap-1.1 {domainlon} { set PI 3.14159265358979323846 set DEGPERRAD [expr {180.0 / $PI}] set RADPERDEG [expr {$PI / 180.0}] for {set errs {};set phi -800} {$phi <= 800} {incr phi} { set phiL [domnlat $phi] set phiS [expr {$DEGPERRAD * asin(sin($phi * $RADPERDEG))}] set err [format {%.1f} [expr {$phiL - $phiS}]] if {!([string match $err "0.0"] || [string match $err "-0.0"])} { lappend errs $err } } set errs } {} test tclgeomap-1.2 {domainlon} { foreach rLon {-135.0 -45.0 0.0 45.0 135.0} { upvar 0 $rLon rLonArr # Generate results manually for {set i -400} {$i <= 400} {incr i} { if {$i < $rLon - 180.0} { set rLonArr($i) [expr $i + 360.0] } elseif {$i > $rLon + 180.0} { set rLonArr($i) [expr $i - 360.0] } else { set rLonArr($i) $i } } # Check manual results against results of domnlon command set rslt {} for {set i -400} {$i <= 400} {incr i} { set i2 [domnlon $i $rLon] if {$i2 != $rLonArr($i)} { lappend rslt \ "Domain of $rLon, longitude $i: got $i2 instead of $rLonArr($i)" } } } set rslt } {} test tclgeomap-1.3 {gwchlon} { # Generate results manually for {set i -400} {$i <= 400} {incr i} { if {$i < $rLon - 180.0} { set GwchLon($i) [expr $i + 360.0] } elseif {$i > $rLon + 180.0} { set GwchLon($i) [expr $i - 360.0] } else { set GwchLon($i) $i } } # Check manual results against results of domnlon command set rslt {} for {set i -400} {$i <= 400} {incr i} { set i2 [domnlon $i $rLon] if {$i2 != $GwchLon($i)} { lappend rslt \ "Domain of $rLon, longitude $i: got $i2 instead of $GwchLon($i)" } } set rslt } {} test tclgeomap-1.4 {latlonok with large angle} { latlonok [list 1e10 1e10] } {0} cleanupTests }