[bknr-cvs] hans changed trunk/projects/bos/

BKNR Commits bknr at bknr.net
Tue Dec 2 22:00:37 UTC 2008


Revision: 4106
Author: hans
URL: http://bknr.net/trac/changeset/4106

Add satellite map browser using Google Maps.

U   trunk/projects/bos/m2/simple-sat-map.lisp
U   trunk/projects/bos/payment-website/static/poi-ms.css
U   trunk/projects/bos/payment-website/static/poi-ms.html
U   trunk/projects/bos/payment-website/static/poi-ms.js
U   trunk/projects/bos/web/map-handlers.lisp
U   trunk/projects/bos/web/webserver.lisp

Modified: trunk/projects/bos/m2/simple-sat-map.lisp
===================================================================
--- trunk/projects/bos/m2/simple-sat-map.lisp	2008-12-01 23:37:14 UTC (rev 4105)
+++ trunk/projects/bos/m2/simple-sat-map.lisp	2008-12-02 22:00:36 UTC (rev 4106)
@@ -39,7 +39,7 @@
              (cl-gd:with-image (tile tile-size tile-size t)
                (let ((tile-source-size (/ size (expt 2 level))))
                  (cl-gd:copy-image map-image tile
-                                   (* x tile-source-size) (* y tile-source-size)
+                                   x y
                                    0 0
                                    tile-source-size tile-source-size
                                    :dest-width tile-size :dest-height tile-size
@@ -58,4 +58,15 @@
                                         (write-quad (+ x next-tile-source-size) (+ y next-tile-source-size) next-level))))))))))
         (make-instance 'tree
                        :name basename
-                       :root (write-quad 0 0 0))))))
\ No newline at end of file
+                       :root (write-quad 0 0 0))))))
+
+(defclass simple-map-handler (bknr.images::imageproc-handler)
+  ())
+
+(defmethod bknr.web:object-handler-get-object ((handler simple-map-handler))
+  (let ((node (tree-root (tree-with-name (bknr.web:parse-url))))
+        (path (or (bknr.web:query-param "path") "")))
+      (dotimes (i (length path))
+        (setf node (nth (parse-integer path :start i :end (1+ i))
+                        (node-children node))))
+    (node-image node)))

Modified: trunk/projects/bos/payment-website/static/poi-ms.css
===================================================================
--- trunk/projects/bos/payment-website/static/poi-ms.css	2008-12-01 23:37:14 UTC (rev 4105)
+++ trunk/projects/bos/payment-website/static/poi-ms.css	2008-12-02 22:00:36 UTC (rev 4106)
@@ -34,3 +34,8 @@
 .map .icon, .map .contract {
     position: absolute;
 }
+
+#google-map {
+    width: 400px;
+    height: 300px;
+}
\ No newline at end of file

Modified: trunk/projects/bos/payment-website/static/poi-ms.html
===================================================================
--- trunk/projects/bos/payment-website/static/poi-ms.html	2008-12-01 23:37:14 UTC (rev 4105)
+++ trunk/projects/bos/payment-website/static/poi-ms.html	2008-12-02 22:00:36 UTC (rev 4106)
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <title>POI Microsite </title>
@@ -7,6 +7,7 @@
     <script src="MochiKit/MochiKit.js" type="text/javascript"> </script>
     <script src="jquery-nightly.js" type="text/javascript"> </script>
     <script src="poi-ms.js" type="text/javascript"> </script>
+    <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA5meUSZ1F7u46UjJHEXSlJhSjRafg-mK9ocVykr2yWZT0eqYCERSER_a6AB49FBiDXdm_NDfIDZUmIg" type="text/javascript"> </script>
     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
   </head>
   <body>
@@ -28,6 +29,7 @@
           <select id="poi-selector" size="1">
             <option value="overview">Ãœbersicht</option>
             <option value="sponsors">Sponsoren</option>
+            <option value="map">Google Map</option>
           </select>
           <div id="left-bar">
           </div>

Modified: trunk/projects/bos/payment-website/static/poi-ms.js
===================================================================
--- trunk/projects/bos/payment-website/static/poi-ms.js	2008-12-01 23:37:14 UTC (rev 4105)
+++ trunk/projects/bos/payment-website/static/poi-ms.js	2008-12-02 22:00:36 UTC (rev 4106)
@@ -2,6 +2,7 @@
 
 $(document).ready(init);
 
+var googleMapKey = "ABQIAAAA5meUSZ1F7u46UjJHEXSlJhQkkdysj0TmG3bX_n9aMEXHvIwNeRQLmdjbjYpAetJRis7naMxi-fqMRQ";
 var pois = {};
 var sponsors = [];
 
@@ -163,29 +164,90 @@
     $('#left-bar')
     .empty()
     .append(UL({ id: 'media-list' }));
-    if (!poi) {
-        showOverview();
-    } else {
-        $('#poi-selector').val(poi.id);
+    $('#poi-selector').val(poi.id);
 
-        document.title = poi.title;
-        $('.yui-b h1').html(poi.title);
-        loadMainInfo(poi);
-        map(function (medium) {
-            if (mediaHandlers[medium.mediumType]) {
-                $('#media-list')
-                .append($(A({ href: '#' },
-                            LI(null,
-                               mediaHandlers[medium.mediumType].icon(medium),
-                               (new Date(medium.timestamp)).renderDate(),
-                               BR(),
-                               B(null, medium.title || medium.name))))
-                        .bind('click', medium, showMedium));
-            }
-        }, poi.media);
+    document.title = poi.title;
+    $('.yui-b h1').html(poi.title);
+    loadMainInfo(poi);
+    map(function (medium) {
+        if (mediaHandlers[medium.mediumType]) {
+            $('#media-list')
+            .append($(A({ href: '#' },
+                        LI(null,
+                           mediaHandlers[medium.mediumType].icon(medium),
+                           (new Date(medium.timestamp)).renderDate(),
+                           BR(),
+                           B(null, medium.title || medium.name))))
+                    .bind('click', medium, showMedium));
+        }
+    }, poi.media);
+}
+
+function pointToPath(point, level) {
+    var x = point.x;
+    var y = point.y;
+    var path = '';
+    for (var i = 0; i < level; i++) {
+        path = ((x & 1) + ((y & 1) << 1)) + path;
+        x >>= 1;
+        y >>= 1;
     }
+    return path;
 }
 
+function showGoogleMap() {
+    var mapDiv = DIV({ id: 'google-map' });
+    $('#content')
+
+    .empty()
+    .append(H2(null, NLS('Google Map')),
+            mapDiv);
+
+    $('#left-bar')
+    .empty();
+
+    var map = new GMap2(mapDiv);
+
+    var copyright
+        = new GCopyright(1,
+                         new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)),
+                         3,
+                         "Copyright BOS Deutschland e.V.");
+    var copyrightCollection = new GCopyrightCollection('Map');
+    copyrightCollection.addCopyright(copyright);
+    var tileLayers = [new GTileLayer(copyrightCollection, 0, 7)];
+    var projection = new GMercatorProjection(7);
+    tileLayers[0].getTileUrl = function(point, level) {
+        if (level < 7) {
+            var path = pointToPath(point, level);
+            log('getTileUrl: x:' + point.x + ' y:' + point.y + ' level:' + level + ' path: ' + path);
+            return '/simple-map/sl_utm50s-0?path=' + path;
+        } else {
+            return null;
+        }
+    }
+    var customMap = new GMapType(tileLayers, projection, 'Map', { errorMessage: NLS("Keine Daten in dieser Zoomstufe") });
+    map.addMapType(customMap);
+    map.addControl(new GLargeMapControl());
+
+    map.setCenter(new GLatLng(0, 0), 1, customMap);
+}
+
+var pages = {
+    overview: showOverview,
+    map: showGoogleMap
+}
+
+function selectPage(e) {
+    var value = e.target.value;
+
+    if (value.match(/^\d+/)) {
+        showPOI(e);
+    } else if (pages[value]) {
+        pages[value](e);
+    }
+}
+
 function showSponsor(e) {
     var sponsor = e.data;
     var contract = sponsor.contracts[0];
@@ -275,7 +337,7 @@
             pois[poi.id] = poi;
             $('#poi-selector').append(OPTION({ value: poi.id }, poi.title));
         }
-        $('#poi-selector').bind('change', null, showPOI);
+        $('#poi-selector').bind('change', null, selectPage);
 
         loadJSONDoc('/sponsors-json').addCallback(loadSponsors);
     }

Modified: trunk/projects/bos/web/map-handlers.lisp
===================================================================
--- trunk/projects/bos/web/map-handlers.lisp	2008-12-01 23:37:14 UTC (rev 4105)
+++ trunk/projects/bos/web/map-handlers.lisp	2008-12-02 22:00:36 UTC (rev 4106)
@@ -4,7 +4,8 @@
 
 (defun map-navigator (x y base-url &key formcheck)
   (labels ((pfeil-image (name)
-             (html ((:img :border "0" :width "16" :height "16" :src (format nil "/images/~:[trans.gif~;~:*pfeil-~A.gif~]" name)))))
+             (html ((:img :border "0" :width "16" :height "16"
+                                                  :src (format nil "/images/~:[trans.gif~;~:*pfeil-~A.gif~]" name)))))
            (td-link-to (x y name &optional (link-format (concatenate 'string base-url "~D/~D")))
              (html (:td (if (or (minusp x)
                                 (minusp y)

Modified: trunk/projects/bos/web/webserver.lisp
===================================================================
--- trunk/projects/bos/web/webserver.lisp	2008-12-01 23:37:14 UTC (rev 4105)
+++ trunk/projects/bos/web/webserver.lisp	2008-12-02 22:00:36 UTC (rev 4106)
@@ -183,6 +183,7 @@
                                         ("/poi-kml-look-at" poi-kml-look-at-handler)
                                         ("/poi-kml" poi-kml-handler)
                                         ("/map-browser" map-browser-handler)
+                                        ("/simple-map" ssm::simple-map-handler)
                                         ("/poi-javascript" poi-javascript-handler)
                                         ("/m2-javascript" m2-javascript-handler)
                                         ("/poi-json" poi-json-handler)





More information about the Bknr-cvs mailing list