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 8d609361e4f27c6480511b28c099baa8575d1610..0ad5a3476cb3f2fdb1664fa9860d3db1d1af546e 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 1d2ed792632dc071ba424d4af910fc28a892b46b..116710d2a6081709984e757ec1dd358d5ccfda0b 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>