Changeset 36728 in project


Ignore:
Timestamp:
10/27/18 18:46:20 (3 weeks ago)
Author:
kon
Message:

add cr

Location:
release/5/geo-utils/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/geo-utils/trunk/geo-dms.scm

    r36188 r36728  
    1616  string-dms->degree
    1717  ;
    18   degree->string string->degree)
     18  degree->string string->degree
     19  ;
     20  degree->compass-rose
     21  set-compass-rose!)
    1922
    2023(import scheme
     
    244247  (dms->string* 0 0 0 pad) )
    245248
     249;;
     250
     251(: set-compass-rose! (vector -> void))
     252(: degree->compass-rose (number -> symbol))
     253(define set-compass-rose!)
     254(define degree->compass-rose)
     255(let (
     256  (+rose+ #f)
     257  (+rose-count+ #f)
     258  (+rose-slice+ #f)
     259  (+rose-slice/2+ #f) )
     260  ;
     261  (define (compass-rose-slice deg)
     262    (inexact->exact (fpfloor (fp/ (fp+ (exact->inexact deg) +rose-slice/2+) +rose-slice+))) )
     263  ;
     264  (set! set-compass-rose! (lambda (vec)
     265    (set! +rose+ (check-vector 'set-compass-rose! vec))
     266    (set! +rose-count+ (vector-length +rose+))
     267    (set! +rose-slice+ (fp/ 360.0 (exact->inexact +rose-count+)))
     268    (set! +rose-slice/2+ (fp/ +rose-slice+ 2.0)) ) )
     269  ;
     270  (set! degree->compass-rose (lambda (deg)
     271    ;0 <= deg < 360
     272    (vector-ref +rose+ (modulo (compass-rose-slice deg) +rose-count+)) ) ) )
     273
     274;;;Module Init
     275
     276(set-compass-rose! '#(N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW))
     277
    246278) ;module geo-dms
  • release/5/geo-utils/trunk/tests/geo-utils-test.scm

    r36188 r36728  
    6767  (test -10.3416666666667 (string-dms->degree "10° 20' 30\" W" #f))
    6868  (test -10.3416666666667 (string-dms->degree "W10° 20'30\"" #t))
     69
     70  (test 'N (degree->compass-rose 10.3416666666667))
     71  (test 'E (degree->compass-rose 100.3416666666667))
    6972)
    7073
Note: See TracChangeset for help on using the changeset viewer.