anchor.diff:          (mapcar #'(lambda (a) (cdr (assoc :elements a))) (cdr (assoc :rows json)))
           (error (cdr (assoc :status json))))))
   
  +(defun great-circle-distance (lng1 lat1 lng2 lat2)
  +  (flet ((rad (x) (/ (* x Pi) 180))
  +         (haversine (x) (expt (sin (/ x 2)) 2)))
  +    (let ((earth-radius 6371)
  +          (lat1 (rad lat1)) (lng1 (rad lng1))
  +          (lat2 (rad lat2)) (lng2 (rad lng2)))
  +      (* 2
  +         earth-radius
  +         (asin (sqrt (+ (haversine (- lat2 lat1))
  +                        (* (cos lat1) (cos lat2)
  +                           (haversine (- lng2 lng1))))))))))
  +
  +(defun transport-time (distance)
  +  (flet ((format-and-print (divisor transport-method)
  +           (format NIL "Human terms: ~,3f hours away by ~a, using an average speed of ~d km/h."
  +                   (/ distance divisor) transport-method divisor)))
  +    (cond
  +      ((< distance 0))
  +      ((< distance 150)
  +       (format-and-print 50 "car"))
  +      ((< distance 2500)
  +       (format-and-print 130 "train"))
  +      ((< distance 12500)
  +       (format-and-print 800 "plane"))
  +      (T
  +       (format-and-print 18000 "ICBM")))))
  +
  +(defun estimated-distance (origin destination)
  +  (multiple-value-bind (from-latitude from-longitude) (coordinates origin)
  +    (multiple-value-bind (to-latitude to-longitude) (coordinates destination)
  +      (let ((distance (great-circle-distance from-longitude from-latitude to-longitude to-latitude)))
  +        (format NIL "Distance: ~,2f km, ~a" distance
  +                (transport-time distance))))))
  
positive.code: (define-command (google geocode) (&rest address) (:documentation "Look up geocoding information about an address.")
    (dolist (result (geocode (format NIL "~{~a~^ ~}" address)))
      (respond event "Address: ~a | Type: ~{~a~^, ~} | Coordinates: ~f/~f"
               (cdr (assoc :types result))
               (cdr (assoc :formatted--address result))
               (cdr (assoc :lat (cdr (assoc :location (cdr (assoc :geometry result))))))
               (cdr (assoc :lng (cdr (assoc :location (cdr (assoc :geometry result)))))))))
  
  (defun geocode (address)
    (let ((json (json-request "http://maps.googleapis.com/maps/api/geocode/json"
  
negative.code: (defpackage org.tymoonnext.colleen.mod.google
    (:use :cl :colleen :events :split-sequence))
  (in-package :org.tymoonnext.colleen.mod.google)
  
  (eval-when (:compile-toplevel :load-toplevel :execute)
    (ql:quickload :parse-number))
  
  