Changeset 34506 in project for release/4/geo-utils/trunk/geobox.scm


Ignore:
Timestamp:
09/04/17 00:48:49 (10 months ago)
Author:
kon
Message:

add types, ? for preds

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/geo-utils/trunk/geobox.scm

    r34496 r34506  
    99  geobox-minimum geobox-maximum
    1010  geobox= geobox< geobox> geobox<= geobox>=
    11   geopoint-within-box )
     11  geopoint-within-box? )
    1212
    1313(import scheme chicken)
     
    2121;;
    2222
    23 (define *make-geobox cons)
    24 (define *geobox-minimum car)
    25 (define *geobox-maximum cdr)
     23(: *make-geobox ((struct geopoint) (struct geopoint) --> (struct geobox)))
     24(: geobox? (* --> boolean))
     25(: *geobox-minimum ((struct geobox) --> (struct geopoint)))
     26(: *geobox-maximum ((struct geobox) --> (struct geopoint)))
     27(define-record-type geobox
     28  (*make-geobox min max)
     29  geobox?
     30  (min *geobox-minimum)
     31  (max *geobox-maximum) )
    2632
    27 ;;;
    28 
    29 ;;
    30 
     33;(: make-geobox (or ((struct geopoint) (struct geopoint) --> (struct geobox)) (number number number number --> (struct geobox))))
    3134(define make-geobox
    3235  (case-lambda
     
    3740        (make-geopoint minLat minLon) (make-geopoint maxLat maxLon)) ) ) )
    3841
     42(: make-geobox* (symbol (struct geopoint) (struct geopoint) --> (struct geobox)))
    3943(define (make-geobox* loc min-pnt max-pnt)
    4044  (check-geopoint loc min-pnt)
     
    4246  (unless
    4347    (and
    44       (geopoint-above min-pnt max-pnt)
    45       (geopoint-left min-pnt max-pnt) )
     48      (geopoint-above? min-pnt max-pnt)
     49      (geopoint-left? min-pnt max-pnt) )
    4650    (error loc "minimum-geopoint > maximum-geopoint" min-pnt max-pnt) )
    4751  (*make-geobox min-pnt max-pnt) )
    4852
    49 (define (geobox? obj)
    50   (and
    51     (pair? obj)
    52     (geopoint? (car obj))
    53     (geopoint? (cdr obj))) )
    54 
    5553(define-check+error-type geobox)
    5654
     55(: geobox-minimum ((struct geobox) --> (struct geopoint)))
    5756(define (geobox-minimum gb)
    5857  (*geobox-minimum (check-geobox 'geobox-minimum gb)) )
    5958
     59(: geobox-maximum ((struct geobox) --> (struct geopoint)))
    6060(define (geobox-maximum gb)
    6161  (*geobox-maximum (check-geobox 'geobox-maximum gb)) )
     
    6363;;
    6464
     65(: geobox= ((struct geobox) (struct geobox) --> boolean))
    6566(define (geobox= gb1 gb2)
    6667  (check-geobox 'geobox= gb1)
     
    7071    (geopoint= (*geobox-maximum gb1) (*geobox-maximum gb2)) ) )
    7172
     73(: geobox< ((struct geobox) (struct geobox) --> boolean))
    7274(define (geobox< gb1 gb2)
    7375  (check-geobox 'geobox< gb1)
     
    7779    (geopoint< (*geobox-maximum gb1) (*geobox-maximum gb2)) ) )
    7880
     81(: geobox> ((struct geobox) (struct geobox) --> boolean))
    7982(define (geobox> gb1 gb2)
    8083  (check-geobox 'geobox> gb1)
     
    8487    (geopoint> (*geobox-maximum gb1) (*geobox-maximum gb2)) ) )
    8588
     89(: geobox<= ((struct geobox) (struct geobox) --> boolean))
    8690(define (geobox<= gb1 gb2)
    8791  (check-geobox 'geobox<= gb1)
     
    9195    (geopoint<= (*geobox-maximum gb1) (*geobox-maximum gb2)) ) )
    9296
     97(: geobox>= ((struct geobox) (struct geobox) --> boolean))
    9398(define (geobox>= gb1 gb2)
    9499  (check-geobox 'geobox>= gb1)
     
    98103    (geopoint>= (*geobox-maximum gb1) (*geobox-maximum gb2)) ) )
    99104
    100 (define (geopoint-within-box gp gb)
     105(: geopoint-within-box? ((struct geobox) (struct geobox) --> boolean))
     106(define (geopoint-within-box? gp gb)
    101107  (and
    102108    (geopoint<= (*geobox-minimum gb) gp)
Note: See TracChangeset for help on using the changeset viewer.