support Potlatch legacy tile scheme; don't support Google
authorRichard Fairhurst <richard@systemed.net>
Tue, 30 Nov 2010 15:05:11 +0000 (15:05 +0000)
committerRichard Fairhurst <richard@systemed.net>
Tue, 30 Nov 2010 15:05:11 +0000 (15:05 +0000)
net/systemeD/halcyon/Map.as
net/systemeD/halcyon/TileSet.as
potlatch2.mxml
resources/imagery.xml

index 4aae32a..2a91e87 100644 (file)
@@ -120,6 +120,9 @@ package net.systemeD.halcyon {
                        while (numChildren) { removeChildAt(0); }
 
                        tileset=new TileSet(this);                                      // 0 - 900913 background
+                       if (initparams['tileblocks']) {                         //   | option to block dodgy tile sources
+                               tileset.blocks=initparams['tileblocks'];//   |
+                       }                                                                                       //   |
                        addChild(tileset);                                                      //   |
                        tileset.init(tileparams);                                       //   |
 
index d35e713..fe631d2 100644 (file)
@@ -23,6 +23,7 @@ package net.systemeD.halcyon {
                private var waiting:int=0;                      // number of tiles currently being downloaded
                private var baseurl:String;                     // e.g. http://npe.openstreetmap.org/$z/$x/$y.png
                private var scheme:String;                      // 900913 or microsoft
+               public var blocks:Array;                        // array of regexes which are verboten
 
                private var map:Map;
 
@@ -149,6 +150,7 @@ package net.systemeD.halcyon {
                // Assemble tile URL
                
                private function tileURL(tx:int,ty:int,tz:uint):String {
+                       var t:String='';
                        switch (scheme.toLowerCase()) {
 
                                case 'microsoft':
@@ -160,18 +162,25 @@ package net.systemeD.halcyon {
                                                if ((ty & mask)!=0) byte+=2;
                                                u+=String(byte);
                                        }
-                                       return baseurl.replace('$quadkey',u);
+                                       t=baseurl.replace('$quadkey',u); break;
 
                                default:
-                                       return baseurl.replace('$z',map.scale).replace('$x',tx).replace('$y',ty);
-                       }       
+                                       if (baseurl.indexOf('$x')>-1) {
+                                               t=baseurl.replace('$z',map.scale).replace('$x',tx).replace('$y',ty);
+                                       } else {
+                                               t=baseurl.replace('!',map.scale).replace('!',tx).replace('!',ty);
+                                       }
+                                       break;
+
+                       }
+                       for each (var block:* in blocks) { if (t.match(block)) return ''; }
+                       return t;
                }
                
                public function get url():String {
                        return baseurl ? baseurl : '';
                }
 
-
                // Update offset
                
                public function nudgeHandler(event:MapEvent):void {
index ea030e1..144ea93 100644 (file)
             b.graphics.endFill();
                        _root.addChild(b);
 
+                       // hard-coded block on Google tiles
+                       var params:Object={};
+                       for (var k:String in this.loaderInfo.parameters) {
+                               params[k]=this.loaderInfo.parameters[k];
+                       }
+                       params['tileblocks']=[new RegExp("google","i")];
+
                        // create map and Yahoo
-                       theMap=new Map(this.loaderInfo.parameters);
+                       theMap=new Map(params);
 
             // Auto-load vector backgrounds from config
             // This could go spectacularly wrong if map.init completes before the event listener below is added
index 154592b..477fed0 100644 (file)
@@ -1,6 +1,16 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
 <imagery>
+       <set>
+               <name>Bing</name>
+               <url>http://ecn.t0.tiles.virtualearth.net/tiles/a$quadkey.jpeg?g=587&mkt=en-gb&n=z</url>
+               <scheme>microsoft</scheme>
+               <sourcetag>Bing</sourcetag>
+               <attribution_url>http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial/0,0?zl=1&mapVersion=v1&key=Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU&include=ImageryProviders&output=xml</attribution_url>
+               <logo>bing_maps.png</logo>
+               <logo_url>http://www.bing.com/maps</logo_url>
+               <terms_url>http://www.microsoft.com/maps/product/terms.html</terms_url>
+       </set>
        <set>
                <name>OSM - Mapnik</name>
                <url>http://tile.openstreetmap.org/$z/$x/$y.png</url>