-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpackage.cl
70 lines (52 loc) · 1.68 KB
/
package.cl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;; This software is Copyright (c) Kevin Layer, 2006-2010.
;; You are granted the rights to distribute
;; and use this software as governed by the terms
;; of the Lisp Lesser GNU Public License
;; (http://opensource.franz.com/preamble.html),
;; known as the LLGPL.
(eval-when (compile eval load) (require :aserve))
(defpackage :cl-geocode
(:use #:common-lisp
#+allegro #:excl
#-allegro #:acl-compat.excl
#:net.aserve
#:net.aserve.client)
#+sbcl
(:import-from #:puri #:delimited-string-to-list)
(:export #:location
#:location-latitude
#:location-longitude
#:make-location
#:distance-between
#:location-near-p)
(:export #:*zipcodes*
#:zipcode-p
#:zipcode-code
#:zipcode-state-abbrev
#:zipcode-latitude
#:zipcode-longitude
#:zipcode-city
#:zipcode-state
#:location-to-zipcode)
(:export #:*default-key*
#:geocode
#:place-to-location
#:location-to-place)
)
(in-package :cl-geocode)
(defstruct location latitude longitude)
(defmethod print-object ((location location) stream)
(if* *print-escape*
then (format stream "#<location ~a,~a>"
(location-latitude location)
(location-longitude location))
else (format stream "~a,~a"
(location-latitude location)
(location-longitude location))))
(defmethod make-load-form ((self location) &optional environment)
(make-load-form-saving-slots self :environment environment))
(defstruct zipcode code state-abbrev location city state)
(defmethod print-object ((zipcode zipcode) stream)
(format stream "#<zipcode ~a (~@[~a, ~]~a): ~a>"
(zipcode-code zipcode) (zipcode-city zipcode) (zipcode-state zipcode)
(zipcode-location zipcode)))