Changeset 40421 in project


Ignore:
Timestamp:
09/04/21 00:38:26 (3 weeks ago)
Author:
Kon Lovett
Message:

use typing for loop var, use n-ary, reflow, add gloss

Location:
release/5/geo-utils/trunk
Files:
1 added
4 edited

Legend:

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

    r40420 r40421  
    5151;;
    5252
    53 (define (degree-latitude? d)
    54   (and (<= -90 d) (<= d 90)) )
    55 
    56 (define (degree-longitude? d)
    57   (and (<= -180 d) (<= d 180)) )
     53(define (degree-latitude? d) (<= -90 d 90))
     54
     55(define (degree-longitude? d) (<= -180 d 180))
    5856
    5957(define (degree? d #!optional lat?)
    60   (if lat?
    61     (degree-latitude? d)
     58  (if lat? (degree-latitude? d)
    6259    (degree-longitude? d)) )
    6360
    64 (define (minute? m)
    65   (and (<= 0 m) (<= m 59)) )
    66 
    67 (define (second? s)
    68   (and (<= 0 s) (<= s 59)) )
     61(define (minute? m) (<= 0 m 59))
     62
     63(define (second? s) (<= 0 s 59))
    6964
    7065;;
     
    197192    (neg? (negative? d))
    198193    (d    (if neg? (- d) d))
    199     (deg  (+ d (+ (/ m 60) (/ s 3600)))) )
     194    (deg  (+ d (/ m 60) (/ s 3600))) )
    200195    (if neg? (- deg) deg) ) )
    201196
     
    213208      (let (
    214209        (ideg (inexact->exact dint))
    215         (isec (inexact->exact (round (+ sint (* mflt 60)))))
    216         (imin (inexact->exact mint)) )
     210        (imin (inexact->exact mint))
     211        (isec (inexact->exact (round (+ sint (* mflt 60))))) )
    217212        ;
    218213        (values (if neg? (- ideg) ideg) imin isec) ) ) ) )
  • release/5/geo-utils/trunk/geo-utils.scm

    r40420 r40421  
    7878    (lat2 (degree->radian lat2)) )
    7979    (let* (
    80       (a
    81         (+
    82           (sqr (sin (/ dlon 2)))
    83           (*
    84             (* (cos lat1) (cos lat2))
    85             (sqr (sin (/ dlat 2))))))
    86       (c
    87         (* 2 (asin (min 1 (sqrt a))))) )
     80      (a  (+ (sqr (sin (/ dlon 2))) (* (cos lat1) (cos lat2) (sqr (sin (/ dlat 2))))))
     81      (c  (* 2 (asin (min 1 (sqrt a))))) )
    8882      (* c R) ) ) )
    8983
     
    157151            (h2 (/ (* 3 (+ r 1)) (* 2 s)))
    158152            (d  (* 2 (* w R))) )
    159             (*  d
    160                 (+  1
    161                     (-  (* (* h1 F) (* sinf2 cosg2))
    162                         (* (* h2 F) (* cosf2 sing2))))) ) ) ) ) ) )
     153            (* d (+ 1 (- (* h1 F sinf2 cosg2) (* h2 F cosf2 sing2)))) ) ) ) ) ) )
    163154
    164155;;
     
    225216      (b  (/ dis R))
    226217      (sinb (sin b))
    227       (a  (acos (+  (* (cos b) (cos dlat))
    228                     (* sinb (* (sin dlat) (cos azi))))))
     218      (a  (acos (+ (* (cos b) (cos dlat)) (* sinb (sin dlat) (cos azi)))))
    229219      (b  (asin (/ (* sinb (sin azi)) (sin a)))) )
    230220      ;
  • release/5/geo-utils/trunk/geopoint-utils.scm

    r38967 r40421  
    1010  intersects?-pnp intersects?-pip)
    1111
    12 (import scheme)
    13 (import (chicken fixnum))
    14 (import (chicken type))
    15 (import geopoint)
    16 (import geopolygon)
    17 (import type-checks)
     12(import scheme
     13  (chicken type)
     14  geopoint
     15  geopolygon
     16  type-checks)
    1817
    1918;;;
     
    4140      (lon (geopoint-longitude gp)) )
    4241      ;assumes an open-poly is "closed" so a closed-poly must be treated as "open"
    43       (let ((len (if (geopolygon-closed? gpoly) (fx- len 1) len)))
    44         (let loop ((i 0) (j (fx- len 1)) (poly? #f))
    45           (if (fx= i len)
     42      (let ((len (if (geopolygon-closed? gpoly) (- len 1) len)))
     43        (let loop ((i (the fixnum 0)) (j (- len 1)) (poly? #f))
     44          (if (= i len)
    4645            poly?
    4746            (let (
     
    5049                  (not poly?)
    5150                  poly?)) )
    52             (loop (fx+ i 1) i new-poly) ) ) ) ) ) ) )
     51            (loop (+ i 1) i new-poly) ) ) ) ) ) ) )
    5352
    5453;;
  • release/5/geo-utils/trunk/geopolygon.scm

    r40420 r40421  
    2424;;;
    2525
    26 (define (ensure-vector gps)
    27   (if (list? gps) (list->vector gps) gps) )
     26(define (ensure-vector gps) (if (list? gps) (list->vector gps) gps))
    2827
    2928;;;
     
    7978          (gpoly (ensure-vector gpoly))
    8079    (len (vector-length (check-geopolygon 'geopolygon-bounding-box gpoly))) )
    81     (let loop ((i 0) (minLat 90) (maxLat -90) (minLon 180) (maxLon -180))
     80    (let loop ((i (the fixnum 0)) (minLat 90) (maxLat -90) (minLon 180) (maxLon -180))
    8281      ;traced polygon?
    8382      (if (= i len)
Note: See TracChangeset for help on using the changeset viewer.