Changeset 34418 in project


Ignore:
Timestamp:
08/27/17 05:22:00 (3 months ago)
Author:
kon
Message:

bump ver, fix spherical-surface-distance, re-flow

Location:
release/4/geo-utils/trunk
Files:
3 edited

Legend:

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

    r34129 r34418  
    5252
    5353(define (spherical-surface-distance lat1 lon1 lat2 lon2 #!optional (R EARTH-RADIUS-MILES))
    54   (let ((dlat (fpdegree->radian (fp- lat2 lat1)))
    55         (dlon (fpdegree->radian (fp- lon2 lon1)))
     54  ;haversine formula : https://en.wikipedia.org/wiki/Haversine_formula
     55  (let ((dlat (fpdegree->radian (fpabs (fp- lat2 lat1))))
     56        (dlon (fpdegree->radian (fpabs (fp- lon2 lon1))))
    5657        (lat1 (fpdegree->radian lat1))
    5758        (lat2 (fpdegree->radian lat2)) )
    58     (let* ((sdlon (fpsin (fp/ dlon 2.0)))
    59            (sdlat (fpsin (fp/ dlat 2.0)))
    60            (a (fp+ (fpsqr sdlat)
    61                    (fp* (fpsqr sdlon) (fp* (fpcos lat1) (fpcos lat2)))))
    62            (c (fp* 2.0 (fpasin (fpmin 1.0 (fpsqrt a))))) )
     59    (let* ((a
     60            (fp+
     61              (fpsqr (fpsin (fp/ dlon 2.0)))
     62              (fp*
     63                (fp* (fpcos lat1) (fpcos lat2))
     64                (fpsqr (fpsin (fp/ dlat 2.0))))) )
     65           (c (fp* 2.0 (fpasin (fpmin 1.0 (fpsqrt a)))) ) )
    6366      (fp* c R) ) ) )
    6467
     
    7275    (great-circle-distance-radians lat1 lon1 lat2 lon2 R) ) )
    7376
     77; https://en.wikipedia.org/wiki/Great-circle_distance
    7478(define (great-circle-distance-radians lat1 lon1 lat2 lon2 #!optional (R EARTH-RADIUS-MILES))
    75   (let ((d (fp+ (fp* (fpsin lat1) (fpsin lat2))
    76                 (fp* (fpcos lat1) (fp* (fpcos lat2) (fpcos (fp- lon1 lon2)))))))
     79
     80  (atan2
     81    (fp/
     82      (sqrt ((sqr (cos lat2)) + (sqr ((cos lat1) • ((sin lon2) - (sin lon1)) • (cos (fpabs (lon2 - lon1)))))
     83
     84  (let ((d
     85          (fp+
     86            (fp* (fpsin lat1) (fpsin lat2))
     87            (fp*
     88              (fp* (fpcos lat1) (fpcos lat2))
     89              (fpcos (fp- lon1 lon2)))) ) )
    7790    (fp* (fpacos d) R) ) )
    7891
  • release/4/geo-utils/trunk/geo-utils.setup

    r34129 r34418  
    55(verify-extension-name "geo-utils")
    66
    7 (setup-shared+static-extension-module 'geopoint (extension-version "0.1.0")
     7(setup-shared+static-extension-module 'geopoint (extension-version "0.1.1")
    88  #:inline? #t
    99  #:types? #t
    1010  #:compile-options `(-scrutinize -optimize-level 3 -debug-level 1 -no-procedure-checks))
    1111
    12 (setup-shared+static-extension-module 'geobox (extension-version "0.1.0")
     12(setup-shared+static-extension-module 'geobox (extension-version "0.1.1")
    1313  #:inline? #t
    1414  #:types? #t
    1515  #:compile-options `(-scrutinize -optimize-level 3 -debug-level 1 -no-procedure-checks))
    1616
    17 (setup-shared+static-extension-module 'geopolygon (extension-version "0.1.0")
     17(setup-shared+static-extension-module 'geopolygon (extension-version "0.1.1")
    1818  #:inline? #t
    1919  #:types? #t
    2020  #:compile-options `(-scrutinize -optimize-level 3 -debug-level 1 -no-procedure-checks))
    2121
    22 (setup-shared+static-extension-module 'geopoint-utils (extension-version "0.1.0")
     22(setup-shared+static-extension-module 'geopoint-utils (extension-version "0.1.1")
    2323  #:inline? #t
    2424  #:types? #t
    2525  #:compile-options `(-scrutinize -optimize-level 3 -debug-level 1 -no-procedure-checks))
    2626
    27 (setup-shared+static-extension-module (extension-name) (extension-version "0.1.0")
     27(setup-shared+static-extension-module (extension-name) (extension-version "0.1.1")
    2828  #:inline? #t
    2929  #:types? #t
    3030  #:compile-options `(-scrutinize -optimize-level 3 -debug-level 1 -no-procedure-checks))
    3131
    32 (setup-shared+static-extension-module 'geo-dms (extension-version "0.1.0")
     32(setup-shared+static-extension-module 'geo-dms (extension-version "0.1.1")
    3333  #:inline? #t
    3434  #:types? #t
  • release/4/geo-utils/trunk/geopoint.scm

    r34129 r34418  
    1010  geopoint-strictly-above geopoint-above geopoint-strictly-below geopoint-below
    1111  geopoint-strictly-left geopoint-left geopoint-strictly-right geopoint-right
    12   geopoint= geopoint< geopoint> geopoint<= geopoint>= )
     12  geopoint= geopoint< geopoint> geopoint<= geopoint>=
     13  ;
     14  )
    1315
    1416(import scheme)
Note: See TracChangeset for help on using the changeset viewer.