Skip to content
Browse files

Merge branch 'master' of github.com:mbostock/polymaps

  • Loading branch information...
2 parents efd26da + bebaf97 commit 6820f1497b7bed159f810ffc9202ea0a8a25e787 @mbostock mbostock committed Feb 11, 2011
Showing with 188 additions and 110 deletions.
  1. +1 −0 examples/cloudmade/pale-dawn.js
  2. +1 −1 lib/blueprint/screen.css
  3. +62 −24 polymaps.js
  4. +62 −61 polymaps.min.js
  5. +2 −3 src/Compass.js
  6. +32 −11 src/Hash.js
  7. +12 −6 src/Image.js
  8. +15 −3 src/Url.js
  9. +1 −1 src/start.js
View
1 examples/cloudmade/pale-dawn.js
@@ -9,6 +9,7 @@ map.add(po.image()
.url(po.url("http://{S}tile.cloudmade.com"
+ "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register
+ "/998/256/{Z}/{X}/{Y}.png")
+ .repeat(false)
.hosts(["a.", "b.", "c.", ""])));
map.add(po.compass()
View
2 lib/blueprint/screen.css
@@ -67,7 +67,7 @@ caption {background:#eee;}
.hide {display:none;}
.quiet {color:#666;}
.loud {color:#000;}
-.highlight {background:#ff0;}
+/*.highlight {background:#ff0;}*/
.added {background:#060;color:#fff;}
.removed {background:#900;color:#fff;}
.first {margin-left:0;padding-left:0;}
View
86 polymaps.js
@@ -2,7 +2,7 @@ if (!org) var org = {};
if (!org.polymaps) org.polymaps = {};
(function(po){
- po.version = "2.2+1.0+2"; // This fork not semver!
+ po.version = "2.4.0+1"; // not semver!
var zero = {x: 0, y: 0};
po.ns = {
@@ -182,12 +182,18 @@ po.cache = function(load, unload) {
return cache;
};
po.url = function(template) {
- var hosts = [];
+ var hosts = [],
+ repeat = true;
function format(c) {
var max = c.zoom < 0 ? 1 : 1 << c.zoom,
- column = c.column % max;
- if (column < 0) column += max;
+ column = c.column;
+ if (repeat) {
+ column = c.column % max;
+ if (column < 0) column += max;
+ } else if ((column < 0) || (column >= max)) {
+ return null;
+ }
return template.replace(/{(.)}/g, function(s, v) {
switch (v) {
case "S": return hosts[(Math.abs(c.zoom) + c.row + column) % hosts.length];
@@ -220,6 +226,12 @@ po.url = function(template) {
return format;
};
+ format.repeat = function(x) {
+ if (!arguments.length) return repeat;
+ repeat = x;
+ return format;
+ };
+
return format;
};
po.dispatch = function(that) {
@@ -1098,16 +1110,22 @@ po.image = function() {
if (typeof url == "function") {
element.setAttribute("opacity", 0);
- tile.request = po.queue.image(element, url(tile), function(img) {
- delete tile.request;
+ var tileUrl = url(tile);
+ if (tileUrl != null) {
+ tile.request = po.queue.image(element, tileUrl, function(img) {
+ delete tile.request;
+ tile.ready = true;
+ tile.img = img;
+ element.removeAttribute("opacity");
+ image.dispatch({type: "load", tile: tile});
+ });
+ } else {
tile.ready = true;
- tile.img = img;
- element.removeAttribute("opacity");
image.dispatch({type: "load", tile: tile});
- });
+ }
} else {
tile.ready = true;
- if (url) element.setAttributeNS(po.ns.xlink, "href", url);
+ if (url != null) element.setAttributeNS(po.ns.xlink, "href", url);
image.dispatch({type: "load", tile: tile});
}
}
@@ -1763,26 +1781,35 @@ po.hash = function() {
lat = 90 - 1e-8, // allowable latitude range
map;
- function move() {
+ var parser = function(map, s) {
+ var args = s.split("/").map(Number);
+ if (args.length < 3 || args.some(isNaN)) return true; // replace bogus hash
+ else {
+ var size = map.size();
+ map.zoomBy(args[0] - map.zoom(),
+ {x: size.x / 2, y: size.y / 2},
+ {lat: Math.min(lat, Math.max(-lat, args[1])), lon: args[2]});
+ }
+ };
+
+ var formatter = function(map) {
var center = map.center(),
zoom = map.zoom(),
- precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
- s1 = "#" + zoom.toFixed(2)
+ precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
+ return "#" + zoom.toFixed(2)
+ "/" + center.lat.toFixed(precision)
+ "/" + center.lon.toFixed(precision);
+ };
+
+ function move() {
+ var s1 = formatter(map);
if (s0 !== s1) location.replace(s0 = s1); // don't recenter the map!
}
function hashchange() {
if (location.hash === s0) return; // ignore spurious hashchange events
- var args = (s0 = location.hash).substring(1).split("/").map(Number);
- if (args.length < 3 || args.some(isNaN)) move(); // replace bogus hash
- else {
- var size = map.size();
- map.zoomBy(args[0] - map.zoom(),
- {x: size.x / 2, y: size.y / 2},
- {lat: Math.min(lat, Math.max(-lat, args[1])), lon: args[2]});
- }
+ if (parser(map, (s0 = location.hash).substring(1)))
+ move(); // replace bogus hash
}
hash.map = function(x) {
@@ -1799,6 +1826,18 @@ po.hash = function() {
return hash;
};
+ hash.parser = function(x) {
+ if (!arguments.length) return parser;
+ parser = x;
+ return hash;
+ };
+
+ hash.formatter = function(x) {
+ if (!arguments.length) return formatter;
+ formatter = x;
+ return hash;
+ };
+
return hash;
};
// Default map controls.
@@ -2010,9 +2049,8 @@ po.compass = function() {
case "bottom-left": y = size.y - y; break;
case "bottom-right": x = size.x - x; y = size.y - y; break;
}
- var tx = "translate(" + x + "," + y + ")";
- if (panContainer) panContainer.setAttribute("transform", tx);
- if (zoomContainer) zoomContainer.setAttribute("transform", tx);
+ g.setAttribute("transform", "translate(" + x + "," + y + ")");
+ dragRect.setAttribute("transform", "translate(" + -x + "," + -y + ")");
for (var i in ticks) {
i == map.zoom()
? ticks[i].setAttribute("class", "active")
View
123 polymaps.min.js
@@ -1,62 +1,63 @@
if(!org)var org={};if(!org.polymaps)org.polymaps={};
-(function(s){function fa(e){var g=e.indexOf(":");return g<0?e:{space:s.ns[e.substring(0,g)],local:e.substring(g+1)}}function S(){for(var e=0;e<S.maps.length;e++)S.maps[e].resize()}function V(e){return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function W(e){return 180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360))}function Z(e,g){if(e.row>g.row){var c=e;e=g;g=c}return{x0:e.column,y0:e.row,x1:g.column,y1:g.row,dx:g.column-e.column,dy:g.row-e.row}}function ca(e,g,c,k,i){c=Math.max(c,Math.floor(g.y0));
-k=Math.min(k,Math.ceil(g.y1));if(e.x0==g.x0&&e.y0==g.y0?e.x0+g.dy/e.dy*e.dx<g.x1:e.x1-g.dy/e.dy*e.dx<g.x0){var a=e;e=g;g=a}a=e.dx/e.dy;var f=g.dx/g.dy,m=e.dx>0,q=g.dx<0;for(c=c;c<k;c++){var t=a*Math.max(0,Math.min(e.dy,c+m-e.y0))+e.x0;i(Math.floor(f*Math.max(0,Math.min(g.dy,c+q-g.y0))+g.x0),Math.ceil(t),c)}}function da(e,g,c,k,i,a){var f=Z(e,g);g=Z(g,c);e=Z(c,e);if(f.dy>g.dy){c=f;f=g;g=c}if(f.dy>e.dy){c=f;f=e;e=c}if(g.dy>e.dy){c=g;g=e;e=c}f.dy&&ca(e,f,k,i,a);g.dy&&ca(e,g,k,i,a)}s.version="2.2+1.0+2";
-var Y={x:0,y:0};s.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};s.id=function(){var e=0;return function(){return++e}}();s.svg=function(e){return document.createElementNS(s.ns.svg,e)};s.transform=function(e,g,c,k,i,a){var f={},m,q,t;if(!arguments.length){e=1;g=i=c=0;k=1;a=0}f.zoomFraction=function(l){if(!arguments.length)return q;q=l;m=Math.floor(q+Math.log(Math.sqrt(e*e+g*g+c*c+k*k))/Math.log(2));t=Math.pow(2,-m);return f};f.apply=function(l){var j=Math.pow(2,-l.zoom),
-u=Math.pow(2,l.zoom-m);return{column:(e*l.column*j+c*l.row*j+i)*u,row:(g*l.column*j+k*l.row*j+a)*u,zoom:l.zoom-m}};f.unapply=function(l){var j=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+m);return{column:(l.column*j*k-l.row*j*c-i*k+a*c)/(e*k-g*c)*u,row:(l.column*j*g-l.row*j*e-i*g+a*e)/(c*g-k*e)*u,zoom:l.zoom+m}};f.toString=function(){return"matrix("+[e*t,g*t,c*t,k*t].join(" ")+" 0 0)"};return f.zoomFraction(0)};s.cache=function(e,g){function c(j){l--;g&&g(j);delete f[j.key];if(j.next)j.next.prev=j.prev;
-else if(q=j.prev)q.next=null;if(j.prev)j.prev.next=j.next;else if(m=j.next)m.prev=null}function k(){for(var j=q;l>t;j=j.prev){if(!j)break;j.lock||c(j)}}var i={},a={},f={},m=null,q=null,t=64,l=0;i.peek=function(j){return f[[j.zoom,j.column,j.row].join("/")]};i.load=function(j,u){var y=[j.zoom,j.column,j.row].join("/"),A=f[y];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else q=A.prev;A.prev=null;A.next=m;m=m.prev=A}A.lock=1;return a[y]=A}A={key:y,column:j.column,row:j.row,zoom:j.zoom,next:m,
-prev:null,lock:1};e.call(null,A,u);a[y]=f[y]=A;if(m)m.prev=A;else q=A;m=A;l++;return A};i.unload=function(j){if(!(j in a))return false;var u=a[j];u.lock=0;delete a[j];u.request&&u.request.abort(false)&&c(u);return u};i.locks=function(){return a};i.size=function(j){if(!arguments.length)return t;t=j;k();return i};i.flush=function(){k();return i};i.clear=function(){for(var j in f){var u=f[j];u.request&&u.request.abort(false);g&&g(f[j]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
-{};f={};m=q=null;l=0;return i};return i};s.url=function(e){function g(k){var i=k.zoom<0?1:1<<k.zoom,a=k.column%i;if(a<0)a+=i;return e.replace(/{(.)}/g,function(f,m){switch(m){case "S":return c[(Math.abs(k.zoom)+k.row+a)%c.length];case "Z":return k.zoom;case "X":return a;case "Y":return k.row;case "B":var q=s.map.coordinateLocation({row:k.row,column:a,zoom:k.zoom}),t=s.map.coordinateLocation({row:k.row+1,column:a+1,zoom:k.zoom}),l=Math.ceil(Math.log(k.zoom)/Math.LN2);return t.lat.toFixed(l)+","+q.lon.toFixed(l)+
-","+q.lat.toFixed(l)+","+t.lon.toFixed(l)}return m})}var c=[];g.template=function(k){if(!arguments.length)return e;e=k;return g};g.hosts=function(k){if(!arguments.length)return c;c=k;return g};return g};s.dispatch=function(e){var g={};e.on=function(c,k){for(var i=g[c]||(g[c]=[]),a=0;a<i.length;a++)if(i[a].handler==k)return e;i.push({handler:k,on:true});return e};e.off=function(c,k){var i=g[c];if(i)for(var a=0;a<i.length;a++){var f=i[a];if(f.handler==k){f.on=false;i.splice(a,1);break}}return e};return function(c){var k=
-g[c.type];if(k){k=k.slice();for(var i=0;i<k.length;i++){var a=k[i];a.on&&a.handler.call(e,c)}}}};s.queue=function(){function e(){if(!(i>=a||!k.length)){i++;k.pop()()}}function g(f){for(var m=0;m<k.length;m++)if(k[m]==f){k.splice(m,1);return true}return false}function c(f,m,q){function t(){l=new XMLHttpRequest;q&&l.overrideMimeType(q);l.open("GET",f,true);l.onreadystatechange=function(){if(l.readyState==4){i--;l.status<300&&m(l);e()}};l.send(null)}var l;k.push(t);e();return{abort:function(j){if(g(t))return true;
-if(j&&l){l.abort();return true}return false}}}var k=[],i=0,a=6;return{text:function(f,m,q){return c(f,function(t){t.responseText&&m(t.responseText)},q)},xml:function(f,m){return c(f,function(q){q.responseXML&&m(q.responseXML)},"application/xml")},json:function(f,m){return c(f,function(q){q.responseText&&m(JSON.parse(q.responseText))},"application/json")},image:function(f,m,q){function t(){l=document.createElement("img");l.onerror=function(){i--;e()};l.onload=function(){i--;q(l);e()};l.src=m;f.setAttributeNS(s.ns.xlink,
-"href",m)}var l;k.push(t);e();return{abort:function(j){if(g(t))return true;if(j&&l){l.src="about:";return true}return false}}}}}();s.map=function(){function e(){if(u)if(t<u[0])t=u[0];else if(t>u[1])t=u[1];l=t-(t=Math.round(t));j=Math.pow(2,l)}function g(){if(n){var d=45/Math.pow(2,t+l-3),r=Math.max(Math.abs(C*f.x+A*f.y),Math.abs(B*f.x+E*f.y)),o=V(K-r*d/m.y);r=V(h+r*d/m.y);q.lat=Math.max(o,Math.min(r,q.lat));o=Math.max(Math.abs(C*f.y+A*f.x),Math.abs(B*f.y+E*f.x));q.lon=Math.max(n[0].lon-o*d/m.x,Math.min(n[1].lon+
-o*d/m.x,q.lon))}}var c={},k,i,a=Y,f=Y,m={x:256,y:256},q={lat:37.76487,lon:-122.41948},t=12,l=0,j=1,u=[1,18],y=0,A=1,C=0,E=1,B=0,K=-180,h=180,n=[{lat:V(K),lon:-Infinity},{lat:V(h),lon:Infinity}];c.locationCoordinate=function(d){d=s.map.locationCoordinate(d);var r=Math.pow(2,t);d.column*=r;d.row*=r;d.zoom+=t;return d};c.coordinateLocation=s.map.coordinateLocation;c.coordinatePoint=function(d,r){var o=Math.pow(2,t-r.zoom),z=Math.pow(2,t-d.zoom),v=(r.column*o-d.column*z)*m.x*j;o=(r.row*o-d.row*z)*m.y*
-j;return{x:f.x+A*v-C*o,y:f.y+C*v+A*o}};c.pointCoordinate=function(d,r){var o=Math.pow(2,t-d.zoom),z=(r.x-f.x)/j,v=(r.y-f.y)/j;return{column:d.column*o+(E*z-B*v)/m.x,row:d.row*o+(B*z+E*v)/m.y,zoom:t}};c.locationPoint=function(d){var r=Math.pow(2,t+l-3)/45,o=(d.lon-q.lon)*r*m.x;d=(W(q.lat)-W(d.lat))*r*m.y;return{x:f.x+A*o-C*d,y:f.y+C*o+A*d}};c.pointLocation=function(d){var r=45/Math.pow(2,t+l-3),o=(d.x-f.x)*r;d=(d.y-f.y)*r;return{lon:q.lon+(E*o-B*d)/m.x,lat:V(W(q.lat)-(B*o+E*d)/m.y)}};var w=s.svg("rect");
-w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(d){if(!arguments.length)return k;k=d;k.setAttribute("class","map");k.appendChild(w);return c.resize()};c.focusableParent=function(){for(var d=k;d;d=d.parentNode)if(d.tabIndex>=0)return d;return window};c.mouse=function(d){var r=(k.ownerSVGElement||k).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var o=document.body.appendChild(s.svg("svg"));o.style.position="absolute";o.style.top=o.style.left=
-"0px";var z=o.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(o)}if($){r.x=d.pageX;r.y=d.pageY}else{r.x=d.clientX;r.y=d.clientY}return r.matrixTransform(k.getScreenCTM().inverse())};c.size=function(d){if(!arguments.length)return a;i=d;return c.resize()};c.resize=function(){if(i){a=i;S.remove(c)}else{w.setAttribute("width","100%");w.setAttribute("height","100%");b=w.getBBox();a={x:b.width,y:b.height};S.add(c)}w.setAttribute("width",a.x);w.setAttribute("height",a.y);f={x:a.x/2,y:a.y/2};g();c.dispatch({type:"resize"});
-return c};c.tileSize=function(d){if(!arguments.length)return m;m=d;c.dispatch({type:"move"});return c};c.center=function(d){if(!arguments.length)return q;q=d;g();c.dispatch({type:"move"});return c};c.panBy=function(d){var r=45/Math.pow(2,t+l-3),o=d.x*r;d=d.y*r;return c.center({lon:q.lon+(B*d-E*o)/m.x,lat:V(W(q.lat)+(B*o+E*d)/m.y)})};c.centerRange=function(d){if(!arguments.length)return n;if(n=d){K=n[0].lat>-90?W(n[0].lat):-Infinity;h=n[0].lat<90?W(n[1].lat):Infinity}else{K=-Infinity;h=Infinity}g();
-c.dispatch({type:"move"});return c};c.zoom=function(d){if(!arguments.length)return t+l;t=d;e();return c.center(q)};c.zoomBy=function(d,r,o){if(arguments.length<2)return c.zoom(t+l+d);if(arguments.length<3)o=c.pointLocation(r);t=t+l+d;e();var z=c.locationPoint(o);return c.panBy({x:r.x-z.x,y:r.y-z.y})};c.zoomRange=function(d){if(!arguments.length)return u;u=d;return c.zoom(t+l)};c.extent=function(d){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var r=c.locationPoint(d[0]),
-o=c.locationPoint(d[1]),z=Math.max((o.x-r.x)/a.x,(r.y-o.y)/a.y);r=c.pointLocation({x:(r.x+o.x)/2,y:(r.y+o.y)/2});t=t+l-Math.log(z)/Math.log(2);e();return c.center(r)};c.angle=function(d){if(!arguments.length)return y;y=d;A=Math.cos(y);C=Math.sin(y);E=Math.cos(-y);B=Math.sin(-y);g();c.dispatch({type:"move"});return c};c.add=function(d){d.map(c);return c};c.remove=function(d){d.map(null);return c};c.dispatch=s.dispatch(c);return c};S.maps=[];S.add=function(e){for(var g=0;g<S.maps.length;g++)if(S.maps[g]==
-e)return;S.maps.push(e)};S.remove=function(e){for(var g=0;g<S.maps.length;g++)if(S.maps[g]==e){S.maps.splice(g,1);return}};window.addEventListener("resize",S,false);s.map.locationCoordinate=function(e){var g=1/360;return{column:(e.lon+180)*g,row:(180-W(e.lat))*g,zoom:0}};s.map.coordinateLocation=function(e){var g=45/Math.pow(2,e.zoom-3);return{lon:g*e.column-180,lat:V(180-g*e.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;s.layer=function(e,g){function c(B){for(var K=C[0].nextSibling;A<B;A++){u.insertBefore(C[-4],
-K);u.insertBefore(C[2],K);u.insertBefore(C[1],K);for(var h=C[-4],n=-4;n<2;)C[n]=C[++n];C[n]=h}}function k(B){for(var K=C[0].nextSibling;A>B;A--){u.insertBefore(C[-1],K);u.insertBefore(C[2],C[-4]);for(var h=C[2],n=2;n>-4;)C[n]=C[--n];C[n]=h}}function i(){function B(O){var H=O.zoom,T=H<0?1:1<<H,U=O.column%T,x=O.row;if(U<0)U+=T;return{locationPoint:function(D){D=s.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:o.x*(G*D.column-U),y:o.y*(G*D.row-x)}}}}function K(O,H,T){var U=I.zoom,x=2-
-R,D=4+R;for(O=O;O<H;O++){var G=f.load({column:O,row:T,zoom:U},B);if(!G.ready&&!(G.key in M)){G.proxyRefs={};for(var J,N,P,Q=1;Q<=x;Q++){N=true;for(var X=0,ea=1<<Q;X<=ea;X++)for(var aa=0;aa<=ea;aa++)if((P=f.peek(J={column:(O<<Q)+aa,row:(T<<Q)+X,zoom:U+Q}))&&P.ready){M[P.key]=f.load(J);P.proxyCount++;G.proxyRefs[P.key]=P}else N=false;if(N)break}if(!N)for(Q=1;Q<=D;Q++)if((P=f.peek(J={column:O>>Q,row:T>>Q,zoom:U-Q}))&&P.ready){M[P.key]=f.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}M[G.key]=G}}
-var h=a.map(),n=h.zoom(),w=n-(n=Math.round(n)),d=h.size(),r=h.angle(),o=h.tileSize(),z=h.locationCoordinate(h.center());if(A!=n){if(A<n)c(n);else if(A>n)k(n);else A=n;for(var v=-4;v<=2;v++){var L=C[v];L.setAttribute("class","zoom"+(v<0?"":"+")+v+" zoom"+(n+v));L.setAttribute("transform","scale("+Math.pow(2,-v)+")")}}u.setAttribute("transform","translate("+d.x/2+","+d.y/2+")"+(r?"rotate("+r/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(y?y.zoomFraction(w):""));var I=h.pointCoordinate(z,Y);
-v=h.pointCoordinate(z,{x:d.x,y:0});n=h.pointCoordinate(z,d);h=h.pointCoordinate(z,{x:0,y:d.y});if(!w&&!r&&!y){z.column=(Math.round(o.x*z.column)+(d.x&1)/2)/o.x;z.row=(Math.round(o.y*z.row)+(d.y&1)/2)/o.y}if(y){I=y.unapply(I);v=y.unapply(v);n=y.unapply(n);h=y.unapply(h);z=y.unapply(z)}var R=t?t(I.zoom)-I.zoom:0;if(R){d=Math.pow(2,R);I.column*=d;I.row*=d;v.column*=d;v.row*=d;n.column*=d;n.row*=d;h.column*=d;h.row*=d;I.zoom=v.zoom=n.zoom=h.zoom+=R}w=f.locks();var M={};for(var F in w)w[F].proxyCount=
-0;if(q&&R>-5&&R<3){r=I.zoom<0?1:1<<I.zoom;if(m){da(I,v,n,0,r,K);da(n,h,I,0,r,K)}else{d=Math.floor((I.column+n.column)/2);r=Math.max(0,Math.min(r-1,Math.floor((v.row+h.row)/2)));v=Math.min(4,I.zoom);d=d>>v<<v;r=r>>v<<v;K(d,d+1,r)}}for(F in M){v=M[F];d=Math.pow(2,v.level=v.zoom-z.zoom);v.element.setAttribute("transform","translate("+(v.x=o.x*(v.column-z.column*d))+","+(v.y=o.y*(v.row-z.row*d))+")")}for(F in w)if(!(F in M)){v=f.unload(F);v.element.parentNode.removeChild(v.element);delete v.proxyRefs}for(F in M){v=
-M[F];if(v.element.parentNode!=C[v.level]){C[v.level].appendChild(v.element);a.show&&a.show(v)}}f.flush();a.dispatch({type:"move"})}var a={},f=a.cache=s.cache(e,g).size(512),m=true,q=true,t,l,j,u=s.svg("g"),y,A,C={};u.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=u.appendChild(s.svg("g"));for(E=2;E>=1;E--)C[E]=u.appendChild(s.svg("g"));C[0]=u.appendChild(s.svg("g"));a.map=function(B){if(!arguments.length)return j;if(j){if(j==B){u.parentNode.appendChild(u);return a}j.off("move",i).off("resize",
-i);u.parentNode.removeChild(u)}if(j=B){j.container().appendChild(u);a.init&&a.init(u);j.on("move",i).on("resize",i);i()}return a};a.container=function(){return u};a.levels=function(){return C};a.id=function(B){if(!arguments.length)return l;l=B;u.setAttribute("id",B);return a};a.visible=function(B){if(!arguments.length)return q;(q=B)?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden");j&&i();return a};a.transform=function(B){if(!arguments.length)return y;y=B;j&&i();return a};a.zoom=
-function(B){if(!arguments.length)return t;t=typeof B=="function"||B==null?B:function(){return B};j&&i();return a};a.tile=function(B){if(!arguments.length)return m;m=B;j&&i();return a};a.reload=function(){f.clear();j&&i();return a};a.dispatch=s.dispatch(a);a.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var h=B.tile.proxyRefs[K];--h.proxyCount<=0&&f.unload(K)&&h.element.parentNode.removeChild(h.element)}delete B.tile.proxyRefs}});return a};s.image=function(){var e=s.layer(function(c){var k=
-c.element=s.svg("image"),i=e.map().tileSize();k.setAttribute("preserveAspectRatio","none");k.setAttribute("width",i.x);k.setAttribute("height",i.y);if(typeof g=="function"){k.setAttribute("opacity",0);c.request=s.queue.image(k,g(c),function(a){delete c.request;c.ready=true;c.img=a;k.removeAttribute("opacity");e.dispatch({type:"load",tile:c})})}else{c.ready=true;g&&k.setAttributeNS(s.ns.xlink,"href",g);e.dispatch({type:"load",tile:c})}},function(c){c.request&&c.request.abort(true)}),g;e.url=function(c){if(!arguments.length)return g;
-g=typeof c=="string"&&/{.}/.test(c)?s.url(c):c;return e.reload()};return e};s.geoJson=function(e){function g(h){var n={lat:0,lon:0};return function(w){n.lat=w[1];n.lon=w[0];var d=h(n);w.x=d.x;w.y=d.y;return d}}function c(h,n){return h&&h.type in C&&C[h.type](h,n)}function k(h,n,w){return h.type in E&&E[h.type](h,n,w)}function i(){var h=a.map().zoom(),n=a.cache.locks(),w,d,r,o,z,v,L;if(y=="fixed")for(w in n){if((d=n[w]).scale!=h){L="scale("+Math.pow(2,d.zoom-h)+")";o=-1;for(z=(r=d.features).length;++o<
-z;)k((v=r[o]).data.geometry,v.element,L);d.scale=h}}else for(w in n){o=-1;for(z=(r=(d=n[w]).features).length;++o<z;)k((v=r[o]).data.geometry,v.element,"");delete d.scale}}var a=s.layer(function(h,n){function w(r){var o=[];if(r.next)h.request=e(r.next.href,w);switch(r.type){case "FeatureCollection":for(var z=0;z<r.features.length;z++){var v=r.features[z],L=c(v.geometry,n);L&&o.push({element:d.appendChild(L),data:v})}break;case "Feature":(L=c(r.geometry,n))&&o.push({element:d.appendChild(L),data:r});
-break;default:(L=c(r,n))&&o.push({element:d.appendChild(L),data:{type:"Feature",geometry:r}});break}h.ready=true;o.push.apply(h.features,o);a.dispatch({type:"load",tile:h,features:o})}var d=h.element=s.svg("g");h.features=[];n=g(n(h).locationPoint);if(m!=null)h.request=e(typeof m=="function"?m(h):m,w);else w({type:"FeatureCollection",features:A||[]})},function(h){h.request&&h.request.abort(true)}),f=a.container(),m,q=true,t="org.polymaps."+s.id(),l="url(#"+t+")",j=f.insertBefore(s.svg("clipPath"),
-f.firstChild),u=j.appendChild(s.svg("rect")),y="auto",A;f.setAttribute("fill-rule","evenodd");j.setAttribute("id",t);if(!arguments.length)e=s.queue.json;var C={Point:function(h,n){var w=n(h.coordinates),d=s.svg("circle");d.setAttribute("r",4.5);d.setAttribute("transform","translate("+w.x+","+w.y+")");return d},MultiPoint:function(h,n){for(var w=s.svg("g"),d=h.coordinates,r,o,z=-1,v=d.length;++z<v;){o=w.appendChild(s.svg("circle"));o.setAttribute("r",4.5);o.setAttribute("transform","translate("+(r=
-n(d[z])).x+","+r.y+")")}return w},LineString:function(h,n){for(var w=s.svg("path"),d=["M"],r=h.coordinates,o,z=-1,v=r.length;++z<v;)d.push((o=n(r[z])).x,",",o.y,"L");d.pop();if(d.length){w.setAttribute("d",d.join(""));return w}},MultiLineString:function(h,n){for(var w=s.svg("path"),d=[],r=h.coordinates,o,z=-1,v,L=r.length,I;++z<L;){o=r[z];v=-1;I=o.length;for(d.push("M");++v<I;)d.push((p=n(o[v])).x,",",p.y,"L");d.pop()}if(d.length){w.setAttribute("d",d.join(""));return w}},Polygon:function(h,n){for(var w=
-s.svg("path"),d=[],r=h.coordinates,o,z=-1,v,L=r.length,I;++z<L;){o=r[z];v=-1;I=o.length-1;for(d.push("M");++v<I;)d.push((p=n(o[v])).x,",",p.y,"L");d[d.length-1]="Z"}if(d.length){w.setAttribute("d",d.join(""));return w}},MultiPolygon:function(h,n){for(var w=s.svg("path"),d=[],r=h.coordinates,o,z,v=-1,L,I,R=r.length,M,F;++v<R;){o=r[v];L=-1;for(M=o.length;++L<M;){z=o[L];I=-1;F=z.length-1;for(d.push("M");++I<F;)d.push((p=n(z[I])).x,",",p.y,"L");d[d.length-1]="Z"}}if(d.length){w.setAttribute("d",d.join(""));
-return w}},GeometryCollection:function(h,n){for(var w=s.svg("g"),d=-1,r=h.geometries,o=r.length,z;++d<o;)(z=c(r[d],n))&&w.appendChild(z);return w}},E={Point:function(h,n,w){h=h.coordinates;n.setAttribute("transform","translate("+h.x+","+h.y+")"+w)},MultiPoint:function(h,n,w){h=h.coordinates;var d=-1,r=o.length;n=n.firstChild;for(var o;++d<r;){o=h[d];n.setAttribute("transform","translate("+o.x+","+o.y+")"+w);n=n.nextSibling}}};a.url=function(h){if(!arguments.length)return m;m=typeof h=="string"&&/{.}/.test(h)?
-s.url(h):h;if(m!=null)A=null;typeof m=="string"&&a.tile(false);return a.reload()};a.features=function(h){if(!arguments.length)return A;if(A=h){m=null;a.tile(false)}return a.reload()};a.clip=function(h){if(!arguments.length)return q;q&&f.removeChild(j);if(q=h)f.insertBefore(j,f.firstChild);var n=a.cache.locks();for(var w in n)q?n[w].element.setAttribute("clip-path",l):n[w].element.removeAttribute("clip-path");return a};var B=a.tile;a.tile=function(h){arguments.length&&!h&&a.clip(h);return B.apply(a,
-arguments)};var K=a.map;a.map=function(h){if(h&&u){var n=h.tileSize();u.setAttribute("width",n.x);u.setAttribute("height",n.y)}return K.apply(a,arguments)};a.scale=function(h){if(!arguments.length)return y;(y=h)?a.on("move",i):a.off("move",i);a.map()&&i();return a};a.show=function(h){q?h.element.setAttribute("clip-path",l):h.element.removeAttribute("clip-path");a.dispatch({type:"show",tile:h,features:h.features});return a};a.reshow=function(){var h=a.cache.locks();for(var n in h)a.show(h[n]);return a};
-return a};s.dblclick=function(){function e(a){var f=k.zoom();f=a.shiftKey?Math.ceil(f)-f-1:1-f+Math.floor(f);c==="mouse"?k.zoomBy(f,k.mouse(a)):k.zoomBy(f)}var g={},c="mouse",k,i;g.zoom=function(a){if(!arguments.length)return c;c=a;return g};g.map=function(a){if(!arguments.length)return k;if(k){i.removeEventListener("dblclick",e,false);i=null}if(k=a){i=k.container();i.addEventListener("dblclick",e,false)}return g};return g};s.drag=function(){function e(f){if(!f.shiftKey){a={x:f.clientX,y:f.clientY};
-k.focusableParent().focus();f.preventDefault();document.body.style.setProperty("cursor","move",null)}}function g(f){if(a){k.panBy({x:f.clientX-a.x,y:f.clientY-a.y});a.x=f.clientX;a.y=f.clientY}}var c={},k,i,a;c.map=function(f){if(!arguments.length)return k;if(k){i.removeEventListener("mousedown",e,false);i=null}if(k=f){i=k.container();i.addEventListener("mousedown",e,false)}return c};window.addEventListener("mousemove",g,false);window.addEventListener("mouseup",function(f){if(a){g(f);a=null;document.body.style.removeProperty("cursor")}},
-false);return c};s.wheel=function(){function e(){m=null}function g(l){var j=(l.wheelDelta/120||-l.detail)*0.1,u;if(ba<0){u=Date.now();var y=u-i;if(y>9&&Math.abs(l.wheelDelta)/y>=50)ba=1;i=u}if(ba==1)j*=0.03;if(!a&&j){u=Date.now();if(u-k>200){j=j>0?+1:-1;k=u}else j=0}if(j)switch(f){case "mouse":u=q.mouse(l);m||(m=q.pointLocation(u));q.off("move",e).zoomBy(j,u,m).on("move",e);break;case "location":q.zoomBy(j,q.locationPoint(m),m);break;default:q.zoomBy(j);break}l.preventDefault();return false}var c=
-{},k=0,i=0,a=true,f="mouse",m,q,t;c.smooth=function(l){if(!arguments.length)return a;a=l;return c};c.zoom=function(l,j){if(!arguments.length)return f;f=l;m=j;if(q)f=="mouse"?q.on("move",e):q.off("move",e);return c};c.map=function(l){if(!arguments.length)return q;if(q){t.removeEventListener("mousemove",e,false);t.removeEventListener("mousewheel",g,false);t.removeEventListener("DOMMouseScroll",g,false);t=null;q.off("move",e)}if(q=l){f=="mouse"&&q.on("move",e);t=q.container();t.addEventListener("mousemove",
-e,false);t.addEventListener("mousewheel",g,false);t.addEventListener("DOMMouseScroll",g,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;s.arrow=function(){function e(y){if(!(y.ctrlKey||y.altKey||y.metaKey)){var A=Date.now(),C=0,E=0;switch(y.keyCode){case 37:if(!a.left){f=A;a.left=1;a.right||(C=l)}break;case 39:if(!a.right){f=A;a.right=1;a.left||(C=-l)}break;case 38:if(!a.up){f=A;a.up=1;a.down||(E=l)}break;case 40:if(!a.down){f=A;a.down=1;a.up||(E=-l)}break;default:return}if(C||
-E)j.panBy({x:C,y:E});if(!m&&a.left|a.right|a.up|a.down)m=setInterval(k,t);y.preventDefault()}}function g(y){f=Date.now();switch(y.keyCode){case 37:a.left=0;break;case 39:a.right=0;break;case 38:a.up=0;break;case 40:a.down=0;break;default:return}if(m&&!(a.left|a.right|a.up|a.down))m=clearInterval(m);y.preventDefault()}function c(y){switch(y.charCode){case 45:case 95:j.zoom(Math.ceil(j.zoom())-1);break;case 43:case 61:j.zoom(Math.floor(j.zoom())+1);break;default:return}y.preventDefault()}function k(){if(j)if(!(Date.now()<
-f+q)){var y=(a.left-a.right)*l,A=(a.up-a.down)*l;if(y||A)j.panBy({x:y,y:A})}}var i={},a={left:0,right:0,up:0,down:0},f=0,m,q=250,t=50,l=16,j,u;i.map=function(y){if(!arguments.length)return j;if(j){u.removeEventListener("keypress",c,false);u.removeEventListener("keydown",e,false);u.removeEventListener("keyup",g,false);u=null}if(j=y){u=j.focusableParent();u.addEventListener("keypress",c,false);u.addEventListener("keydown",e,false);u.addEventListener("keyup",g,false)}return i};i.speed=function(y){if(!arguments.length)return l;
-l=y;return i};return i};s.hash=function(){function e(){var f=a.center(),m=a.zoom(),q=Math.max(0,Math.ceil(Math.log(m)/Math.LN2));f="#"+m.toFixed(2)+"/"+f.lat.toFixed(q)+"/"+f.lon.toFixed(q);if(k!==f)location.replace(k=f)}function g(){if(location.hash!==k){var f=(k=location.hash).substring(1).split("/").map(Number);if(f.length<3||f.some(isNaN))e();else{var m=a.size();a.zoomBy(f[0]-a.zoom(),{x:m.x/2,y:m.y/2},{lat:Math.min(i,Math.max(-i,f[1])),lon:f[2]})}}}var c={},k,i=89.99999999,a;c.map=function(f){if(!arguments.length)return a;
-if(a){a.off("move",e);window.removeEventListener("hashchange",g,false)}if(a=f){a.on("move",e);window.addEventListener("hashchange",g,false);location.hash?g():e()}return c};return c};s.interact=function(){var e={},g=s.drag(),c=s.wheel(),k=s.dblclick(),i=s.arrow();e.map=function(a){g.map(a);c.map(a);k.map(a);i.map(a);return e};return e};s.compass=function(){function e(x){B.setAttribute("class","compass active");I||(I=setInterval(g,r));R&&H.panBy(R);w=Date.now();return l(x)}function g(){R&&Date.now()>
-w+d&&H.panBy(R)}function c(x){if(x.shiftKey){F={x0:H.mouse(x)};H.focusableParent().focus();return l(x)}}function k(x){if(F){F.x1=H.mouse(x);O.setAttribute("x",Math.min(F.x0.x,F.x1.x));O.setAttribute("y",Math.min(F.x0.y,F.x1.y));O.setAttribute("width",Math.abs(F.x0.x-F.x1.x));O.setAttribute("height",Math.abs(F.x0.y-F.x1.y));O.removeAttribute("display")}}function i(){B.setAttribute("class","compass");if(F){if(F.x1){H.extent([H.pointLocation({x:Math.min(F.x0.x,F.x1.x),y:Math.max(F.x0.y,F.x1.y)}),H.pointLocation({x:Math.max(F.x0.x,
-F.x1.x),y:Math.min(F.x0.y,F.x1.y)})]);O.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function a(x){return function(){x?this.setAttribute("class","active"):this.removeAttribute("class");R=x}}function f(x){return function(D){B.setAttribute("class","compass active");var G=H.zoom();H.zoom(x<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function m(x){return function(D){H.zoom(x);return l(D)}}function q(){this.setAttribute("class","active")}function t(){this.removeAttribute("class")}
-function l(x){x.stopPropagation();x.preventDefault();return false}function j(x){var D=Math.SQRT1_2*h,G=h*0.7,J=h*0.2,N=s.svg("g"),P=N.appendChild(s.svg("path")),Q=N.appendChild(s.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d","M0,0L"+D+","+D+"A"+h+","+h+" 0 0,1 "+-D+","+D+"Z");Q.setAttribute("class","chevron");Q.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));Q.setAttribute("pointer-events","none");N.addEventListener("mousedown",
-e,false);N.addEventListener("mouseover",a(x),false);N.addEventListener("mouseout",a(null),false);N.addEventListener("dblclick",l,false);return N}function u(x){var D=h*0.4,G=D/2,J=s.svg("g"),N=J.appendChild(s.svg("path")),P=J.appendChild(s.svg("path")),Q=J.appendChild(s.svg("path")),X=J.appendChild(s.svg("path"));N.setAttribute("class","back");N.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",N.getAttribute("d"));Q.setAttribute("class",
-"chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(x>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",N.getAttribute("d"));J.addEventListener("mousedown",f(x),false);J.addEventListener("mouseover",q,false);J.addEventListener("mouseout",t,false);J.addEventListener("dblclick",l,false);return J}function y(x){var D=h*0.2,G=h*0.4,J=s.svg("g"),N=J.appendChild(s.svg("rect")),P=J.appendChild(s.svg("path"));N.setAttribute("pointer-events","all");N.setAttribute("fill",
-"none");N.setAttribute("x",-G);N.setAttribute("y",-0.75*G);N.setAttribute("width",2*G);N.setAttribute("height",1.5*G);P.setAttribute("class","chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",m(x),false);J.addEventListener("dblclick",l,false);return J}function A(){var x=h+6,D=x,G=H.size();switch(o){case "top-left":break;case "top-right":x=G.x-x;break;case "bottom-left":D=G.y-D;break;case "bottom-right":x=G.x-x;D=G.y-D;break}x="translate("+x+","+D+")";M&&M.setAttribute("transform",
-x);v&&v.setAttribute("transform",x);for(var J in K)J==H.zoom()?K[J].setAttribute("class","active"):K[J].removeAttribute("class")}function C(){for(;B.lastChild;)B.removeChild(B.lastChild);B.appendChild(O);if(L!="none"){M=B.appendChild(s.svg("g"));M.setAttribute("class","pan");var x=M.appendChild(s.svg("circle"));x.setAttribute("class","back");x.setAttribute("r",h);M.appendChild(j({x:0,y:-n})).setAttribute("transform","rotate(0)");M.appendChild(j({x:n,y:0})).setAttribute("transform","rotate(90)");M.appendChild(j({x:0,
-y:n})).setAttribute("transform","rotate(180)");M.appendChild(j({x:-n,y:0})).setAttribute("transform","rotate(270)");x=M.appendChild(s.svg("circle"));x.setAttribute("fill","none");x.setAttribute("class","fore");x.setAttribute("r",h)}else M=null;if(z!="none"){v=B.appendChild(s.svg("g"));v.setAttribute("class","zoom");x=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(x=0;D<=H.zoomRange()[1];D++,x++)(K[D]=v.appendChild(y(D))).setAttribute("transform","translate(0,"+-(x+0.75)*h*0.4+")")}D=L=="none"?
-0.4:2;v.setAttribute("transform","translate(0,"+h*(/^top-/.test(o)?D+(x+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(x+0.5)*h*0.4+")");v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E={},B=s.svg("g"),K={},h=30,n=16,w=0,d=250,r=50,o="top-left",z="small",v,L="small",I,R,M,F,O=s.svg("rect"),H,T,U;B.setAttribute("class","compass");O.setAttribute("class","back fore");O.setAttribute("pointer-events","none");O.setAttribute("display","none");
-E.radius=function(x){if(!arguments.length)return h;h=x;H&&C();return E};E.speed=function(x){if(!arguments.length)return h;n=x;return E};E.position=function(x){if(!arguments.length)return o;o=x;H&&C();return E};E.pan=function(x){if(!arguments.length)return L;L=x;H&&C();return E};E.zoom=function(x){if(!arguments.length)return z;z=x;H&&C();return E};E.map=function(x){if(!arguments.length)return H;if(H){T.removeEventListener("mousedown",c,false);T.removeChild(B);T=null;U.removeEventListener("mousemove",
-k,false);U.removeEventListener("mouseup",i,false);U=null;H.off("move",A).off("resize",A)}if(H=x){T=H.container();T.appendChild(B);T.addEventListener("mousedown",c,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",k,false);U.addEventListener("mouseup",i,false);H.on("move",A).on("resize",A);C()}return E};return E};s.grid=function(){function e(){var i=k.firstChild,a=c.size(),f=c.pointLocation(Y);c.pointLocation(a);var m=Math.pow(2,4-Math.round(c.zoom()));f.lat=Math.floor(f.lat/m)*m;
-f.lon=Math.ceil(f.lon/m)*m;for(var q;(q=c.locationPoint(f).x)<=a.x;f.lon+=m){i||(i=k.appendChild(s.svg("line")));i.setAttribute("x1",q);i.setAttribute("x2",q);i.setAttribute("y1",0);i.setAttribute("y2",a.y);i=i.nextSibling}for(;(q=c.locationPoint(f).y)<=a.y;f.lat-=m){i||(i=k.appendChild(s.svg("line")));i.setAttribute("y1",q);i.setAttribute("y2",q);i.setAttribute("x1",0);i.setAttribute("x2",a.x);i=i.nextSibling}for(;i;){a=i.nextSibling;k.removeChild(i);i=a}}var g={},c,k=s.svg("g");k.setAttribute("class",
-"grid");g.map=function(i){if(!arguments.length)return c;if(c){k.parentNode.removeChild(k);c.off("move",e).off("resize",e)}if(c=i){c.on("move",e).on("resize",e);c.container().appendChild(k);c.dispatch({type:"move"})}return g};return g};s.stylist=function(){function e(i){var a=i.features.length,f=g.length,m=c.length,q,t,l,j,u,y;for(u=0;u<a;++u)if(t=(q=i.features[u]).element){q=q.data;for(y=0;y<f;++y){j=(l=g[y]).value;if(typeof j==="function")j=j.call(null,q);j==null?l.name.local?t.removeAttributeNS(l.name.space,
-l.name.local):t.removeAttribute(l.name):l.name.local?t.setAttributeNS(l.name.space,l.name.local,j):t.setAttribute(l.name,j)}for(y=0;y<m;++y){j=(l=c[y]).value;if(typeof j==="function")j=j.call(null,q);j==null?t.style.removeProperty(l.name):t.style.setProperty(l.name,j,l.priority)}if(j=k){if(typeof j==="function")j=j.call(null,q);for(;t.lastChild;)t.removeChild(t.lastChild);j!=null&&t.appendChild(s.svg("title")).appendChild(document.createTextNode(j))}}}var g=[],c=[],k;e.attr=function(i,a){g.push({name:fa(i),
-value:a});return e};e.style=function(i,a,f){c.push({name:i,value:a,priority:arguments.length<3?null:f});return e};e.title=function(i){k=i;return e};return e}})(org.polymaps);
+(function(t){function fa(d){var h=d.indexOf(":");return h<0?d:{space:t.ns[d.substring(0,h)],local:d.substring(h+1)}}function S(){for(var d=0;d<S.maps.length;d++)S.maps[d].resize()}function V(d){return 360/Math.PI*Math.atan(Math.exp(d*Math.PI/180))-90}function W(d){return 180/Math.PI*Math.log(Math.tan(Math.PI/4+d*Math.PI/360))}function Z(d,h){if(d.row>h.row){var c=d;d=h;h=c}return{x0:d.column,y0:d.row,x1:h.column,y1:h.row,dx:h.column-d.column,dy:h.row-d.row}}function ca(d,h,c,m,f){c=Math.max(c,Math.floor(h.y0));
+m=Math.min(m,Math.ceil(h.y1));if(d.x0==h.x0&&d.y0==h.y0?d.x0+h.dy/d.dy*d.dx<h.x1:d.x1-h.dy/d.dy*d.dx<h.x0){var a=d;d=h;h=a}a=d.dx/d.dy;var g=h.dx/h.dy,k=d.dx>0,o=h.dx<0;for(c=c;c<m;c++){var q=a*Math.max(0,Math.min(d.dy,c+k-d.y0))+d.x0;f(Math.floor(g*Math.max(0,Math.min(h.dy,c+o-h.y0))+h.x0),Math.ceil(q),c)}}function da(d,h,c,m,f,a){var g=Z(d,h);h=Z(h,c);d=Z(c,d);if(g.dy>h.dy){c=g;g=h;h=c}if(g.dy>d.dy){c=g;g=d;d=c}if(h.dy>d.dy){c=h;h=d;d=c}g.dy&&ca(d,g,m,f,a);h.dy&&ca(d,h,m,f,a)}t.version="2.4.0+1";
+var Y={x:0,y:0};t.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};t.id=function(){var d=0;return function(){return++d}}();t.svg=function(d){return document.createElementNS(t.ns.svg,d)};t.transform=function(d,h,c,m,f,a){var g={},k,o,q;if(!arguments.length){d=1;h=f=c=0;m=1;a=0}g.zoomFraction=function(l){if(!arguments.length)return o;o=l;k=Math.floor(o+Math.log(Math.sqrt(d*d+h*h+c*c+m*m))/Math.log(2));q=Math.pow(2,-k);return g};g.apply=function(l){var i=Math.pow(2,-l.zoom),
+u=Math.pow(2,l.zoom-k);return{column:(d*l.column*i+c*l.row*i+f)*u,row:(h*l.column*i+m*l.row*i+a)*u,zoom:l.zoom-k}};g.unapply=function(l){var i=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+k);return{column:(l.column*i*m-l.row*i*c-f*m+a*c)/(d*m-h*c)*u,row:(l.column*i*h-l.row*i*d-f*h+a*d)/(c*h-m*d)*u,zoom:l.zoom+k}};g.toString=function(){return"matrix("+[d*q,h*q,c*q,m*q].join(" ")+" 0 0)"};return g.zoomFraction(0)};t.cache=function(d,h){function c(i){l--;h&&h(i);delete g[i.key];if(i.next)i.next.prev=i.prev;
+else if(o=i.prev)o.next=null;if(i.prev)i.prev.next=i.next;else if(k=i.next)k.prev=null}function m(){for(var i=o;l>q;i=i.prev){if(!i)break;i.lock||c(i)}}var f={},a={},g={},k=null,o=null,q=64,l=0;f.peek=function(i){return g[[i.zoom,i.column,i.row].join("/")]};f.load=function(i,u){var x=[i.zoom,i.column,i.row].join("/"),A=g[x];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else o=A.prev;A.prev=null;A.next=k;k=k.prev=A}A.lock=1;return a[x]=A}A={key:x,column:i.column,row:i.row,zoom:i.zoom,next:k,
+prev:null,lock:1};d.call(null,A,u);a[x]=g[x]=A;if(k)k.prev=A;else o=A;k=A;l++;return A};f.unload=function(i){if(!(i in a))return false;var u=a[i];u.lock=0;delete a[i];u.request&&u.request.abort(false)&&c(u);return u};f.locks=function(){return a};f.size=function(i){if(!arguments.length)return q;q=i;m();return f};f.flush=function(){m();return f};f.clear=function(){for(var i in g){var u=g[i];u.request&&u.request.abort(false);h&&h(g[i]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
+{};g={};k=o=null;l=0;return f};return f};t.url=function(d){function h(f){var a=f.zoom<0?1:1<<f.zoom,g=f.column;if(m){g=f.column%a;if(g<0)g+=a}else if(g<0||g>=a)return null;return d.replace(/{(.)}/g,function(k,o){switch(o){case "S":return c[(Math.abs(f.zoom)+f.row+g)%c.length];case "Z":return f.zoom;case "X":return g;case "Y":return f.row;case "B":var q=t.map.coordinateLocation({row:f.row,column:g,zoom:f.zoom}),l=t.map.coordinateLocation({row:f.row+1,column:g+1,zoom:f.zoom}),i=Math.ceil(Math.log(f.zoom)/
+Math.LN2);return l.lat.toFixed(i)+","+q.lon.toFixed(i)+","+q.lat.toFixed(i)+","+l.lon.toFixed(i)}return o})}var c=[],m=true;h.template=function(f){if(!arguments.length)return d;d=f;return h};h.hosts=function(f){if(!arguments.length)return c;c=f;return h};h.repeat=function(f){if(!arguments.length)return m;m=f;return h};return h};t.dispatch=function(d){var h={};d.on=function(c,m){for(var f=h[c]||(h[c]=[]),a=0;a<f.length;a++)if(f[a].handler==m)return d;f.push({handler:m,on:true});return d};d.off=function(c,
+m){var f=h[c];if(f)for(var a=0;a<f.length;a++){var g=f[a];if(g.handler==m){g.on=false;f.splice(a,1);break}}return d};return function(c){var m=h[c.type];if(m){m=m.slice();for(var f=0;f<m.length;f++){var a=m[f];a.on&&a.handler.call(d,c)}}}};t.queue=function(){function d(){if(!(f>=a||!m.length)){f++;m.pop()()}}function h(g){for(var k=0;k<m.length;k++)if(m[k]==g){m.splice(k,1);return true}return false}function c(g,k,o){function q(){l=new XMLHttpRequest;o&&l.overrideMimeType(o);l.open("GET",g,true);l.onreadystatechange=
+function(){if(l.readyState==4){f--;l.status<300&&k(l);d()}};l.send(null)}var l;m.push(q);d();return{abort:function(i){if(h(q))return true;if(i&&l){l.abort();return true}return false}}}var m=[],f=0,a=6;return{text:function(g,k,o){return c(g,function(q){q.responseText&&k(q.responseText)},o)},xml:function(g,k){return c(g,function(o){o.responseXML&&k(o.responseXML)},"application/xml")},json:function(g,k){return c(g,function(o){o.responseText&&k(JSON.parse(o.responseText))},"application/json")},image:function(g,
+k,o){function q(){l=document.createElement("img");l.onerror=function(){f--;d()};l.onload=function(){f--;o(l);d()};l.src=k;g.setAttributeNS(t.ns.xlink,"href",k)}var l;m.push(q);d();return{abort:function(i){if(h(q))return true;if(i&&l){l.src="about:";return true}return false}}}}}();t.map=function(){function d(){if(u)if(q<u[0])q=u[0];else if(q>u[1])q=u[1];l=q-(q=Math.round(q));i=Math.pow(2,l)}function h(){if(n){var e=45/Math.pow(2,q+l-3),s=Math.max(Math.abs(C*g.x+A*g.y),Math.abs(B*g.x+E*g.y)),r=V(K-
+s*e/k.y);s=V(j+s*e/k.y);o.lat=Math.max(r,Math.min(s,o.lat));r=Math.max(Math.abs(C*g.y+A*g.x),Math.abs(B*g.y+E*g.x));o.lon=Math.max(n[0].lon-r*e/k.x,Math.min(n[1].lon+r*e/k.x,o.lon))}}var c={},m,f,a=Y,g=Y,k={x:256,y:256},o={lat:37.76487,lon:-122.41948},q=12,l=0,i=1,u=[1,18],x=0,A=1,C=0,E=1,B=0,K=-180,j=180,n=[{lat:V(K),lon:-Infinity},{lat:V(j),lon:Infinity}];c.locationCoordinate=function(e){e=t.map.locationCoordinate(e);var s=Math.pow(2,q);e.column*=s;e.row*=s;e.zoom+=q;return e};c.coordinateLocation=
+t.map.coordinateLocation;c.coordinatePoint=function(e,s){var r=Math.pow(2,q-s.zoom),z=Math.pow(2,q-e.zoom),v=(s.column*r-e.column*z)*k.x*i;r=(s.row*r-e.row*z)*k.y*i;return{x:g.x+A*v-C*r,y:g.y+C*v+A*r}};c.pointCoordinate=function(e,s){var r=Math.pow(2,q-e.zoom),z=(s.x-g.x)/i,v=(s.y-g.y)/i;return{column:e.column*r+(E*z-B*v)/k.x,row:e.row*r+(B*z+E*v)/k.y,zoom:q}};c.locationPoint=function(e){var s=Math.pow(2,q+l-3)/45,r=(e.lon-o.lon)*s*k.x;e=(W(o.lat)-W(e.lat))*s*k.y;return{x:g.x+A*r-C*e,y:g.y+C*r+A*
+e}};c.pointLocation=function(e){var s=45/Math.pow(2,q+l-3),r=(e.x-g.x)*s;e=(e.y-g.y)*s;return{lon:o.lon+(E*r-B*e)/k.x,lat:V(W(o.lat)-(B*r+E*e)/k.y)}};var w=t.svg("rect");w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(e){if(!arguments.length)return m;m=e;m.setAttribute("class","map");m.appendChild(w);return c.resize()};c.focusableParent=function(){for(var e=m;e;e=e.parentNode)if(e.tabIndex>=0)return e;return window};c.mouse=function(e){var s=(m.ownerSVGElement||
+m).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var r=document.body.appendChild(t.svg("svg"));r.style.position="absolute";r.style.top=r.style.left="0px";var z=r.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(r)}if($){s.x=e.pageX;s.y=e.pageY}else{s.x=e.clientX;s.y=e.clientY}return s.matrixTransform(m.getScreenCTM().inverse())};c.size=function(e){if(!arguments.length)return a;f=e;return c.resize()};c.resize=function(){if(f){a=f;S.remove(c)}else{w.setAttribute("width","100%");w.setAttribute("height",
+"100%");b=w.getBBox();a={x:b.width,y:b.height};S.add(c)}w.setAttribute("width",a.x);w.setAttribute("height",a.y);g={x:a.x/2,y:a.y/2};h();c.dispatch({type:"resize"});return c};c.tileSize=function(e){if(!arguments.length)return k;k=e;c.dispatch({type:"move"});return c};c.center=function(e){if(!arguments.length)return o;o=e;h();c.dispatch({type:"move"});return c};c.panBy=function(e){var s=45/Math.pow(2,q+l-3),r=e.x*s;e=e.y*s;return c.center({lon:o.lon+(B*e-E*r)/k.x,lat:V(W(o.lat)+(B*r+E*e)/k.y)})};c.centerRange=
+function(e){if(!arguments.length)return n;if(n=e){K=n[0].lat>-90?W(n[0].lat):-Infinity;j=n[0].lat<90?W(n[1].lat):Infinity}else{K=-Infinity;j=Infinity}h();c.dispatch({type:"move"});return c};c.zoom=function(e){if(!arguments.length)return q+l;q=e;d();return c.center(o)};c.zoomBy=function(e,s,r){if(arguments.length<2)return c.zoom(q+l+e);if(arguments.length<3)r=c.pointLocation(s);q=q+l+e;d();var z=c.locationPoint(r);return c.panBy({x:s.x-z.x,y:s.y-z.y})};c.zoomRange=function(e){if(!arguments.length)return u;
+u=e;return c.zoom(q+l)};c.extent=function(e){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var s=c.locationPoint(e[0]),r=c.locationPoint(e[1]),z=Math.max((r.x-s.x)/a.x,(s.y-r.y)/a.y);s=c.pointLocation({x:(s.x+r.x)/2,y:(s.y+r.y)/2});q=q+l-Math.log(z)/Math.log(2);d();return c.center(s)};c.angle=function(e){if(!arguments.length)return x;x=e;A=Math.cos(x);C=Math.sin(x);E=Math.cos(-x);B=Math.sin(-x);h();c.dispatch({type:"move"});return c};c.add=function(e){e.map(c);
+return c};c.remove=function(e){e.map(null);return c};c.dispatch=t.dispatch(c);return c};S.maps=[];S.add=function(d){for(var h=0;h<S.maps.length;h++)if(S.maps[h]==d)return;S.maps.push(d)};S.remove=function(d){for(var h=0;h<S.maps.length;h++)if(S.maps[h]==d){S.maps.splice(h,1);return}};window.addEventListener("resize",S,false);t.map.locationCoordinate=function(d){var h=1/360;return{column:(d.lon+180)*h,row:(180-W(d.lat))*h,zoom:0}};t.map.coordinateLocation=function(d){var h=45/Math.pow(2,d.zoom-3);
+return{lon:h*d.column-180,lat:V(180-h*d.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;t.layer=function(d,h){function c(B){for(var K=C[0].nextSibling;A<B;A++){u.insertBefore(C[-4],K);u.insertBefore(C[2],K);u.insertBefore(C[1],K);for(var j=C[-4],n=-4;n<2;)C[n]=C[++n];C[n]=j}}function m(B){for(var K=C[0].nextSibling;A>B;A--){u.insertBefore(C[-1],K);u.insertBefore(C[2],C[-4]);for(var j=C[2],n=2;n>-4;)C[n]=C[--n];C[n]=j}}function f(){function B(N){var H=N.zoom,T=H<0?1:1<<H,U=N.column%T,y=N.row;
+if(U<0)U+=T;return{locationPoint:function(D){D=t.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:r.x*(G*D.column-U),y:r.y*(G*D.row-y)}}}}function K(N,H,T){var U=I.zoom,y=2-R,D=4+R;for(N=N;N<H;N++){var G=g.load({column:N,row:T,zoom:U},B);if(!G.ready&&!(G.key in O)){G.proxyRefs={};for(var J,M,P,Q=1;Q<=y;Q++){M=true;for(var X=0,ea=1<<Q;X<=ea;X++)for(var aa=0;aa<=ea;aa++)if((P=g.peek(J={column:(N<<Q)+aa,row:(T<<Q)+X,zoom:U+Q}))&&P.ready){O[P.key]=g.load(J);P.proxyCount++;G.proxyRefs[P.key]=
+P}else M=false;if(M)break}if(!M)for(Q=1;Q<=D;Q++)if((P=g.peek(J={column:N>>Q,row:T>>Q,zoom:U-Q}))&&P.ready){O[P.key]=g.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}O[G.key]=G}}var j=a.map(),n=j.zoom(),w=n-(n=Math.round(n)),e=j.size(),s=j.angle(),r=j.tileSize(),z=j.locationCoordinate(j.center());if(A!=n){if(A<n)c(n);else if(A>n)m(n);else A=n;for(var v=-4;v<=2;v++){var L=C[v];L.setAttribute("class","zoom"+(v<0?"":"+")+v+" zoom"+(n+v));L.setAttribute("transform","scale("+Math.pow(2,-v)+")")}}u.setAttribute("transform",
+"translate("+e.x/2+","+e.y/2+")"+(s?"rotate("+s/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(x?x.zoomFraction(w):""));var I=j.pointCoordinate(z,Y);v=j.pointCoordinate(z,{x:e.x,y:0});n=j.pointCoordinate(z,e);j=j.pointCoordinate(z,{x:0,y:e.y});if(!w&&!s&&!x){z.column=(Math.round(r.x*z.column)+(e.x&1)/2)/r.x;z.row=(Math.round(r.y*z.row)+(e.y&1)/2)/r.y}if(x){I=x.unapply(I);v=x.unapply(v);n=x.unapply(n);j=x.unapply(j);z=x.unapply(z)}var R=q?q(I.zoom)-I.zoom:0;if(R){e=Math.pow(2,R);I.column*=
+e;I.row*=e;v.column*=e;v.row*=e;n.column*=e;n.row*=e;j.column*=e;j.row*=e;I.zoom=v.zoom=n.zoom=j.zoom+=R}w=g.locks();var O={};for(var F in w)w[F].proxyCount=0;if(o&&R>-5&&R<3){s=I.zoom<0?1:1<<I.zoom;if(k){da(I,v,n,0,s,K);da(n,j,I,0,s,K)}else{e=Math.floor((I.column+n.column)/2);s=Math.max(0,Math.min(s-1,Math.floor((v.row+j.row)/2)));v=Math.min(4,I.zoom);e=e>>v<<v;s=s>>v<<v;K(e,e+1,s)}}for(F in O){v=O[F];e=Math.pow(2,v.level=v.zoom-z.zoom);v.element.setAttribute("transform","translate("+(v.x=r.x*(v.column-
+z.column*e))+","+(v.y=r.y*(v.row-z.row*e))+")")}for(F in w)if(!(F in O)){v=g.unload(F);v.element.parentNode.removeChild(v.element);delete v.proxyRefs}for(F in O){v=O[F];if(v.element.parentNode!=C[v.level]){C[v.level].appendChild(v.element);a.show&&a.show(v)}}g.flush();a.dispatch({type:"move"})}var a={},g=a.cache=t.cache(d,h).size(512),k=true,o=true,q,l,i,u=t.svg("g"),x,A,C={};u.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=u.appendChild(t.svg("g"));for(E=2;E>=1;E--)C[E]=u.appendChild(t.svg("g"));
+C[0]=u.appendChild(t.svg("g"));a.map=function(B){if(!arguments.length)return i;if(i){if(i==B){u.parentNode.appendChild(u);return a}i.off("move",f).off("resize",f);u.parentNode.removeChild(u)}if(i=B){i.container().appendChild(u);a.init&&a.init(u);i.on("move",f).on("resize",f);f()}return a};a.container=function(){return u};a.levels=function(){return C};a.id=function(B){if(!arguments.length)return l;l=B;u.setAttribute("id",B);return a};a.visible=function(B){if(!arguments.length)return o;(o=B)?u.removeAttribute("visibility"):
+u.setAttribute("visibility","hidden");i&&f();return a};a.transform=function(B){if(!arguments.length)return x;x=B;i&&f();return a};a.zoom=function(B){if(!arguments.length)return q;q=typeof B=="function"||B==null?B:function(){return B};i&&f();return a};a.tile=function(B){if(!arguments.length)return k;k=B;i&&f();return a};a.reload=function(){g.clear();i&&f();return a};a.dispatch=t.dispatch(a);a.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var j=B.tile.proxyRefs[K];--j.proxyCount<=
+0&&g.unload(K)&&j.element.parentNode.removeChild(j.element)}delete B.tile.proxyRefs}});return a};t.image=function(){var d=t.layer(function(c){var m=c.element=t.svg("image"),f=d.map().tileSize();m.setAttribute("preserveAspectRatio","none");m.setAttribute("width",f.x);m.setAttribute("height",f.y);if(typeof h=="function"){m.setAttribute("opacity",0);f=h(c);if(f!=null)c.request=t.queue.image(m,f,function(a){delete c.request;c.ready=true;c.img=a;m.removeAttribute("opacity");d.dispatch({type:"load",tile:c})});
+else{c.ready=true;d.dispatch({type:"load",tile:c})}}else{c.ready=true;h!=null&&m.setAttributeNS(t.ns.xlink,"href",h);d.dispatch({type:"load",tile:c})}},function(c){c.request&&c.request.abort(true)}),h;d.url=function(c){if(!arguments.length)return h;h=typeof c=="string"&&/{.}/.test(c)?t.url(c):c;return d.reload()};return d};t.geoJson=function(d){function h(j){var n={lat:0,lon:0};return function(w){n.lat=w[1];n.lon=w[0];var e=j(n);w.x=e.x;w.y=e.y;return e}}function c(j,n){return j&&j.type in C&&C[j.type](j,
+n)}function m(j,n,w){return j.type in E&&E[j.type](j,n,w)}function f(){var j=a.map().zoom(),n=a.cache.locks(),w,e,s,r,z,v,L;if(x=="fixed")for(w in n){if((e=n[w]).scale!=j){L="scale("+Math.pow(2,e.zoom-j)+")";r=-1;for(z=(s=e.features).length;++r<z;)m((v=s[r]).data.geometry,v.element,L);e.scale=j}}else for(w in n){r=-1;for(z=(s=(e=n[w]).features).length;++r<z;)m((v=s[r]).data.geometry,v.element,"");delete e.scale}}var a=t.layer(function(j,n){function w(s){var r=[];if(s.next)j.request=d(s.next.href,
+w);switch(s.type){case "FeatureCollection":for(var z=0;z<s.features.length;z++){var v=s.features[z],L=c(v.geometry,n);L&&r.push({element:e.appendChild(L),data:v})}break;case "Feature":(L=c(s.geometry,n))&&r.push({element:e.appendChild(L),data:s});break;default:(L=c(s,n))&&r.push({element:e.appendChild(L),data:{type:"Feature",geometry:s}});break}j.ready=true;r.push.apply(j.features,r);a.dispatch({type:"load",tile:j,features:r})}var e=j.element=t.svg("g");j.features=[];n=h(n(j).locationPoint);if(k!=
+null)j.request=d(typeof k=="function"?k(j):k,w);else w({type:"FeatureCollection",features:A||[]})},function(j){j.request&&j.request.abort(true)}),g=a.container(),k,o=true,q="org.polymaps."+t.id(),l="url(#"+q+")",i=g.insertBefore(t.svg("clipPath"),g.firstChild),u=i.appendChild(t.svg("rect")),x="auto",A;g.setAttribute("fill-rule","evenodd");i.setAttribute("id",q);if(!arguments.length)d=t.queue.json;var C={Point:function(j,n){var w=n(j.coordinates),e=t.svg("circle");e.setAttribute("r",4.5);e.setAttribute("transform",
+"translate("+w.x+","+w.y+")");return e},MultiPoint:function(j,n){for(var w=t.svg("g"),e=j.coordinates,s,r,z=-1,v=e.length;++z<v;){r=w.appendChild(t.svg("circle"));r.setAttribute("r",4.5);r.setAttribute("transform","translate("+(s=n(e[z])).x+","+s.y+")")}return w},LineString:function(j,n){for(var w=t.svg("path"),e=["M"],s=j.coordinates,r,z=-1,v=s.length;++z<v;)e.push((r=n(s[z])).x,",",r.y,"L");e.pop();if(e.length){w.setAttribute("d",e.join(""));return w}},MultiLineString:function(j,n){for(var w=t.svg("path"),
+e=[],s=j.coordinates,r,z=-1,v,L=s.length,I;++z<L;){r=s[z];v=-1;I=r.length;for(e.push("M");++v<I;)e.push((p=n(r[v])).x,",",p.y,"L");e.pop()}if(e.length){w.setAttribute("d",e.join(""));return w}},Polygon:function(j,n){for(var w=t.svg("path"),e=[],s=j.coordinates,r,z=-1,v,L=s.length,I;++z<L;){r=s[z];v=-1;I=r.length-1;for(e.push("M");++v<I;)e.push((p=n(r[v])).x,",",p.y,"L");e[e.length-1]="Z"}if(e.length){w.setAttribute("d",e.join(""));return w}},MultiPolygon:function(j,n){for(var w=t.svg("path"),e=[],
+s=j.coordinates,r,z,v=-1,L,I,R=s.length,O,F;++v<R;){r=s[v];L=-1;for(O=r.length;++L<O;){z=r[L];I=-1;F=z.length-1;for(e.push("M");++I<F;)e.push((p=n(z[I])).x,",",p.y,"L");e[e.length-1]="Z"}}if(e.length){w.setAttribute("d",e.join(""));return w}},GeometryCollection:function(j,n){for(var w=t.svg("g"),e=-1,s=j.geometries,r=s.length,z;++e<r;)(z=c(s[e],n))&&w.appendChild(z);return w}},E={Point:function(j,n,w){j=j.coordinates;n.setAttribute("transform","translate("+j.x+","+j.y+")"+w)},MultiPoint:function(j,
+n,w){j=j.coordinates;var e=-1,s=r.length;n=n.firstChild;for(var r;++e<s;){r=j[e];n.setAttribute("transform","translate("+r.x+","+r.y+")"+w);n=n.nextSibling}}};a.url=function(j){if(!arguments.length)return k;k=typeof j=="string"&&/{.}/.test(j)?t.url(j):j;if(k!=null)A=null;typeof k=="string"&&a.tile(false);return a.reload()};a.features=function(j){if(!arguments.length)return A;if(A=j){k=null;a.tile(false)}return a.reload()};a.clip=function(j){if(!arguments.length)return o;o&&g.removeChild(i);if(o=j)g.insertBefore(i,
+g.firstChild);var n=a.cache.locks();for(var w in n)o?n[w].element.setAttribute("clip-path",l):n[w].element.removeAttribute("clip-path");return a};var B=a.tile;a.tile=function(j){arguments.length&&!j&&a.clip(j);return B.apply(a,arguments)};var K=a.map;a.map=function(j){if(j&&u){var n=j.tileSize();u.setAttribute("width",n.x);u.setAttribute("height",n.y)}return K.apply(a,arguments)};a.scale=function(j){if(!arguments.length)return x;(x=j)?a.on("move",f):a.off("move",f);a.map()&&f();return a};a.show=function(j){o?
+j.element.setAttribute("clip-path",l):j.element.removeAttribute("clip-path");a.dispatch({type:"show",tile:j,features:j.features});return a};a.reshow=function(){var j=a.cache.locks();for(var n in j)a.show(j[n]);return a};return a};t.dblclick=function(){function d(a){var g=m.zoom();g=a.shiftKey?Math.ceil(g)-g-1:1-g+Math.floor(g);c==="mouse"?m.zoomBy(g,m.mouse(a)):m.zoomBy(g)}var h={},c="mouse",m,f;h.zoom=function(a){if(!arguments.length)return c;c=a;return h};h.map=function(a){if(!arguments.length)return m;
+if(m){f.removeEventListener("dblclick",d,false);f=null}if(m=a){f=m.container();f.addEventListener("dblclick",d,false)}return h};return h};t.drag=function(){function d(g){if(!g.shiftKey){a={x:g.clientX,y:g.clientY};m.focusableParent().focus();g.preventDefault();document.body.style.setProperty("cursor","move",null)}}function h(g){if(a){m.panBy({x:g.clientX-a.x,y:g.clientY-a.y});a.x=g.clientX;a.y=g.clientY}}var c={},m,f,a;c.map=function(g){if(!arguments.length)return m;if(m){f.removeEventListener("mousedown",
+d,false);f=null}if(m=g){f=m.container();f.addEventListener("mousedown",d,false)}return c};window.addEventListener("mousemove",h,false);window.addEventListener("mouseup",function(g){if(a){h(g);a=null;document.body.style.removeProperty("cursor")}},false);return c};t.wheel=function(){function d(){k=null}function h(l){var i=(l.wheelDelta/120||-l.detail)*0.1,u;if(ba<0){u=Date.now();var x=u-f;if(x>9&&Math.abs(l.wheelDelta)/x>=50)ba=1;f=u}if(ba==1)i*=0.03;if(!a&&i){u=Date.now();if(u-m>200){i=i>0?+1:-1;m=
+u}else i=0}if(i)switch(g){case "mouse":u=o.mouse(l);k||(k=o.pointLocation(u));o.off("move",d).zoomBy(i,u,k).on("move",d);break;case "location":o.zoomBy(i,o.locationPoint(k),k);break;default:o.zoomBy(i);break}l.preventDefault();return false}var c={},m=0,f=0,a=true,g="mouse",k,o,q;c.smooth=function(l){if(!arguments.length)return a;a=l;return c};c.zoom=function(l,i){if(!arguments.length)return g;g=l;k=i;if(o)g=="mouse"?o.on("move",d):o.off("move",d);return c};c.map=function(l){if(!arguments.length)return o;
+if(o){q.removeEventListener("mousemove",d,false);q.removeEventListener("mousewheel",h,false);q.removeEventListener("DOMMouseScroll",h,false);q=null;o.off("move",d)}if(o=l){g=="mouse"&&o.on("move",d);q=o.container();q.addEventListener("mousemove",d,false);q.addEventListener("mousewheel",h,false);q.addEventListener("DOMMouseScroll",h,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;t.arrow=function(){function d(x){if(!(x.ctrlKey||x.altKey||x.metaKey)){var A=Date.now(),
+C=0,E=0;switch(x.keyCode){case 37:if(!a.left){g=A;a.left=1;a.right||(C=l)}break;case 39:if(!a.right){g=A;a.right=1;a.left||(C=-l)}break;case 38:if(!a.up){g=A;a.up=1;a.down||(E=l)}break;case 40:if(!a.down){g=A;a.down=1;a.up||(E=-l)}break;default:return}if(C||E)i.panBy({x:C,y:E});if(!k&&a.left|a.right|a.up|a.down)k=setInterval(m,q);x.preventDefault()}}function h(x){g=Date.now();switch(x.keyCode){case 37:a.left=0;break;case 39:a.right=0;break;case 38:a.up=0;break;case 40:a.down=0;break;default:return}if(k&&
+!(a.left|a.right|a.up|a.down))k=clearInterval(k);x.preventDefault()}function c(x){switch(x.charCode){case 45:case 95:i.zoom(Math.ceil(i.zoom())-1);break;case 43:case 61:i.zoom(Math.floor(i.zoom())+1);break;default:return}x.preventDefault()}function m(){if(i)if(!(Date.now()<g+o)){var x=(a.left-a.right)*l,A=(a.up-a.down)*l;if(x||A)i.panBy({x:x,y:A})}}var f={},a={left:0,right:0,up:0,down:0},g=0,k,o=250,q=50,l=16,i,u;f.map=function(x){if(!arguments.length)return i;if(i){u.removeEventListener("keypress",
+c,false);u.removeEventListener("keydown",d,false);u.removeEventListener("keyup",h,false);u=null}if(i=x){u=i.focusableParent();u.addEventListener("keypress",c,false);u.addEventListener("keydown",d,false);u.addEventListener("keyup",h,false)}return f};f.speed=function(x){if(!arguments.length)return l;l=x;return f};return f};t.hash=function(){function d(){var k=g(f);if(m!==k)location.replace(m=k)}function h(){if(location.hash!==m)if(a(f,(m=location.hash).substring(1)))d()}var c={},m,f,a=function(k,o){var q=
+o.split("/").map(Number);if(q.length<3||q.some(isNaN))return true;else{var l=k.size();k.zoomBy(q[0]-k.zoom(),{x:l.x/2,y:l.y/2},{lat:Math.min(89.99999999,Math.max(-89.99999999,q[1])),lon:q[2]})}},g=function(k){var o=k.center();k=k.zoom();var q=Math.max(0,Math.ceil(Math.log(k)/Math.LN2));return"#"+k.toFixed(2)+"/"+o.lat.toFixed(q)+"/"+o.lon.toFixed(q)};c.map=function(k){if(!arguments.length)return f;if(f){f.off("move",d);window.removeEventListener("hashchange",h,false)}if(f=k){f.on("move",d);window.addEventListener("hashchange",
+h,false);location.hash?h():d()}return c};c.parser=function(k){if(!arguments.length)return a;a=k;return c};c.formatter=function(k){if(!arguments.length)return g;g=k;return c};return c};t.interact=function(){var d={},h=t.drag(),c=t.wheel(),m=t.dblclick(),f=t.arrow();d.map=function(a){h.map(a);c.map(a);m.map(a);f.map(a);return d};return d};t.compass=function(){function d(y){B.setAttribute("class","compass active");I||(I=setInterval(h,s));R&&H.panBy(R);w=Date.now();return l(y)}function h(){R&&Date.now()>
+w+e&&H.panBy(R)}function c(y){if(y.shiftKey){F={x0:H.mouse(y)};H.focusableParent().focus();return l(y)}}function m(y){if(F){F.x1=H.mouse(y);N.setAttribute("x",Math.min(F.x0.x,F.x1.x));N.setAttribute("y",Math.min(F.x0.y,F.x1.y));N.setAttribute("width",Math.abs(F.x0.x-F.x1.x));N.setAttribute("height",Math.abs(F.x0.y-F.x1.y));N.removeAttribute("display")}}function f(){B.setAttribute("class","compass");if(F){if(F.x1){H.extent([H.pointLocation({x:Math.min(F.x0.x,F.x1.x),y:Math.max(F.x0.y,F.x1.y)}),H.pointLocation({x:Math.max(F.x0.x,
+F.x1.x),y:Math.min(F.x0.y,F.x1.y)})]);N.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function a(y){return function(){y?this.setAttribute("class","active"):this.removeAttribute("class");R=y}}function g(y){return function(D){B.setAttribute("class","compass active");var G=H.zoom();H.zoom(y<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function k(y){return function(D){H.zoom(y);return l(D)}}function o(){this.setAttribute("class","active")}function q(){this.removeAttribute("class")}
+function l(y){y.stopPropagation();y.preventDefault();return false}function i(y){var D=Math.SQRT1_2*j,G=j*0.7,J=j*0.2,M=t.svg("g"),P=M.appendChild(t.svg("path")),Q=M.appendChild(t.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d","M0,0L"+D+","+D+"A"+j+","+j+" 0 0,1 "+-D+","+D+"Z");Q.setAttribute("class","chevron");Q.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));Q.setAttribute("pointer-events","none");M.addEventListener("mousedown",
+d,false);M.addEventListener("mouseover",a(y),false);M.addEventListener("mouseout",a(null),false);M.addEventListener("dblclick",l,false);return M}function u(y){var D=j*0.4,G=D/2,J=t.svg("g"),M=J.appendChild(t.svg("path")),P=J.appendChild(t.svg("path")),Q=J.appendChild(t.svg("path")),X=J.appendChild(t.svg("path"));M.setAttribute("class","back");M.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",M.getAttribute("d"));Q.setAttribute("class",
+"chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(y>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",M.getAttribute("d"));J.addEventListener("mousedown",g(y),false);J.addEventListener("mouseover",o,false);J.addEventListener("mouseout",q,false);J.addEventListener("dblclick",l,false);return J}function x(y){var D=j*0.2,G=j*0.4,J=t.svg("g"),M=J.appendChild(t.svg("rect")),P=J.appendChild(t.svg("path"));M.setAttribute("pointer-events","all");M.setAttribute("fill",
+"none");M.setAttribute("x",-G);M.setAttribute("y",-0.75*G);M.setAttribute("width",2*G);M.setAttribute("height",1.5*G);P.setAttribute("class","chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",k(y),false);J.addEventListener("dblclick",l,false);return J}function A(){var y=j+6,D=y,G=H.size();switch(r){case "top-left":break;case "top-right":y=G.x-y;break;case "bottom-left":D=G.y-D;break;case "bottom-right":y=G.x-y;D=G.y-D;break}B.setAttribute("transform","translate("+y+","+D+
+")");N.setAttribute("transform","translate("+-y+","+-D+")");for(var J in K)J==H.zoom()?K[J].setAttribute("class","active"):K[J].removeAttribute("class")}function C(){for(;B.lastChild;)B.removeChild(B.lastChild);B.appendChild(N);if(L!="none"){O=B.appendChild(t.svg("g"));O.setAttribute("class","pan");var y=O.appendChild(t.svg("circle"));y.setAttribute("class","back");y.setAttribute("r",j);O.appendChild(i({x:0,y:-n})).setAttribute("transform","rotate(0)");O.appendChild(i({x:n,y:0})).setAttribute("transform",
+"rotate(90)");O.appendChild(i({x:0,y:n})).setAttribute("transform","rotate(180)");O.appendChild(i({x:-n,y:0})).setAttribute("transform","rotate(270)");y=O.appendChild(t.svg("circle"));y.setAttribute("fill","none");y.setAttribute("class","fore");y.setAttribute("r",j)}else O=null;if(z!="none"){v=B.appendChild(t.svg("g"));v.setAttribute("class","zoom");y=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(y=0;D<=H.zoomRange()[1];D++,y++)(K[D]=v.appendChild(x(D))).setAttribute("transform","translate(0,"+
+-(y+0.75)*j*0.4+")")}D=L=="none"?0.4:2;v.setAttribute("transform","translate(0,"+j*(/^top-/.test(r)?D+(y+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(y+0.5)*j*0.4+")");v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E={},B=t.svg("g"),K={},j=30,n=16,w=0,e=250,s=50,r="top-left",z="small",v,L="small",I,R,O,F,N=t.svg("rect"),H,T,U;B.setAttribute("class","compass");N.setAttribute("class","back fore");N.setAttribute("pointer-events","none");
+N.setAttribute("display","none");E.radius=function(y){if(!arguments.length)return j;j=y;H&&C();return E};E.speed=function(y){if(!arguments.length)return j;n=y;return E};E.position=function(y){if(!arguments.length)return r;r=y;H&&C();return E};E.pan=function(y){if(!arguments.length)return L;L=y;H&&C();return E};E.zoom=function(y){if(!arguments.length)return z;z=y;H&&C();return E};E.map=function(y){if(!arguments.length)return H;if(H){T.removeEventListener("mousedown",c,false);T.removeChild(B);T=null;
+U.removeEventListener("mousemove",m,false);U.removeEventListener("mouseup",f,false);U=null;H.off("move",A).off("resize",A)}if(H=y){T=H.container();T.appendChild(B);T.addEventListener("mousedown",c,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",m,false);U.addEventListener("mouseup",f,false);H.on("move",A).on("resize",A);C()}return E};return E};t.grid=function(){function d(){var f=m.firstChild,a=c.size(),g=c.pointLocation(Y);c.pointLocation(a);var k=Math.pow(2,4-Math.round(c.zoom()));
+g.lat=Math.floor(g.lat/k)*k;g.lon=Math.ceil(g.lon/k)*k;for(var o;(o=c.locationPoint(g).x)<=a.x;g.lon+=k){f||(f=m.appendChild(t.svg("line")));f.setAttribute("x1",o);f.setAttribute("x2",o);f.setAttribute("y1",0);f.setAttribute("y2",a.y);f=f.nextSibling}for(;(o=c.locationPoint(g).y)<=a.y;g.lat-=k){f||(f=m.appendChild(t.svg("line")));f.setAttribute("y1",o);f.setAttribute("y2",o);f.setAttribute("x1",0);f.setAttribute("x2",a.x);f=f.nextSibling}for(;f;){a=f.nextSibling;m.removeChild(f);f=a}}var h={},c,m=
+t.svg("g");m.setAttribute("class","grid");h.map=function(f){if(!arguments.length)return c;if(c){m.parentNode.removeChild(m);c.off("move",d).off("resize",d)}if(c=f){c.on("move",d).on("resize",d);c.container().appendChild(m);c.dispatch({type:"move"})}return h};return h};t.stylist=function(){function d(f){var a=f.features.length,g=h.length,k=c.length,o,q,l,i,u,x;for(u=0;u<a;++u)if(q=(o=f.features[u]).element){o=o.data;for(x=0;x<g;++x){i=(l=h[x]).value;if(typeof i==="function")i=i.call(null,o);i==null?
+l.name.local?q.removeAttributeNS(l.name.space,l.name.local):q.removeAttribute(l.name):l.name.local?q.setAttributeNS(l.name.space,l.name.local,i):q.setAttribute(l.name,i)}for(x=0;x<k;++x){i=(l=c[x]).value;if(typeof i==="function")i=i.call(null,o);i==null?q.style.removeProperty(l.name):q.style.setProperty(l.name,i,l.priority)}if(i=m){if(typeof i==="function")i=i.call(null,o);for(;q.lastChild;)q.removeChild(q.lastChild);i!=null&&q.appendChild(t.svg("title")).appendChild(document.createTextNode(i))}}}
+var h=[],c=[],m;d.attr=function(f,a){h.push({name:fa(f),value:a});return d};d.style=function(f,a,g){c.push({name:f,value:a,priority:arguments.length<3?null:g});return d};d.title=function(f){m=f;return d};return d}})(org.polymaps);
View
5 src/Compass.js
@@ -189,9 +189,8 @@ po.compass = function() {
case "bottom-left": y = size.y - y; break;
case "bottom-right": x = size.x - x; y = size.y - y; break;
}
- var tx = "translate(" + x + "," + y + ")";
- if (panContainer) panContainer.setAttribute("transform", tx);
- if (zoomContainer) zoomContainer.setAttribute("transform", tx);
+ g.setAttribute("transform", "translate(" + x + "," + y + ")");
+ dragRect.setAttribute("transform", "translate(" + -x + "," + -y + ")");
for (var i in ticks) {
i == map.zoom()
? ticks[i].setAttribute("class", "active")
View
43 src/Hash.js
@@ -4,26 +4,35 @@ po.hash = function() {
lat = 90 - 1e-8, // allowable latitude range
map;
- function move() {
+ var parser = function(map, s) {
+ var args = s.split("/").map(Number);
+ if (args.length < 3 || args.some(isNaN)) return true; // replace bogus hash
+ else {
+ var size = map.size();
+ map.zoomBy(args[0] - map.zoom(),
+ {x: size.x / 2, y: size.y / 2},
+ {lat: Math.min(lat, Math.max(-lat, args[1])), lon: args[2]});
+ }
+ };
+
+ var formatter = function(map) {
var center = map.center(),
zoom = map.zoom(),
- precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
- s1 = "#" + zoom.toFixed(2)
+ precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
+ return "#" + zoom.toFixed(2)
+ "/" + center.lat.toFixed(precision)
+ "/" + center.lon.toFixed(precision);
+ };
+
+ function move() {
+ var s1 = formatter(map);
if (s0 !== s1) location.replace(s0 = s1); // don't recenter the map!
}
function hashchange() {
if (location.hash === s0) return; // ignore spurious hashchange events
- var args = (s0 = location.hash).substring(1).split("/").map(Number);
- if (args.length < 3 || args.some(isNaN)) move(); // replace bogus hash
- else {
- var size = map.size();
- map.zoomBy(args[0] - map.zoom(),
- {x: size.x / 2, y: size.y / 2},
- {lat: Math.min(lat, Math.max(-lat, args[1])), lon: args[2]});
- }
+ if (parser(map, (s0 = location.hash).substring(1)))
+ move(); // replace bogus hash
}
hash.map = function(x) {
@@ -40,5 +49,17 @@ po.hash = function() {
return hash;
};
+ hash.parser = function(x) {
+ if (!arguments.length) return parser;
+ parser = x;
+ return hash;
+ };
+
+ hash.formatter = function(x) {
+ if (!arguments.length) return formatter;
+ formatter = x;
+ return hash;
+ };
+
return hash;
};
View
18 src/Image.js
@@ -10,16 +10,22 @@ po.image = function() {
if (typeof url == "function") {
element.setAttribute("opacity", 0);
- tile.request = po.queue.image(element, url(tile), function(img) {
- delete tile.request;
+ var tileUrl = url(tile);
+ if (tileUrl != null) {
+ tile.request = po.queue.image(element, tileUrl, function(img) {
+ delete tile.request;
+ tile.ready = true;
+ tile.img = img;
+ element.removeAttribute("opacity");
+ image.dispatch({type: "load", tile: tile});
+ });
+ } else {
tile.ready = true;
- tile.img = img;
- element.removeAttribute("opacity");
image.dispatch({type: "load", tile: tile});
- });
+ }
} else {
tile.ready = true;
- if (url) element.setAttributeNS(po.ns.xlink, "href", url);
+ if (url != null) element.setAttributeNS(po.ns.xlink, "href", url);
image.dispatch({type: "load", tile: tile});
}
}
View
18 src/Url.js
@@ -1,10 +1,16 @@
po.url = function(template) {
- var hosts = [];
+ var hosts = [],
+ repeat = true;
function format(c) {
var max = c.zoom < 0 ? 1 : 1 << c.zoom,
- column = c.column % max;
- if (column < 0) column += max;
+ column = c.column;
+ if (repeat) {
+ column = c.column % max;
+ if (column < 0) column += max;
+ } else if ((column < 0) || (column >= max)) {
+ return null;
+ }
return template.replace(/{(.)}/g, function(s, v) {
switch (v) {
case "S": return hosts[(Math.abs(c.zoom) + c.row + column) % hosts.length];
@@ -37,5 +43,11 @@ po.url = function(template) {
return format;
};
+ format.repeat = function(x) {
+ if (!arguments.length) return repeat;
+ repeat = x;
+ return format;
+ };
+
return format;
};
View
2 src/start.js
@@ -2,6 +2,6 @@ if (!org) var org = {};
if (!org.polymaps) org.polymaps = {};
(function(po){
- po.version = "2.2+1.0+2"; // This fork not semver!
+ po.version = "2.4.0+1"; // not semver!
var zero = {x: 0, y: 0};

0 comments on commit 6820f14

Please sign in to comment.
Something went wrong with that request. Please try again.