The quadtree structure is a little wacky, but it&#39;s nice for being able to selectively purge your cache based on regular expressions.<div><br></div><div>Anyhow, here&#39;s the working class. Bit of a hack, but it does the trick:</div>

<div><br></div><div><div>var VELayer = OpenLayers.Class(OpenLayers.Layer.XYZ, {</div><div>    name: &quot;VirtualEarth&quot;,</div><div>    attribution: &quot;Microsoft&quot;,</div><div>    sphericalMercator: true,</div>
<div>
    url: &#39;/tiles/a${n}.jpeg&#39;,</div><div>    CLASS_NAME: &quot;VELayer&quot;,</div><div><br></div><div>    getURL: function (bounds) {</div><div>        var res = this.map.getResolution();</div><div>        var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));</div>

<div>        var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));</div><div>        var z = this.map.getZoom();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>x = x.toString(2);</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>y = y.toString(2);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>while(x.length &lt; z) { x = &quot;0&quot; + x; }</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>while(y.length &lt; z) { y = &quot;0&quot; + y; }</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>var n = [];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>for(var i = 0; i &lt; z; i++) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>  n.push((parseInt(x[i]) + parseInt(y[i]) * 2).toString());   </div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>        var url = this.url;</div><div>        var path = OpenLayers.String.format(url, {&#39;n&#39;: n.join(&#39;&#39;) });</div><div><br></div>

<div>        return path;</div><div>    }</div><div>});</div></div><div><br></div><div><br><br><div class="gmail_quote">On Tue, Jul 13, 2010 at 10:57 AM, Stephen Woodbridge <span dir="ltr">&lt;<a href="mailto:woodbri@swoodbridge.com">woodbri@swoodbridge.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Right! that is not the intent here. I have clients that are moving away from Bing but have apps that are built around this tile name scheme. They would like to create a cache using mapserver of tiles like this for their other apps. being about to browse the cache in OL makes it much easier to develop, review and build web apps all using the same cache.<br>


<br>
The big issue I see with this is determining an appropriate directory structure that maximizes tile storage in dirs so you don&#39;t have excessive directory overhead and that you do not have too many files in a directory or run out of inodes.<br>


<br>
-Steve<div><div></div><div class="h5"><br>
<br>
Andreas Hocevar wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Mind that using Bing tiles directly is a violation of the Bing Maps terms of use.<br>
<br>
Regards,<br>
Andreas.<br>
<br>
On Jul 13, 2010, at 15:33 , Mike Purvis wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hey,<br>
<br>
If I want to serve the Bing tiles directly, without using the VirtualEarth wrapper layer, has that already been coded up by anyone? I know it&#39;s just a matter of extending Openlayers.Layer.XYZ and plugging in the correct geturl function. It&#39;s just that Bing&#39;s tile urls are based on some quadtree nonsense that makes it slightly more of a pain that just dropping in the coordinates.<br>


<br>
Nevermind about whether it&#39;s a good idea or not—has it already been done, or should I just do it myself?<br>
<br>
Thanks!<br>
<br>
Mike<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
</blockquote>
<br>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://uwmike.com">http://uwmike.com</a><br>
</div>