Round-robin tile naming
authorRichard Fairhurst <richard@systemeD.net>
Fri, 6 Jul 2012 15:59:14 +0000 (16:59 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Fri, 6 Jul 2012 15:59:14 +0000 (16:59 +0100)
net/systemeD/halcyon/TileSet.as
resources/imagery.xml

index 8d60936..0ad5a34 100644 (file)
@@ -25,6 +25,9 @@ package net.systemeD.halcyon {
                private var scheme:String;                      // 900913 or microsoft
                public var blocks:Array;                        // array of regexes which are verboten
 
+               private var count:Number=0;                     // counter incremented to provide a/b/c/d tile swapping
+               private static const ROUNDROBIN:RegExp =/\$\{([^}]+)\}/;
+
                private var map:Map;
                private const MAXTILEREQUESTS:uint= 4;
                private const MAXTILESLOADED:uint=30;
@@ -241,6 +244,14 @@ package net.systemeD.halcyon {
                                        break;
 
                        }
+                       var o:Object=new Object();
+                       if ((o=ROUNDROBIN.exec(t))) {
+                               var prefixes:Array=o[1].split('|');
+                               var p:String = prefixes[count % prefixes.length];
+                               t=t.replace(ROUNDROBIN,p);
+                               count++;
+                       }
+
                        for each (var block:* in blocks) { if (t.match(block)) return ''; }
                        return t;
                }
index 1d2ed79..116710d 100644 (file)
     </set>
        <set>
                <name>OSM - Mapnik</name>
-               <url>http://c.tile.openstreetmap.org/$z/$x/$y.png</url>
-       </set>
-       <set>
-               <name>OSM - Osmarender</name>
-               <url>http://tah.openstreetmap.org/Tiles/tile/$z/$x/$y.png</url>
+               <url>http://${a|b|c}.tile.openstreetmap.org/$z/$x/$y.png</url>
        </set>
     <set>
         <name>OSM - OpenCycleMap</name>