Changeset 2775
- Timestamp:
- 03/20/08 14:20:00 (10 months ago)
- Files:
-
- trunk/projects/bos/m2/packages.lisp (modified) (1 diff)
- trunk/projects/bos/m2/poi.lisp (modified) (2 diffs)
- trunk/projects/bos/web/poi-handlers.lisp (modified) (1 diff)
- trunk/projects/bos/web/webserver.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/bos/m2/packages.lisp
r2632 r2775 209 209 #:poi-center-x 210 210 #:poi-center-y 211 #:poi-center-lon-lat 211 212 #:make-poi-javascript 212 213 #:write-poi-xml 214 #:write-poi-kml 215 213 216 ;; news 214 217 #:news-item trunk/projects/bos/m2/poi.lisp
r2147 r2775 121 121 (defmethod poi-center-y ((poi poi)) 122 122 (second (poi-area poi))) 123 124 (defun poi-center-lon-lat (poi) 125 (geo-utm:utm-x-y-to-lon-lat (+ +nw-utm-x+ (poi-center-x poi)) (- +nw-utm-y+ (poi-center-y poi)) +utm-zone+ t)) 123 126 124 127 (defun make-poi-javascript (language) … … 177 180 (format t "poi['thumbnail'] = 0;~%") 178 181 (format t "pois.push(poi);~%"))))) 182 183 (defun write-poi-xml (poi &optional prefix) 184 (macrolet ((with-element (qname &body body) 185 `(with-element* (prefix ,qname) ,@body))) 186 (labels ((format-hash-table (element-name hash-table) 187 (with-element element-name 188 (maphash (lambda (k v) 189 (with-element "content" 190 (attribute "lang" k) 191 (text v))) 192 hash-table))) 193 (format-store-image (element-name store-image) 194 (with-element element-name 195 (with-element "id" (text (princ-to-string (store-object-id store-image)))) 196 (with-element "name" (text (store-image-name store-image))) 197 (with-element "width" (text (princ-to-string (store-image-width store-image)))) 198 (with-element "height" (text (princ-to-string (store-image-height store-image))))))) 199 (with-accessors ((id store-object-id) 200 (name poi-name) 201 (title poi-title) 202 (subtitle poi-subtitle) 203 (description poi-description) 204 (airals poi-airals) 205 (images poi-images) 206 (panoramas poi-panoramas) 207 (movies poi-movies)) poi 208 (with-element "poi" 209 (with-element "id" (text (princ-to-string id))) 210 (with-element "name" (text name)) 211 (format-hash-table "title" title) 212 (format-hash-table "subtitle" subtitle) 213 (format-hash-table "description" description) 214 (with-element "airals" 215 (mapc (alexandria:curry #'format-store-image "airal") airals)) 216 (with-element "images" 217 (mapc (alexandria:curry #'format-store-image "image") images)) 218 (with-element "panoramas" 219 (mapc (alexandria:curry #'format-store-image "panorama") panoramas)) 220 (with-element "movies" 221 (dolist (url movies) 222 (with-element "movie" 223 (with-element "url" (text url)))))))))) 224 225 (defun write-poi-kml (poi) 226 (with-element "Placemark" 227 (with-element "name" (text (poi-name poi))) 228 (with-element "description" 229 (with-namespace ("bos" "http://headcraft.de/bos") 230 (write-poi-xml poi "bos"))) 231 (with-element "Point" 232 (with-element "coordinates" 233 (text (format nil "~{~F,~}0" (poi-center-lon-lat poi))))))) trunk/projects/bos/web/poi-handlers.lisp
r2763 r2775 395 395 396 396 (defmethod handle-object ((handler poi-xml-handler) poi) 397 (labels ((format-hash-table (element-name hash-table) 398 (with-element element-name 399 (maphash (lambda (k v) 400 (with-element "content" 401 (attribute "lang" k) 402 (text v))) 403 hash-table))) 404 (format-store-image (element-name store-image) 405 (with-element element-name 406 (with-element "id" (text (princ-to-string (store-object-id store-image)))) 407 (with-element "name" (text (store-image-name store-image))) 408 (with-element "width" (text (princ-to-string (store-image-width store-image)))) 409 (with-element "height" (text (princ-to-string (store-image-height store-image))))))) 410 (with-accessors ((id store-object-id) 411 (name poi-name) 412 (title poi-title) 413 (subtitle poi-subtitle) 414 (description poi-description) 415 (airals poi-airals) 416 (images poi-images) 417 (panoramas poi-panoramas) 418 (movies poi-movies)) poi 419 (with-xml-response (:root-element "poi") 420 (with-element "id" (text (princ-to-string id))) 421 (with-element "name" (text name)) 422 (format-hash-table "title" title) 423 (format-hash-table "subtitle" subtitle) 424 (format-hash-table "description" description) 425 (with-element "airals" 426 (mapc (alexandria:curry #'format-store-image "airal") airals)) 427 (with-element "images" 428 (mapc (alexandria:curry #'format-store-image "image") images)) 429 (with-element "panoramas" 430 (mapc (alexandria:curry #'format-store-image "panorama") panoramas)) 431 (with-element "movies" 432 (dolist (url movies) 433 (with-element "movie" 434 (with-element "url" (text url))))))))) 435 397 (with-xml-response () 398 (write-poi-xml poi))) 399 400 (defclass poi-kml-handler (object-handler) 401 () 402 (:default-initargs :object-class 'poi :query-function #'find-poi)) 403 404 405 (defmethod handle-object ((handler poi-kml-handler) poi) 406 (with-xml-response () 407 (sax:processing-instruction cxml::*sink* "xml-stylesheet" "href=\"/static/trivial.xsl\" type=\"text/xsl\"") 408 (with-namespace (nil "http://earth.google.com/kml/2.1") 409 (with-element "kml" 410 (write-poi-kml poi))))) 411 412 (defclass poi-kml-all-handler (page-handler) 413 ()) 414 415 (defmethod handle ((handler poi-kml-all-handler)) 416 (with-xml-response () 417 ;; (sax:processing-instruction cxml::*sink* "xml-stylesheet" "href=\"/static/tri.xsl\" type=\"text/xsl\"") 418 (with-namespace (nil "http://earth.google.com/kml/2.1") 419 (with-element "kml" 420 (with-element "Document" 421 (mapc #'write-poi-kml (remove-if-not #'poi-area (class-instances 'poi)))))))) 422 trunk/projects/bos/web/webserver.lisp
r2763 r2775 212 212 ("/poi-image" poi-image-handler) 213 213 ("/poi-xml" poi-xml-handler) 214 ("/poi-kml-all" poi-kml-all-handler) 215 ("/poi-kml" poi-kml-handler) 214 216 ("/map-browser" map-browser-handler) 215 217 ("/poi-javascript" poi-javascript-handler)
