Changeset 3706

Show
Ignore:
Timestamp:
07/31/08 10:54:27 (4 months ago)
Author:
ksprotte
Message:

added reader poi-sat-images and transaction poi-sat-images-exchange-neighbours for edit-poi handler

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/projects/bos/m2/packages.lisp

    r3695 r3706  
    230230           #:poi-center-lon-lat 
    231231           #:poi-images 
     232           #:poi-sat-images 
     233           #:poi-sat-images-exchange-neighbours 
    232234           #:poi-airals 
    233235           #:poi-panoramas 
  • trunk/projects/bos/m2/poi.lisp

    r3700 r3706  
    118118  (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)) 
    119119 
     120;;; POI media are stored in one list - for convenience we provide 
     121;;; accessors by type. POI-IMAGES e.g. returns a list of all 
     122;;; POI-IMAGES in the same order as they appear in the media list. The 
     123;;; second value is a list of corresponding positions in that list. 
    120124(macrolet ((define-poi-medium-reader (name) 
    121125             (let ((type (find-symbol (subseq (symbol-name name) 0 (1- (length (symbol-name name))))))) 
    122126               (assert type) 
    123127               `(defun ,name (poi) 
    124                   (remove-if-not (lambda (medium) (typep medium ',type)) (poi-media poi)))))) 
     128                  ;; this surely could be optimized 
     129                  (let ((media-of-type (remove-if-not (lambda (medium) (typep medium ',type)) (poi-media poi)))) 
     130                    (values media-of-type 
     131                            (mapcar (lambda (medium) (position medium (poi-media poi))) media-of-type))))))) 
    125132  (define-poi-medium-reader poi-images) 
    126133  (define-poi-medium-reader poi-airals) 
    127134  (define-poi-medium-reader poi-panoramas) 
    128135  (define-poi-medium-reader poi-movies)) 
     136 
     137(defun poi-sat-images (poi) 
     138  "We use the 6 last (oldest) images of POI as images for the 
     139  satellite application." 
     140  (multiple-value-bind (images positions) 
     141      (poi-images poi) 
     142    (let* ((length (length images)) 
     143           (start (max 0 (- length 6)))) 
     144      (values (subseq images start length) 
     145              (subseq positions start length))))) 
     146 
     147;;; Provides for the shifting of images in the edit-poi handler. 
     148;;; Exchanges (nth index (poi-sat-images poi)) with 
     149;;; (nth (1+ index) (poi-sat-images poi)). 
     150(deftransaction poi-sat-images-exchange-neighbours (poi index)   
     151  (check-type index (integer 0 4)) 
     152  (multiple-value-bind (images positions) 
     153      (poi-images poi) 
     154    (declare (ignore images)) 
     155    (let ((media-index-a (nth index positions)) 
     156          (media-index-b (nth (1+ index) positions))) 
     157      (rotatef (nth media-index-a (poi-media poi)) 
     158               (nth media-index-b (poi-media poi)))))) 
    129159 
    130160(defun make-poi-javascript (language) 
     
    156186              (poi-center-x poi) 
    157187              (poi-center-y poi) 
    158               (length (poi-images poi))) 
    159       (format t "poi.thumbnail = ~D;~%" (length (poi-images poi))) 
     188              (length (poi-sat-images poi))) 
     189      (format t "poi.thumbnail = ~D;~%" (length (poi-sat-images poi))) 
    160190      (when (poi-airals poi) 
    161191 
     
    169199         for slot-values = (mapcar (lambda (image) 
    170200                                     (escape-nl (slot-string image slot-name language))) 
    171                                    (poi-images poi)) 
     201                                   (poi-sat-images poi)) 
    172202         when slot-values 
    173203         do (format t "poi.~A = [ ~{~S~^, ~} ];~%" javascript-name slot-values)) 
  • trunk/projects/bos/web/poi-handlers.lisp

    r3704 r3706  
    5757      (setq shift (find-store-object (parse-integer shift))) 
    5858      (setq shift-by (parse-integer shift-by)) 
    59       (let* ((new-images (poi-images poi)) 
     59      (let* ((new-images (poi-sat-images poi)) 
    6060             (old-position (position shift new-images)) 
    6161             (tmp (nth old-position new-images))) 
     
    6464        (setf (nth old-position new-images) (nth (+ shift-by old-position) new-images)) 
    6565        (setf (nth (+ shift-by old-position) new-images) tmp) 
    66         (with-transaction ("setf poi-images") 
    67           (setf (poi-images poi) new-images)))) 
     66        (with-transaction ("setf poi-sat-images") 
     67          (setf (poi-sat-images poi) new-images)))) 
    6868    (with-bos-cms-page (:title "Edit POI") 
    6969      (content-language-chooser) 
     
    108108              ((:table) 
    109109               (:tr 
    110                 (loop for image in (poi-images poi) 
     110                (loop for image in (poi-sat-images poi) 
    111111                   for index from 1 by 1 
    112112                   do (html (:td ((:a :href (format nil "/edit-poi-image/~a?poi=~A" (store-object-id image) (store-object-id poi))) 
    113113                                  ((:img :border "0" :src (format nil "/image/~a/thumbnail,,55,55" (store-object-id image))))) 
    114                              :br 
    115                              (if (eql index 1) 
    116                                  (html ((:img :src "/images/trans.gif" :width "16"))) 
    117                                  (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=-1" 
    118                                                           (store-object-id poi) 
    119                                                           (store-object-id image))) 
    120                                         ((:img :border "0" :src "/images/pfeil-l.gif"))))) 
    121                              ((:img :src "/images/trans.gif" :width "23")) 
    122                              (unless (eql index (length (poi-images poi))) 
    123                                (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=1" 
    124                                                         (store-object-id poi) 
    125                                                         (store-object-id image))) 
    126                                       ((:img :border "0" :src "/images/pfeil-r.gif")))))))))) 
    127               (unless (eql 6 (length (poi-images poi))) 
     114                                 :br 
     115                                 (if (eql index 1) 
     116                                     (html ((:img :src "/images/trans.gif" :width "16"))) 
     117                                     (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=-1" 
     118                                                              (store-object-id poi) 
     119                                                              (store-object-id image))) 
     120                                            ((:img :border "0" :src "/images/pfeil-l.gif"))))) 
     121                                 ((:img :src "/images/trans.gif" :width "23")) 
     122                                 (unless (eql index (length (poi-sat-images poi))) 
     123                                   (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=1" 
     124                                                            (store-object-id poi) 
     125                                                            (store-object-id image))) 
     126                                          ((:img :border "0" :src "/images/pfeil-r.gif")))))))))) 
     127              (unless (eql 6 (length (poi-sat-images poi))) 
    128128                (html 
    129129                 :br 
     
    343343                (:tr (:td "upload new image") 
    344344                     (:td ((:input :type "file" :name "image-file")) 
    345                       :br 
    346                       (submit-button "upload" "upload"))) 
     345                          :br 
     346                          (submit-button "upload" "upload"))) 
    347347                (:tr (:td "title") 
    348348                     (:td (text-field "title" 
     
    417417    (let ((image-index (1- (parse-integer image-index-string)))) 
    418418      (if (and (not (minusp image-index)) 
    419                (< image-index (length (poi-images poi)))) 
     419               (< image-index (length (poi-sat-images poi)))) 
    420420          (redirect (format nil "/image/~D~@[~{/~a~}~]" 
    421                             (store-object-id (nth image-index (poi-images poi))) 
     421                            (store-object-id (nth image-index (poi-sat-images poi))) 
    422422                            imageproc-arguments)) 
    423423          (error "image index ~a out of bounds for poi ~a" image-index poi))))) 
     
    437437     ((:param :name "allowFullScreen" :value "true")) 
    438438     ((:embed :src (poi-movie-url poi-movie) :type "application/x-shockwave-flash" 
    439                                              :allowFullScreen "true" 
    440                                              :width "425" :height "344"))))) 
     439              :allowFullScreen "true" 
     440              :width "425" :height "344"))))) 
    441441 
    442442(defun write-poi-xml (poi language) 
     
    468468                       (description poi-description) 
    469469                       (airals poi-airals) 
    470                        (images poi-images) 
     470                       (images poi-sat-images) 
    471471                       (panoramas poi-panoramas) 
    472472                       (movies poi-movies)) poi 
     
    565565                      (with-element "table" 
    566566                        (with-element "tbody" 
    567                           (let ((images (poi-images poi))) 
     567                          (let ((images (poi-sat-images poi))) 
    568568                            (images-2trs (subseq images 0 (min 3 (length images)))) 
    569569                            (when (> (length images) 3)