pietervdvn
7559f9259b
Add mapillary link to nearby_images Fix licenses Add missing assets First version of nearby-images
7 lines
189 KiB
JavaScript
7 lines
189 KiB
JavaScript
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.P4C=f()}}(function(){return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(_dereq_,module,exports){var SphericalMercator=function(){function isFloat(n){return Number(n)===n&&n%1!==0}function SphericalMercator(options){if(options=options||{},this.size=options.size||256,!cache[this.size]){var size=this.size,c=cache[this.size]={};c.Bc=[],c.Cc=[],c.zc=[],c.Ac=[];for(var d=0;d<30;d++)c.Bc.push(size/360),c.Cc.push(size/(2*Math.PI)),c.zc.push(size/2),c.Ac.push(size),size*=2}this.Bc=cache[this.size].Bc,this.Cc=cache[this.size].Cc,this.zc=cache[this.size].zc,this.Ac=cache[this.size].Ac}var cache={},D2R=Math.PI/180,R2D=180/Math.PI,A=6378137,MAXEXTENT=20037508.342789244;return SphericalMercator.prototype.px=function(ll,zoom){if(isFloat(zoom)){var size=this.size*Math.pow(2,zoom),d=size/2,bc=size/360,cc=size/(2*Math.PI),ac=size,f=Math.min(Math.max(Math.sin(D2R*ll[1]),-.9999),.9999),x=d+ll[0]*bc,y=d+.5*Math.log((1+f)/(1-f))*-cc;return x>ac&&(x=ac),y>ac&&(y=ac),[x,y]}var d=this.zc[zoom],f=Math.min(Math.max(Math.sin(D2R*ll[1]),-.9999),.9999),x=Math.round(d+ll[0]*this.Bc[zoom]),y=Math.round(d+.5*Math.log((1+f)/(1-f))*-this.Cc[zoom]);return x>this.Ac[zoom]&&(x=this.Ac[zoom]),y>this.Ac[zoom]&&(y=this.Ac[zoom]),[x,y]},SphericalMercator.prototype.ll=function(px,zoom){if(isFloat(zoom)){var size=this.size*Math.pow(2,zoom),bc=size/360,cc=size/(2*Math.PI),zc=size/2,g=(px[1]-zc)/-cc,lon=(px[0]-zc)/bc,lat=R2D*(2*Math.atan(Math.exp(g))-.5*Math.PI);return[lon,lat]}var g=(px[1]-this.zc[zoom])/-this.Cc[zoom],lon=(px[0]-this.zc[zoom])/this.Bc[zoom],lat=R2D*(2*Math.atan(Math.exp(g))-.5*Math.PI);return[lon,lat]},SphericalMercator.prototype.bbox=function(x,y,zoom,tms_style,srs){tms_style&&(y=Math.pow(2,zoom)-1-y);var ll=[x*this.size,(+y+1)*this.size],ur=[(+x+1)*this.size,y*this.size],bbox=this.ll(ll,zoom).concat(this.ll(ur,zoom));return"900913"===srs?this.convert(bbox,"900913"):bbox},SphericalMercator.prototype.xyz=function(bbox,zoom,tms_style,srs){"900913"===srs&&(bbox=this.convert(bbox,"WGS84"));var ll=[bbox[0],bbox[1]],ur=[bbox[2],bbox[3]],px_ll=this.px(ll,zoom),px_ur=this.px(ur,zoom),x=[Math.floor(px_ll[0]/this.size),Math.floor((px_ur[0]-1)/this.size)],y=[Math.floor(px_ur[1]/this.size),Math.floor((px_ll[1]-1)/this.size)],bounds={minX:Math.min.apply(Math,x)<0?0:Math.min.apply(Math,x),minY:Math.min.apply(Math,y)<0?0:Math.min.apply(Math,y),maxX:Math.max.apply(Math,x),maxY:Math.max.apply(Math,y)};if(tms_style){var tms={minY:Math.pow(2,zoom)-1-bounds.maxY,maxY:Math.pow(2,zoom)-1-bounds.minY};bounds.minY=tms.minY,bounds.maxY=tms.maxY}return bounds},SphericalMercator.prototype.convert=function(bbox,to){return"900913"===to?this.forward(bbox.slice(0,2)).concat(this.forward(bbox.slice(2,4))):this.inverse(bbox.slice(0,2)).concat(this.inverse(bbox.slice(2,4)))},SphericalMercator.prototype.forward=function(ll){var xy=[A*ll[0]*D2R,A*Math.log(Math.tan(.25*Math.PI+.5*ll[1]*D2R))];return xy[0]>MAXEXTENT&&(xy[0]=MAXEXTENT),xy[0]<-MAXEXTENT&&(xy[0]=-MAXEXTENT),xy[1]>MAXEXTENT&&(xy[1]=MAXEXTENT),xy[1]<-MAXEXTENT&&(xy[1]=-MAXEXTENT),xy},SphericalMercator.prototype.inverse=function(xy){return[xy[0]*R2D/A,(.5*Math.PI-2*Math.atan(Math.exp(-xy[1]/A)))*R2D]},SphericalMercator}();"undefined"!=typeof module&&"undefined"!=typeof exports&&(module.exports=exports=SphericalMercator)},{}],2:[function(_dereq_,module,exports){"use strict";function getLens(b64){var len=b64.length;if(len%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var validLen=b64.indexOf("=");validLen===-1&&(validLen=len);var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64),validLen=lens[0],placeHoldersLen=lens[1];return 3*(validLen+placeHoldersLen)/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return 3*(validLen+placeHoldersLen)/4-placeHoldersLen}function toByteArray(b64){for(var tmp,lens=getLens(b64),validLen=lens[0],placeHoldersLen=lens[1],arr=new Arr(_byteLength(b64,validLen,placeHoldersLen)),curByte=0,len=placeHoldersLen>0?validLen-4:validLen,i=0;i<len;i+=4)tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)],arr[curByte++]=tmp>>16&255,arr[curByte++]=tmp>>8&255,arr[curByte++]=255&tmp;return 2===placeHoldersLen&&(tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4,arr[curByte++]=255&tmp),1===placeHoldersLen&&(tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2,arr[curByte++]=tmp>>8&255,arr[curByte++]=255&tmp),arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[63&num]}function encodeChunk(uint8,start,end){for(var tmp,output=[],i=start;i<end;i+=3)tmp=(uint8[i]<<16&16711680)+(uint8[i+1]<<8&65280)+(255&uint8[i+2]),output.push(tripletToBase64(tmp));return output.join("")}function fromByteArray(uint8){for(var tmp,len=uint8.length,extraBytes=len%3,parts=[],maxChunkLength=16383,i=0,len2=len-extraBytes;i<len2;i+=maxChunkLength)parts.push(encodeChunk(uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength));return 1===extraBytes?(tmp=uint8[len-1],parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")):2===extraBytes&&(tmp=(uint8[len-2]<<8)+uint8[len-1],parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")),parts.join("")}exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63},{}],3:[function(_dereq_,module,exports){},{}],4:[function(_dereq_,module,exports){(function(global){"use strict";function typedArraySupport(){try{var arr=new Uint8Array(1);return arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===arr.foo()&&"function"==typeof arr.subarray&&0===arr.subarray(1,1).byteLength}catch(e){return!1}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()<length)throw new RangeError("Invalid typed array length");return Buffer.TYPED_ARRAY_SUPPORT?(that=new Uint8Array(length),that.__proto__=Buffer.prototype):(null===that&&(that=new Buffer(length)),that.length=length),that}function Buffer(arg,encodingOrOffset,length){if(!(Buffer.TYPED_ARRAY_SUPPORT||this instanceof Buffer))return new Buffer(arg,encodingOrOffset,length);if("number"==typeof arg){if("string"==typeof encodingOrOffset)throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(this,arg)}return from(this,arg,encodingOrOffset,length)}function from(that,value,encodingOrOffset,length){if("number"==typeof value)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&value instanceof ArrayBuffer?fromArrayBuffer(that,value,encodingOrOffset,length):"string"==typeof value?fromString(that,value,encodingOrOffset):fromObject(that,value)}function assertSize(size){if("number"!=typeof size)throw new TypeError('"size" argument must be a number');if(size<0)throw new RangeError('"size" argument must not be negative')}function alloc(that,size,fill,encoding){return assertSize(size),size<=0?createBuffer(that,size):void 0!==fill?"string"==typeof encoding?createBuffer(that,size).fill(fill,encoding):createBuffer(that,size).fill(fill):createBuffer(that,size)}function allocUnsafe(that,size){if(assertSize(size),that=createBuffer(that,size<0?0:0|checked(size)),!Buffer.TYPED_ARRAY_SUPPORT)for(var i=0;i<size;++i)that[i]=0;return that}function fromString(that,string,encoding){if("string"==typeof encoding&&""!==encoding||(encoding="utf8"),!Buffer.isEncoding(encoding))throw new TypeError('"encoding" must be a valid string encoding');var length=0|byteLength(string,encoding);that=createBuffer(that,length);var actual=that.write(string,encoding);return actual!==length&&(that=that.slice(0,actual)),that}function fromArrayLike(that,array){var length=array.length<0?0:0|checked(array.length);that=createBuffer(that,length);for(var i=0;i<length;i+=1)that[i]=255&array[i];return that}function fromArrayBuffer(that,array,byteOffset,length){if(array.byteLength,byteOffset<0||array.byteLength<byteOffset)throw new RangeError("'offset' is out of bounds");if(array.byteLength<byteOffset+(length||0))throw new RangeError("'length' is out of bounds");return array=void 0===byteOffset&&void 0===length?new Uint8Array(array):void 0===length?new Uint8Array(array,byteOffset):new Uint8Array(array,byteOffset,length),Buffer.TYPED_ARRAY_SUPPORT?(that=array,that.__proto__=Buffer.prototype):that=fromArrayLike(that,array),that}function fromObject(that,obj){if(Buffer.isBuffer(obj)){var len=0|checked(obj.length);return that=createBuffer(that,len),0===that.length?that:(obj.copy(that,0,0,len),that)}if(obj){if("undefined"!=typeof ArrayBuffer&&obj.buffer instanceof ArrayBuffer||"length"in obj)return"number"!=typeof obj.length||isnan(obj.length)?createBuffer(that,0):fromArrayLike(that,obj);if("Buffer"===obj.type&&isArray(obj.data))return fromArrayLike(that,obj.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(length){if(length>=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|length}function SlowBuffer(length){return+length!=length&&(length=0),Buffer.alloc(+length)}function byteLength(string,encoding){if(Buffer.isBuffer(string))return string.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(string)||string instanceof ArrayBuffer))return string.byteLength;"string"!=typeof string&&(string=""+string);var len=string.length;if(0===len)return 0;for(var loweredCase=!1;;)switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":case void 0:return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*len;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase(),loweredCase=!0}}function slowToString(encoding,start,end){var loweredCase=!1;if((void 0===start||start<0)&&(start=0),start>this.length)return"";if((void 0===end||end>this.length)&&(end=this.length),end<=0)return"";if(end>>>=0,start>>>=0,end<=start)return"";for(encoding||(encoding="utf8");;)switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase(),loweredCase=!0}}function swap(b,n,m){var i=b[n];b[n]=b[m],b[m]=i}function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(0===buffer.length)return-1;if("string"==typeof byteOffset?(encoding=byteOffset,byteOffset=0):byteOffset>2147483647?byteOffset=2147483647:byteOffset<-2147483648&&(byteOffset=-2147483648),byteOffset=+byteOffset,isNaN(byteOffset)&&(byteOffset=dir?0:buffer.length-1),byteOffset<0&&(byteOffset=buffer.length+byteOffset),byteOffset>=buffer.length){if(dir)return-1;byteOffset=buffer.length-1}else if(byteOffset<0){if(!dir)return-1;byteOffset=0}if("string"==typeof val&&(val=Buffer.from(val,encoding)),Buffer.isBuffer(val))return 0===val.length?-1:arrayIndexOf(buffer,val,byteOffset,encoding,dir);if("number"==typeof val)return val&=255,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?dir?Uint8Array.prototype.indexOf.call(buffer,val,byteOffset):Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset):arrayIndexOf(buffer,[val],byteOffset,encoding,dir);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){function read(buf,i){return 1===indexSize?buf[i]:buf.readUInt16BE(i*indexSize)}var indexSize=1,arrLength=arr.length,valLength=val.length;if(void 0!==encoding&&(encoding=String(encoding).toLowerCase(),"ucs2"===encoding||"ucs-2"===encoding||"utf16le"===encoding||"utf-16le"===encoding)){if(arr.length<2||val.length<2)return-1;indexSize=2,arrLength/=2,valLength/=2,byteOffset/=2}var i;if(dir){var foundIndex=-1;for(i=byteOffset;i<arrLength;i++)if(read(arr,i)===read(val,foundIndex===-1?0:i-foundIndex)){if(foundIndex===-1&&(foundIndex=i),i-foundIndex+1===valLength)return foundIndex*indexSize}else foundIndex!==-1&&(i-=i-foundIndex),foundIndex=-1}else for(byteOffset+valLength>arrLength&&(byteOffset=arrLength-valLength),i=byteOffset;i>=0;i--){for(var found=!0,j=0;j<valLength;j++)if(read(arr,i+j)!==read(val,j)){found=!1;break}if(found)return i}return-1}function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;length?(length=Number(length),length>remaining&&(length=remaining)):length=remaining;var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");length>strLen/2&&(length=strLen/2);for(var i=0;i<length;++i){var parsed=parseInt(string.substr(2*i,2),16);if(isNaN(parsed))return i;buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}function asciiWrite(buf,string,offset,length){return blitBuffer(asciiToBytes(string),buf,offset,length)}function latin1Write(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length)}function base64Slice(buf,start,end){return 0===start&&end===buf.length?base64.fromByteArray(buf):base64.fromByteArray(buf.slice(start,end))}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);for(var res=[],i=start;i<end;){var firstByte=buf[i],codePoint=null,bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:firstByte<128&&(codePoint=firstByte);break;case 2:secondByte=buf[i+1],128===(192&secondByte)&&(tempCodePoint=(31&firstByte)<<6|63&secondByte,tempCodePoint>127&&(codePoint=tempCodePoint));break;case 3:secondByte=buf[i+1],thirdByte=buf[i+2],128===(192&secondByte)&&128===(192&thirdByte)&&(tempCodePoint=(15&firstByte)<<12|(63&secondByte)<<6|63&thirdByte,tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)&&(codePoint=tempCodePoint));break;case 4:secondByte=buf[i+1],thirdByte=buf[i+2],fourthByte=buf[i+3],128===(192&secondByte)&&128===(192&thirdByte)&&128===(192&fourthByte)&&(tempCodePoint=(15&firstByte)<<18|(63&secondByte)<<12|(63&thirdByte)<<6|63&fourthByte,tempCodePoint>65535&&tempCodePoint<1114112&&(codePoint=tempCodePoint))}}null===codePoint?(codePoint=65533,bytesPerSequence=1):codePoint>65535&&(codePoint-=65536,res.push(codePoint>>>10&1023|55296),codePoint=56320|1023&codePoint),res.push(codePoint),i+=bytesPerSequence}return decodeCodePointsArray(res)}function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,codePoints);for(var res="",i=0;i<len;)res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH));return res}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(127&buf[i]);return ret}function latin1Slice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(buf[i]);return ret}function hexSlice(buf,start,end){var len=buf.length;(!start||start<0)&&(start=0),(!end||end<0||end>len)&&(end=len);for(var out="",i=start;i<end;++i)out+=toHex(buf[i]);return out}function utf16leSlice(buf,start,end){for(var bytes=buf.slice(start,end),res="",i=0;i<bytes.length;i+=2)res+=String.fromCharCode(bytes[i]+256*bytes[i+1]);return res}function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}function objectWriteUInt16(buf,value,offset,littleEndian){value<0&&(value=65535+value+1);for(var i=0,j=Math.min(buf.length-offset,2);i<j;++i)buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>8*(littleEndian?i:1-i)}function objectWriteUInt32(buf,value,offset,littleEndian){value<0&&(value=4294967295+value+1);for(var i=0,j=Math.min(buf.length-offset,4);i<j;++i)buf[offset+i]=value>>>8*(littleEndian?i:3-i)&255}function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){return noAssert||checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(buf,value,offset,littleEndian,23,4),offset+4}function writeDouble(buf,value,offset,littleEndian,noAssert){return noAssert||checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(buf,value,offset,littleEndian,52,8),offset+8}function base64clean(str){if(str=stringtrim(str).replace(INVALID_BASE64_RE,""),str.length<2)return"";for(;str.length%4!==0;)str+="=";return str}function stringtrim(str){return str.trim?str.trim():str.replace(/^\s+|\s+$/g,"")}function toHex(n){return n<16?"0"+n.toString(16):n.toString(16)}function utf8ToBytes(string,units){units=units||1/0;for(var codePoint,length=string.length,leadSurrogate=null,bytes=[],i=0;i<length;++i){if(codePoint=string.charCodeAt(i),codePoint>55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){(units-=3)>-1&&bytes.push(239,191,189);continue}if(i+1===length){(units-=3)>-1&&bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){(units-=3)>-1&&bytes.push(239,191,189),leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else leadSurrogate&&(units-=3)>-1&&bytes.push(239,191,189);if(leadSurrogate=null,codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,63&codePoint|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,63&codePoint|128)}else{if(!(codePoint<1114112))throw new Error("Invalid code point");if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,63&codePoint|128)}}return bytes}function asciiToBytes(str){for(var byteArray=[],i=0;i<str.length;++i)byteArray.push(255&str.charCodeAt(i));return byteArray}function utf16leToBytes(str,units){for(var c,hi,lo,byteArray=[],i=0;i<str.length&&!((units-=2)<0);++i)c=str.charCodeAt(i),hi=c>>8,lo=c%256,byteArray.push(lo),byteArray.push(hi);return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i<length&&!(i+offset>=dst.length||i>=src.length);++i)dst[i+offset]=src[i];return i}function isnan(val){return val!==val}var base64=_dereq_("base64-js"),ieee754=_dereq_("ieee754"),isArray=_dereq_("isarray");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50,Buffer.TYPED_ARRAY_SUPPORT=void 0!==global.TYPED_ARRAY_SUPPORT?global.TYPED_ARRAY_SUPPORT:typedArraySupport(),exports.kMaxLength=kMaxLength(),Buffer.poolSize=8192,Buffer._augment=function(arr){return arr.__proto__=Buffer.prototype,arr},Buffer.from=function(value,encodingOrOffset,length){return from(null,value,encodingOrOffset,length)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0})),Buffer.alloc=function(size,fill,encoding){return alloc(null,size,fill,encoding)},Buffer.allocUnsafe=function(size){return allocUnsafe(null,size)},Buffer.allocUnsafeSlow=function(size){return allocUnsafe(null,size)},Buffer.isBuffer=function(b){return!(null==b||!b._isBuffer)},Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);i<len;++i)if(a[i]!==b[i]){x=a[i],y=b[i];break}return x<y?-1:y<x?1:0},Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(list,length){if(!isArray(list))throw new TypeError('"list" argument must be an Array of Buffers');if(0===list.length)return Buffer.alloc(0);var i;if(void 0===length)for(length=0,i=0;i<list.length;++i)length+=list[i].length;var buffer=Buffer.allocUnsafe(length),pos=0;for(i=0;i<list.length;++i){var buf=list[i];if(!Buffer.isBuffer(buf))throw new TypeError('"list" argument must be an Array of Buffers');buf.copy(buffer,pos),pos+=buf.length}return buffer},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var len=this.length;if(len%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;i<len;i+=2)swap(this,i,i+1);return this},Buffer.prototype.swap32=function(){var len=this.length;if(len%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;i<len;i+=4)swap(this,i,i+3),swap(this,i+1,i+2);return this},Buffer.prototype.swap64=function(){var len=this.length;if(len%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;i<len;i+=8)swap(this,i,i+7),swap(this,i+1,i+6),swap(this,i+2,i+5),swap(this,i+3,i+4);return this},Buffer.prototype.toString=function(){var length=0|this.length;return 0===length?"":0===arguments.length?utf8Slice(this,0,length):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||0===Buffer.compare(this,b)},Buffer.prototype.inspect=function(){var str="",max=exports.INSPECT_MAX_BYTES;return this.length>0&&(str=this.toString("hex",0,max).match(/.{2}/g).join(" "),this.length>max&&(str+=" ... ")),"<Buffer "+str+">"},Buffer.prototype.compare=function(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target))throw new TypeError("Argument must be a Buffer");if(void 0===start&&(start=0),void 0===end&&(end=target?target.length:0),void 0===thisStart&&(thisStart=0),void 0===thisEnd&&(thisEnd=this.length),start<0||end>target.length||thisStart<0||thisEnd>this.length)throw new RangeError("out of range index");if(thisStart>=thisEnd&&start>=end)return 0;if(thisStart>=thisEnd)return-1;if(start>=end)return 1;if(start>>>=0,end>>>=0,thisStart>>>=0,thisEnd>>>=0,this===target)return 0;for(var x=thisEnd-thisStart,y=end-start,len=Math.min(x,y),thisCopy=this.slice(thisStart,thisEnd),targetCopy=target.slice(start,end),i=0;i<len;++i)if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i],y=targetCopy[i];break}return x<y?-1:y<x?1:0},Buffer.prototype.includes=function(val,byteOffset,encoding){return this.indexOf(val,byteOffset,encoding)!==-1},Buffer.prototype.indexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!0)},Buffer.prototype.lastIndexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!1)},Buffer.prototype.write=function(string,offset,length,encoding){if(void 0===offset)encoding="utf8",length=this.length,offset=0;else if(void 0===length&&"string"==typeof offset)encoding=offset,length=this.length,offset=0;else{if(!isFinite(offset))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");offset|=0,isFinite(length)?(length|=0,void 0===encoding&&(encoding="utf8")):(encoding=length,length=void 0)}var remaining=this.length-offset;if((void 0===length||length>remaining)&&(length=remaining),string.length>0&&(length<0||offset<0)||offset>this.length)throw new RangeError("Attempt to write outside buffer bounds");encoding||(encoding="utf8");for(var loweredCase=!1;;)switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase(),loweredCase=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start,end=void 0===end?len:~~end,start<0?(start+=len,start<0&&(start=0)):start>len&&(start=len),end<0?(end+=len,end<0&&(end=0)):end>len&&(end=len),end<start&&(end=start);var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT)newBuf=this.subarray(start,end),newBuf.__proto__=Buffer.prototype;else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,void 0);for(var i=0;i<sliceLen;++i)newBuf[i]=this[i+start]}return newBuf},Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset|=0,byteLength|=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val},Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset|=0,byteLength|=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset+--byteLength],mul=1;byteLength>0&&(mul*=256);)val+=this[offset+--byteLength]*mul;return val},Buffer.prototype.readUInt8=function(offset,noAssert){return noAssert||checkOffset(offset,1,this.length),this[offset]},Buffer.prototype.readUInt16LE=function(offset,noAssert){return noAssert||checkOffset(offset,2,this.length),this[offset]|this[offset+1]<<8},Buffer.prototype.readUInt16BE=function(offset,noAssert){return noAssert||checkOffset(offset,2,this.length),this[offset]<<8|this[offset+1]},Buffer.prototype.readUInt32LE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+16777216*this[offset+3]},Buffer.prototype.readUInt32BE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),16777216*this[offset]+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])},Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset|=0,byteLength|=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return mul*=128,val>=mul&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset|=0,byteLength|=0,noAssert||checkOffset(offset,byteLength,this.length);for(var i=byteLength,mul=1,val=this[offset+--i];i>0&&(mul*=256);)val+=this[offset+--i]*mul;return mul*=128,val>=mul&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readInt8=function(offset,noAssert){return noAssert||checkOffset(offset,1,this.length),128&this[offset]?(255-this[offset]+1)*-1:this[offset]},Buffer.prototype.readInt16LE=function(offset,noAssert){noAssert||checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt16BE=function(offset,noAssert){noAssert||checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt32LE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24},Buffer.prototype.readInt32BE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]},Buffer.prototype.readFloatLE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!0,23,4)},Buffer.prototype.readFloatBE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!1,23,4)},Buffer.prototype.readDoubleLE=function(offset,noAssert){return noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!0,52,8)},Buffer.prototype.readDoubleBE=function(offset,noAssert){return noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!1,52,8)},Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){if(value=+value,offset|=0,byteLength|=0,!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1,i=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){if(value=+value,offset|=0,byteLength|=0,!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1,mul=1;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUInt8=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(value=Math.floor(value)),this[offset]=255&value,offset+1},Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=255&value,this[offset+1]=value>>>8):objectWriteUInt16(this,value,offset,!0),offset+2},Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>8,this[offset+1]=255&value):objectWriteUInt16(this,value,offset,!1),offset+2},Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset+3]=value>>>24,this[offset+2]=value>>>16,this[offset+1]=value>>>8,this[offset]=255&value):objectWriteUInt32(this,value,offset,!0),offset+4},Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>24,
|
||
this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value):objectWriteUInt32(this,value,offset,!1),offset+4},Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){if(value=+value,offset|=0,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0,mul=1,sub=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)value<0&&0===sub&&0!==this[offset+i-1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){if(value=+value,offset|=0,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1,mul=1,sub=0;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)value<0&&0===sub&&0!==this[offset+i+1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeInt8=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(value=Math.floor(value)),value<0&&(value=255+value+1),this[offset]=255&value,offset+1},Buffer.prototype.writeInt16LE=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=255&value,this[offset+1]=value>>>8):objectWriteUInt16(this,value,offset,!0),offset+2},Buffer.prototype.writeInt16BE=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>8,this[offset+1]=255&value):objectWriteUInt16(this,value,offset,!1),offset+2},Buffer.prototype.writeInt32LE=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=255&value,this[offset+1]=value>>>8,this[offset+2]=value>>>16,this[offset+3]=value>>>24):objectWriteUInt32(this,value,offset,!0),offset+4},Buffer.prototype.writeInt32BE=function(value,offset,noAssert){return value=+value,offset|=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),value<0&&(value=4294967295+value+1),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value):objectWriteUInt32(this,value,offset,!1),offset+4},Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,!0,noAssert)},Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,!1,noAssert)},Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,!0,noAssert)},Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,!1,noAssert)},Buffer.prototype.copy=function(target,targetStart,start,end){if(start||(start=0),end||0===end||(end=this.length),targetStart>=target.length&&(targetStart=target.length),targetStart||(targetStart=0),end>0&&end<start&&(end=start),end===start)return 0;if(0===target.length||0===this.length)return 0;if(targetStart<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");end>this.length&&(end=this.length),target.length-targetStart<end-start&&(end=target.length-targetStart+start);var i,len=end-start;if(this===target&&start<targetStart&&targetStart<end)for(i=len-1;i>=0;--i)target[i+targetStart]=this[i+start];else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;i<len;++i)target[i+targetStart]=this[i+start];else Uint8Array.prototype.set.call(target,this.subarray(start,start+len),targetStart);return len},Buffer.prototype.fill=function(val,start,end,encoding){if("string"==typeof val){if("string"==typeof start?(encoding=start,start=0,end=this.length):"string"==typeof end&&(encoding=end,end=this.length),1===val.length){var code=val.charCodeAt(0);code<256&&(val=code)}if(void 0!==encoding&&"string"!=typeof encoding)throw new TypeError("encoding must be a string");if("string"==typeof encoding&&!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding)}else"number"==typeof val&&(val&=255);if(start<0||this.length<start||this.length<end)throw new RangeError("Out of range index");if(end<=start)return this;start>>>=0,end=void 0===end?this.length:end>>>0,val||(val=0);var i;if("number"==typeof val)for(i=start;i<end;++i)this[i]=val;else{var bytes=Buffer.isBuffer(val)?val:utf8ToBytes(new Buffer(val,encoding).toString()),len=bytes.length;for(i=0;i<end-start;++i)this[i+start]=bytes[i%len]}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":2,ieee754:9,isarray:12}],5:[function(_dereq_,module,exports){(function(Buffer){function isArray(arg){return Array.isArray?Array.isArray(arg):"[object Array]"===objectToString(arg)}function isBoolean(arg){return"boolean"==typeof arg}function isNull(arg){return null===arg}function isNullOrUndefined(arg){return null==arg}function isNumber(arg){return"number"==typeof arg}function isString(arg){return"string"==typeof arg}function isSymbol(arg){return"symbol"==typeof arg}function isUndefined(arg){return void 0===arg}function isRegExp(re){return"[object RegExp]"===objectToString(re)}function isObject(arg){return"object"==typeof arg&&null!==arg}function isDate(d){return"[object Date]"===objectToString(d)}function isError(e){return"[object Error]"===objectToString(e)||e instanceof Error}function isFunction(arg){return"function"==typeof arg}function isPrimitive(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"==typeof arg||"undefined"==typeof arg}function objectToString(o){return Object.prototype.toString.call(o)}exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=Buffer.isBuffer}).call(this,{isBuffer:_dereq_("../../is-buffer/index.js")})},{"../../is-buffer/index.js":11}],6:[function(_dereq_,module,exports){(function(process,Buffer){var Parser,StringDecoder,isObjLiteral,stream,util;stream=_dereq_("stream"),util=_dereq_("util"),StringDecoder=_dereq_("string_decoder").StringDecoder,module.exports=function(){var callback,called,chunks,data,err,options,parser;if(3===arguments.length){if(data=arguments[0],options=arguments[1],callback=arguments[2],"function"!=typeof callback)throw Error("Invalid callback argument: "+JSON.stringify(callback));if("string"!=typeof data&&!Buffer.isBuffer(arguments[0]))return callback(Error("Invalid data argument: "+JSON.stringify(data)))}else if(2===arguments.length){if("string"==typeof arguments[0]||Buffer.isBuffer(arguments[0])?data=arguments[0]:isObjLiteral(arguments[0])?options=arguments[0]:err="Invalid first argument: "+JSON.stringify(arguments[0]),"function"==typeof arguments[1]?callback=arguments[1]:isObjLiteral(arguments[1])?options?err="Invalid arguments: got options twice as first and second arguments":options=arguments[1]:err="Invalid first argument: "+JSON.stringify(arguments[1]),err){if(callback)return callback(Error(err));throw Error(err)}}else 1===arguments.length&&("function"==typeof arguments[0]?callback=arguments[0]:options=arguments[0]);return null==options&&(options={}),parser=new Parser(options),null!=data&&process.nextTick(function(){return parser.write(data),parser.end()}),callback&&(called=!1,chunks=options.objname?{}:[],parser.on("readable",function(){var chunk,results;for(results=[];chunk=parser.read();)options.objname?results.push(chunks[chunk[0]]=chunk[1]):results.push(chunks.push(chunk));return results}),parser.on("error",function(err){return called=!0,callback(err)}),parser.on("end",function(){if(!called)return callback(null,chunks)})),parser},Parser=function(options){var base,base1,base10,base11,base12,base13,base14,base15,base16,base2,base3,base4,base5,base6,base7,base8,base9,k,v;null==options&&(options={}),this.options={};for(k in options)v=options[k],this.options[k]=v;return this.options.objectMode=!0,stream.Transform.call(this,this.options),null==(base=this.options).rowDelimiter&&(base.rowDelimiter=null),"string"==typeof this.options.rowDelimiter&&(this.options.rowDelimiter=[this.options.rowDelimiter]),null==(base1=this.options).delimiter&&(base1.delimiter=","),void 0===this.options.quote||this.options.quote||(this.options.quote=""),null==(base2=this.options).quote&&(base2.quote='"'),null==(base3=this.options).escape&&(base3.escape='"'),null==(base4=this.options).columns&&(base4.columns=null),null==(base5=this.options).comment&&(base5.comment=""),null==(base6=this.options).objname&&(base6.objname=!1),null==(base7=this.options).trim&&(base7.trim=!1),null==(base8=this.options).ltrim&&(base8.ltrim=!1),null==(base9=this.options).rtrim&&(base9.rtrim=!1),null==(base10=this.options).auto_parse&&(base10.auto_parse=!1),null==(base11=this.options).auto_parse_date&&(base11.auto_parse_date=!1),this.options.auto_parse_date===!0&&(this.options.auto_parse_date=function(value){var m;return m=Date.parse(value),isNaN(m)||(value=new Date(m)),value}),null==(base12=this.options).relax&&(base12.relax=!1),null==(base13=this.options).relax_column_count&&(base13.relax_column_count=!1),null==(base14=this.options).skip_empty_lines&&(base14.skip_empty_lines=!1),null==(base15=this.options).max_limit_on_data_read&&(base15.max_limit_on_data_read=128e3),null==(base16=this.options).skip_lines_with_empty_values&&(base16.skip_lines_with_empty_values=!1),this.lines=0,this.count=0,this.skipped_line_count=0,this.empty_line_count=0,this.is_int=/^(\-|\+)?([1-9]+[0-9]*)$/,this.is_float=function(value){return value-parseFloat(value)+1>=0},this._={decoder:new StringDecoder,quoting:!1,commenting:!1,field:null,nextChar:null,closingQuote:0,line:[],chunks:[],rawBuf:"",buf:"",rowDelimiterLength:this.options.rowDelimiter?Math.max.apply(Math,this.options.rowDelimiter.map(function(v){return v.length})):void 0},this},util.inherits(Parser,stream.Transform),module.exports.Parser=Parser,Parser.prototype._transform=function(chunk,encoding,callback){var err;return chunk instanceof Buffer&&(chunk=this._.decoder.write(chunk)),err=this.__write(chunk,!1),err?this.emit("error",err):callback()},Parser.prototype._flush=function(callback){var err;return err=this.__write(this._.decoder.end(),!0),err?this.emit("error",err):this._.quoting?void this.emit("error",new Error("Quoted field not terminated at line "+(this.lines+1))):this._.line.length>0&&(err=this.__push(this._.line))?callback(err):callback()},Parser.prototype.__push=function(line){var call_column_udf,columns,err,field,i,j,len,lineAsColumns,rawBuf,ref,row;if(!this.options.skip_lines_with_empty_values||""!==line.join("").trim()){if(row=null,this.options.columns===!0)return this.options.columns=line,void(rawBuf="");if("function"==typeof this.options.columns)return call_column_udf=function(fn,line){var columns,err;try{return columns=fn.call(null,line),[null,columns]}catch(error){return err=error,[err]}},ref=call_column_udf(this.options.columns,line),err=ref[0],columns=ref[1],err?err:(this.options.columns=columns,void(rawBuf=""));if(!this._.line_length&&line.length>0&&(this._.line_length=this.options.columns?this.options.columns.length:line.length),1===line.length&&""===line[0])this.empty_line_count++;else if(line.length!==this._.line_length){if(!this.options.relax_column_count)return null!=this.options.columns?Error("Number of columns on line "+this.lines+" does not match header"):Error("Number of columns is inconsistent on line "+this.lines);this.count++,this.skipped_line_count++}else this.count++;if(null!=this.options.columns){for(lineAsColumns={},i=j=0,len=line.length;j<len;i=++j)field=line[i],this.options.columns[i]!==!1&&(lineAsColumns[this.options.columns[i]]=field);row=this.options.objname?[lineAsColumns[this.options.objname],lineAsColumns]:lineAsColumns}else row=line;if(!(this.count<this.options.from||this.count>this.options.to))return this.options.raw?(this.push({raw:this._.rawBuf,row:row}),this._.rawBuf=""):this.push(row),null}},Parser.prototype.__write=function(chars,end){var areNextCharsDelimiter,areNextCharsRowDelimiters,auto_parse,char,err,escapeIsQuote,i,isDelimiter,isEscape,isNextCharAComment,isQuote,isRowDelimiter,isRowDelimiterLength,is_float,is_int,l,ltrim,nextCharPos,ref,ref1,ref2,ref3,ref4,ref5,remainingBuffer,rowDelimiter,rtrim,wasCommenting;for(is_int=function(_this){return function(value){return"function"==typeof _this.is_int?_this.is_int(value):_this.is_int.test(value)}}(this),is_float=function(_this){return function(value){return"function"==typeof _this.is_float?_this.is_float(value):_this.is_float.test(value)}}(this),auto_parse=function(_this){return function(value){return _this.options.auto_parse?"function"==typeof _this.options.auto_parse?_this.options.auto_parse(value):(is_int(value)?value=parseInt(value):is_float(value)?value=parseFloat(value):_this.options.auto_parse_date&&(value=_this.options.auto_parse_date(value)),value):value}}(this),ltrim=this.options.trim||this.options.ltrim,rtrim=this.options.trim||this.options.rtrim,chars=this._.buf+chars,l=chars.length,i=0,0===this.lines&&65279===chars.charCodeAt(0)&&i++;i<l&&(end||(remainingBuffer=chars.substr(i,l-i),!(!this.options.rowDelimiter&&i+3>l||!this._.commenting&&l-i<this.options.comment.length&&this.options.comment.substr(0,l-i)===remainingBuffer||this.options.rowDelimiter&&l-i<this._.rowDelimiterLength&&this.options.rowDelimiter.some(function(rd){return rd.substr(0,l-i)===remainingBuffer})||this.options.rowDelimiter&&this._.quoting&&l-i<this.options.quote.length+this._.rowDelimiterLength&&this.options.rowDelimiter.some(function(_this){return function(rd){return(_this.options.quote+rd).substr(0,l-i)===remainingBuffer}}(this))||l-i<=this.options.delimiter.length&&this.options.delimiter.substr(0,l-i)===remainingBuffer||l-i<=this.options.escape.length&&this.options.escape.substr(0,l-i)===remainingBuffer)));)if(char=this._.nextChar?this._.nextChar:chars.charAt(i),this._.nextChar=l>i+1?chars.charAt(i+1):"",this.options.raw&&(this._.rawBuf+=char),null==this.options.rowDelimiter&&(nextCharPos=i,rowDelimiter=null,this._.quoting||"\n"!==char&&"\r"!==char?!this._.quoting||char!==this.options.quote||"\n"!==(ref=this._.nextChar)&&"\r"!==ref||(rowDelimiter=this._.nextChar,nextCharPos+=2,this.raw&&(rawBuf+=this._.nextChar)):(rowDelimiter=char,nextCharPos+=1),rowDelimiter&&("\r"===rowDelimiter&&"\n"===chars.charAt(nextCharPos)&&(rowDelimiter+="\n"),this.options.rowDelimiter=[rowDelimiter],this._.rowDelimiterLength=rowDelimiter.length)),this._.commenting||char!==this.options.escape||(escapeIsQuote=this.options.escape===this.options.quote,isEscape=this._.nextChar===this.options.escape,isQuote=this._.nextChar===this.options.quote,escapeIsQuote&&null==this._.field&&!this._.quoting||!isEscape&&!isQuote)){if(!this._.commenting&&char===this.options.quote)if(this._.quoting){if(areNextCharsRowDelimiters=this.options.rowDelimiter&&this.options.rowDelimiter.some(function(rd){return chars.substr(i+1,rd.length)===rd}),areNextCharsDelimiter=chars.substr(i+1,this.options.delimiter.length)===this.options.delimiter,isNextCharAComment=this._.nextChar===this.options.comment,!this._.nextChar||areNextCharsRowDelimiters||areNextCharsDelimiter||isNextCharAComment){this._.quoting=!1,this._.closingQuote=this.options.quote.length,i++,end&&i===l&&(this._.line.push(auto_parse(this._.field||"")),this._.field=null);continue}if(!this.options.relax)return Error("Invalid closing quote at line "+(this.lines+1)+"; found "+JSON.stringify(this._.nextChar)+" instead of delimiter "+JSON.stringify(this.options.delimiter));this._.quoting=!1,this._.field&&(this._.field=""+this.options.quote+this._.field)}else{if(!this._.field){this._.quoting=!0,i++;continue}if(null!=this._.field&&!this.options.relax)return Error("Invalid opening quote at line "+(this.lines+1))}if(isRowDelimiter=this.options.rowDelimiter&&this.options.rowDelimiter.some(function(rd){return chars.substr(i,rd.length)===rd}),(isRowDelimiter||end&&i===l-1)&&this.lines++,wasCommenting=!1,this._.commenting||this._.quoting||!this.options.comment||chars.substr(i,this.options.comment.length)!==this.options.comment?this._.commenting&&isRowDelimiter&&(wasCommenting=!0,this._.commenting=!1):this._.commenting=!0,isDelimiter=chars.substr(i,this.options.delimiter.length)===this.options.delimiter,this._.commenting||this._.quoting||!isDelimiter&&!isRowDelimiter)this._.commenting||this._.quoting||" "!==char&&"\t"!==char?this._.commenting?i++:(null==this._.field&&(this._.field=""),this._.field+=char,i++):(null==this._.field&&(this._.field=""),ltrim&&!this._.field||(this._.field+=char),i++);else{if(isRowDelimiter&&(isRowDelimiterLength=this.options.rowDelimiter.filter(function(rd){return chars.substr(i,rd.length)===rd})[0].length),isRowDelimiter&&0===this._.line.length&&null==this._.field&&(wasCommenting||this.options.skip_empty_lines)){i+=isRowDelimiterLength,this._.nextChar=chars.charAt(i);continue}if(rtrim&&(this._.closingQuote||(this._.field=null!=(ref1=this._.field)?ref1.trimRight():void 0)),this._.line.push(auto_parse(this._.field||"")),this._.closingQuote=0,this._.field=null,isDelimiter&&(i+=this.options.delimiter.length,this._.nextChar=chars.charAt(i),end&&!this._.nextChar&&(isRowDelimiter=!0,this._.line.push(""))),isRowDelimiter){if(err=this.__push(this._.line))return err;this._.line=[],i+=isRowDelimiterLength,this._.nextChar=chars.charAt(i);continue}}if(!this._.commenting&&(null!=(ref2=this._.field)?ref2.length:void 0)>this.options.max_limit_on_data_read)return Error("Field exceeds max_limit_on_data_read setting ("+this.options.max_limit_on_data_read+") "+JSON.stringify(this.options.delimiter));if(!this._.commenting&&(null!=(ref3=this._.line)?ref3.length:void 0)>this.options.max_limit_on_data_read)return Error("Row delimiter not found in the file "+JSON.stringify(this.options.rowDelimiter))}else i++,char=this._.nextChar,this._.nextChar=chars.charAt(i+1),null==this._.field&&(this._.field=""),this._.field+=char,this.options.raw&&(this._.rawBuf+=char),i++;if(end){if(null!=this._.field&&(rtrim&&(this._.closingQuote||(this._.field=null!=(ref4=this._.field)?ref4.trimRight():void 0)),this._.line.push(auto_parse(this._.field||"")),this._.field=null),(null!=(ref5=this._.field)?ref5.length:void 0)>this.options.max_limit_on_data_read)return Error("Delimiter not found in the file "+JSON.stringify(this.options.delimiter));if(0===l&&this.lines++,this._.line.length>this.options.max_limit_on_data_read)return Error("Row delimiter not found in the file "+JSON.stringify(this.options.rowDelimiter))}return this._.buf=chars.substr(i),null},isObjLiteral=function(_obj){var _test;return _test=_obj,"object"==typeof _obj&&null!==_obj&&!Array.isArray(_obj)&&function(){for(;;)if(null===Object.getPrototypeOf(_test=Object.getPrototypeOf(_test)))break;return Object.getPrototypeOf(_obj===_test)}()}}).call(this,_dereq_("_process"),_dereq_("buffer").Buffer)},{_process:18,buffer:4,stream:34,string_decoder:35,util:39}],7:[function(_dereq_,module,exports){(function(Buffer){var StringDecoder,parse;StringDecoder=_dereq_("string_decoder").StringDecoder,parse=_dereq_("./index"),module.exports=function(data,options){var decoder,err,parser,records;if(null==options&&(options={}),records=options.objname?{}:[],data instanceof Buffer&&(decoder=new StringDecoder,data=decoder.write(data)),parser=new parse.Parser(options),parser.push=function(record){return options.objname?records[record[0]]=record[1]:records.push(record)},err=parser.__write(data,!1))throw err;if(data instanceof Buffer&&(err=parser.__write(data.end(),!0)))throw err;return parser._flush(function(){}),records}}).call(this,_dereq_("buffer").Buffer)},{"./index":6,buffer:4,string_decoder:35}],8:[function(_dereq_,module,exports){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return"function"==typeof arg}function isNumber(arg){return"number"==typeof arg}function isObject(arg){return"object"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),"error"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(er=arguments[1],er instanceof Error)throw er;var err=new Error('Uncaught, unspecified "error" event. ('+er+")");throw err.context=er,err}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1),handler.apply(this,args)}else if(isObject(handler))for(args=Array.prototype.slice.call(arguments,1),listeners=handler.slice(),len=listeners.length,i=0;i<len;i++)listeners[i].apply(this,args);return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned&&(m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),"function"==typeof console.trace&&console.trace())),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError("listener must be a function");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit("removeListener",type,listener);else if(isObject(list)){for(i=length;i-- >0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(position<0)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit("removeListener",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)"removeListener"!==key&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events={},this}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else if(listeners)for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){var ret;return ret=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;if(evlistener)return evlistener.length}return 0},EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)}},{}],9:[function(_dereq_,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];for(i+=d,e=s&(1<<-nBits)-1,s>>=-nBits,nBits+=eLen;nBits>0;e=256*e+buffer[offset+i],i+=d,nBits-=8);for(m=e&(1<<-nBits)-1,e>>=-nBits,nBits+=mLen;nBits>0;m=256*m+buffer[offset+i],i+=d,nBits-=8);if(0===e)e=1-eBias;else{if(e===eMax)return m?NaN:(s?-1:1)*(1/0);m+=Math.pow(2,mLen),e-=eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)},exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=23===mLen?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||0===value&&1/value<0?1:0;for(value=Math.abs(value),isNaN(value)||value===1/0?(m=isNaN(value)?1:0,e=eMax):(e=Math.floor(Math.log(value)/Math.LN2),value*(c=Math.pow(2,-e))<1&&(e--,c*=2),value+=e+eBias>=1?rt/c:rt*Math.pow(2,1-eBias),value*c>=2&&(e++,c/=2),e+eBias>=eMax?(m=0,e=eMax):e+eBias>=1?(m=(value*c-1)*Math.pow(2,mLen),e+=eBias):(m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen),e=0));mLen>=8;buffer[offset+i]=255&m,i+=d,m/=256,mLen-=8);for(e=e<<mLen|m,eLen+=mLen;eLen>0;buffer[offset+i]=255&e,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=128*s}},{}],10:[function(_dereq_,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}},{}],11:[function(_dereq_,module,exports){function isBuffer(obj){return!!obj.constructor&&"function"==typeof obj.constructor.isBuffer&&obj.constructor.isBuffer(obj)}function isSlowBuffer(obj){return"function"==typeof obj.readFloatLE&&"function"==typeof obj.slice&&isBuffer(obj.slice(0,0))}module.exports=function(obj){return null!=obj&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)}},{}],12:[function(_dereq_,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return"[object Array]"==toString.call(arr)}},{}],13:[function(_dereq_,module,exports){"use strict";function kdbush(points,getX,getY,nodeSize,ArrayType){return new KDBush(points,getX,getY,nodeSize,ArrayType)}function KDBush(points,getX,getY,nodeSize,ArrayType){getX=getX||defaultGetX,getY=getY||defaultGetY,ArrayType=ArrayType||Array,this.nodeSize=nodeSize||64,this.points=points,this.ids=new ArrayType(points.length),this.coords=new ArrayType(2*points.length);for(var i=0;i<points.length;i++)this.ids[i]=i,this.coords[2*i]=getX(points[i]),this.coords[2*i+1]=getY(points[i]);sort(this.ids,this.coords,this.nodeSize,0,this.ids.length-1,0)}function defaultGetX(p){return p[0]}function defaultGetY(p){return p[1]}var sort=_dereq_("./sort"),range=_dereq_("./range"),within=_dereq_("./within");module.exports=kdbush,KDBush.prototype={range:function(minX,minY,maxX,maxY){return range(this.ids,this.coords,minX,minY,maxX,maxY,this.nodeSize)},within:function(x,y,r){return within(this.ids,this.coords,x,y,r,this.nodeSize)}}},{"./range":14,"./sort":15,"./within":16}],14:[function(_dereq_,module,exports){"use strict";function range(ids,coords,minX,minY,maxX,maxY,nodeSize){for(var x,y,stack=[0,ids.length-1,0],result=[];stack.length;){var axis=stack.pop(),right=stack.pop(),left=stack.pop();if(right-left<=nodeSize)for(var i=left;i<=right;i++)x=coords[2*i],y=coords[2*i+1],x>=minX&&x<=maxX&&y>=minY&&y<=maxY&&result.push(ids[i]);else{var m=Math.floor((left+right)/2);x=coords[2*m],y=coords[2*m+1],x>=minX&&x<=maxX&&y>=minY&&y<=maxY&&result.push(ids[m]);var nextAxis=(axis+1)%2;(0===axis?minX<=x:minY<=y)&&(stack.push(left),stack.push(m-1),stack.push(nextAxis)),(0===axis?maxX>=x:maxY>=y)&&(stack.push(m+1),stack.push(right),stack.push(nextAxis))}}return result}module.exports=range},{}],15:[function(_dereq_,module,exports){"use strict";function sortKD(ids,coords,nodeSize,left,right,depth){if(!(right-left<=nodeSize)){var m=Math.floor((left+right)/2);select(ids,coords,m,left,right,depth%2),sortKD(ids,coords,nodeSize,left,m-1,depth+1),sortKD(ids,coords,nodeSize,m+1,right,depth+1)}}function select(ids,coords,k,left,right,inc){for(;right>left;){if(right-left>600){var n=right-left+1,m=k-left+1,z=Math.log(n),s=.5*Math.exp(2*z/3),sd=.5*Math.sqrt(z*s*(n-s)/n)*(m-n/2<0?-1:1),newLeft=Math.max(left,Math.floor(k-m*s/n+sd)),newRight=Math.min(right,Math.floor(k+(n-m)*s/n+sd));select(ids,coords,k,newLeft,newRight,inc)}var t=coords[2*k+inc],i=left,j=right;for(swapItem(ids,coords,left,k),coords[2*right+inc]>t&&swapItem(ids,coords,left,right);i<j;){for(swapItem(ids,coords,i,j),i++,j--;coords[2*i+inc]<t;)i++;for(;coords[2*j+inc]>t;)j--}coords[2*left+inc]===t?swapItem(ids,coords,left,j):(j++,swapItem(ids,coords,j,right)),j<=k&&(left=j+1),k<=j&&(right=j-1)}}function swapItem(ids,coords,i,j){swap(ids,i,j),swap(coords,2*i,2*j),swap(coords,2*i+1,2*j+1)}function swap(arr,i,j){var tmp=arr[i];arr[i]=arr[j],arr[j]=tmp}module.exports=sortKD},{}],16:[function(_dereq_,module,exports){"use strict";function within(ids,coords,qx,qy,r,nodeSize){for(var stack=[0,ids.length-1,0],result=[],r2=r*r;stack.length;){var axis=stack.pop(),right=stack.pop(),left=stack.pop();if(right-left<=nodeSize)for(var i=left;i<=right;i++)sqDist(coords[2*i],coords[2*i+1],qx,qy)<=r2&&result.push(ids[i]);else{var m=Math.floor((left+right)/2),x=coords[2*m],y=coords[2*m+1];sqDist(x,y,qx,qy)<=r2&&result.push(ids[m]);var nextAxis=(axis+1)%2;(0===axis?qx-r<=x:qy-r<=y)&&(stack.push(left),stack.push(m-1),stack.push(nextAxis)),(0===axis?qx+r>=x:qy+r>=y)&&(stack.push(m+1),stack.push(right),stack.push(nextAxis))}}return result}function sqDist(ax,ay,bx,by){var dx=ax-bx,dy=ay-by;return dx*dx+dy*dy}module.exports=within},{}],17:[function(_dereq_,module,exports){(function(process){"use strict";function nextTick(fn,arg1,arg2,arg3){if("function"!=typeof fn)throw new TypeError('"callback" argument must be a function');var args,i,len=arguments.length;switch(len){case 0:case 1:return process.nextTick(fn);case 2:return process.nextTick(function(){fn.call(null,arg1)});case 3:return process.nextTick(function(){fn.call(null,arg1,arg2)});case 4:return process.nextTick(function(){fn.call(null,arg1,arg2,arg3)});default:for(args=new Array(len-1),i=0;i<args.length;)args[i++]=arguments[i];return process.nextTick(function(){fn.apply(null,args)})}}!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?module.exports={nextTick:nextTick}:module.exports=process}).call(this,_dereq_("_process"))},{_process:18}],18:[function(_dereq_,module,exports){function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0);
|
||
}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,runClearTimeout(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}var cachedSetTimeout,cachedClearTimeout,process=module.exports={};!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(name){return[]},process.binding=function(name){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(dir){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],19:[function(_dereq_,module,exports){module.exports=_dereq_("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":20}],20:[function(_dereq_,module,exports){"use strict";function Duplex(options){return this instanceof Duplex?(Readable.call(this,options),Writable.call(this,options),options&&options.readable===!1&&(this.readable=!1),options&&options.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,options&&options.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",onend)):new Duplex(options)}function onend(){this.allowHalfOpen||this._writableState.ended||pna.nextTick(onEndNT,this)}function onEndNT(self){self.end()}var pna=_dereq_("process-nextick-args"),objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};module.exports=Duplex;var util=_dereq_("core-util-is");util.inherits=_dereq_("inherits");var Readable=_dereq_("./_stream_readable"),Writable=_dereq_("./_stream_writable");util.inherits(Duplex,Readable);for(var keys=objectKeys(Writable.prototype),v=0;v<keys.length;v++){var method=keys[v];Duplex.prototype[method]||(Duplex.prototype[method]=Writable.prototype[method])}Object.defineProperty(Duplex.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(Duplex.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(value){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=value,this._writableState.destroyed=value)}}),Duplex.prototype._destroy=function(err,cb){this.push(null),this.end(),pna.nextTick(cb,err)}},{"./_stream_readable":22,"./_stream_writable":24,"core-util-is":5,inherits:10,"process-nextick-args":17}],21:[function(_dereq_,module,exports){"use strict";function PassThrough(options){return this instanceof PassThrough?void Transform.call(this,options):new PassThrough(options)}module.exports=PassThrough;var Transform=_dereq_("./_stream_transform"),util=_dereq_("core-util-is");util.inherits=_dereq_("inherits"),util.inherits(PassThrough,Transform),PassThrough.prototype._transform=function(chunk,encoding,cb){cb(null,chunk)}},{"./_stream_transform":23,"core-util-is":5,inherits:10}],22:[function(_dereq_,module,exports){(function(process,global){"use strict";function _uint8ArrayToBuffer(chunk){return Buffer.from(chunk)}function _isUint8Array(obj){return Buffer.isBuffer(obj)||obj instanceof OurUint8Array}function prependListener(emitter,event,fn){return"function"==typeof emitter.prependListener?emitter.prependListener(event,fn):void(emitter._events&&emitter._events[event]?isArray(emitter._events[event])?emitter._events[event].unshift(fn):emitter._events[event]=[fn,emitter._events[event]]:emitter.on(event,fn))}function ReadableState(options,stream){Duplex=Duplex||_dereq_("./_stream_duplex"),options=options||{};var isDuplex=stream instanceof Duplex;this.objectMode=!!options.objectMode,isDuplex&&(this.objectMode=this.objectMode||!!options.readableObjectMode);var hwm=options.highWaterMark,readableHwm=options.readableHighWaterMark,defaultHwm=this.objectMode?16:16384;hwm||0===hwm?this.highWaterMark=hwm:isDuplex&&(readableHwm||0===readableHwm)?this.highWaterMark=readableHwm:this.highWaterMark=defaultHwm,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new BufferList,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=options.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,options.encoding&&(StringDecoder||(StringDecoder=_dereq_("string_decoder/").StringDecoder),this.decoder=new StringDecoder(options.encoding),this.encoding=options.encoding)}function Readable(options){return Duplex=Duplex||_dereq_("./_stream_duplex"),this instanceof Readable?(this._readableState=new ReadableState(options,this),this.readable=!0,options&&("function"==typeof options.read&&(this._read=options.read),"function"==typeof options.destroy&&(this._destroy=options.destroy)),void Stream.call(this)):new Readable(options)}function readableAddChunk(stream,chunk,encoding,addToFront,skipChunkCheck){var state=stream._readableState;if(null===chunk)state.reading=!1,onEofChunk(stream,state);else{var er;skipChunkCheck||(er=chunkInvalid(state,chunk)),er?stream.emit("error",er):state.objectMode||chunk&&chunk.length>0?("string"==typeof chunk||state.objectMode||Object.getPrototypeOf(chunk)===Buffer.prototype||(chunk=_uint8ArrayToBuffer(chunk)),addToFront?state.endEmitted?stream.emit("error",new Error("stream.unshift() after end event")):addChunk(stream,state,chunk,!0):state.ended?stream.emit("error",new Error("stream.push() after EOF")):(state.reading=!1,state.decoder&&!encoding?(chunk=state.decoder.write(chunk),state.objectMode||0!==chunk.length?addChunk(stream,state,chunk,!1):maybeReadMore(stream,state)):addChunk(stream,state,chunk,!1))):addToFront||(state.reading=!1)}return needMoreData(state)}function addChunk(stream,state,chunk,addToFront){state.flowing&&0===state.length&&!state.sync?(stream.emit("data",chunk),stream.read(0)):(state.length+=state.objectMode?1:chunk.length,addToFront?state.buffer.unshift(chunk):state.buffer.push(chunk),state.needReadable&&emitReadable(stream)),maybeReadMore(stream,state)}function chunkInvalid(state,chunk){var er;return _isUint8Array(chunk)||"string"==typeof chunk||void 0===chunk||state.objectMode||(er=new TypeError("Invalid non-string/buffer chunk")),er}function needMoreData(state){return!state.ended&&(state.needReadable||state.length<state.highWaterMark||0===state.length)}function computeNewHighWaterMark(n){return n>=MAX_HWM?n=MAX_HWM:(n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++),n}function howMuchToRead(n,state){return n<=0||0===state.length&&state.ended?0:state.objectMode?1:n!==n?state.flowing&&state.length?state.buffer.head.data.length:state.length:(n>state.highWaterMark&&(state.highWaterMark=computeNewHighWaterMark(n)),n<=state.length?n:state.ended?state.length:(state.needReadable=!0,0))}function onEofChunk(stream,state){if(!state.ended){if(state.decoder){var chunk=state.decoder.end();chunk&&chunk.length&&(state.buffer.push(chunk),state.length+=state.objectMode?1:chunk.length)}state.ended=!0,emitReadable(stream)}}function emitReadable(stream){var state=stream._readableState;state.needReadable=!1,state.emittedReadable||(debug("emitReadable",state.flowing),state.emittedReadable=!0,state.sync?pna.nextTick(emitReadable_,stream):emitReadable_(stream))}function emitReadable_(stream){debug("emit readable"),stream.emit("readable"),flow(stream)}function maybeReadMore(stream,state){state.readingMore||(state.readingMore=!0,pna.nextTick(maybeReadMore_,stream,state))}function maybeReadMore_(stream,state){for(var len=state.length;!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark&&(debug("maybeReadMore read 0"),stream.read(0),len!==state.length);)len=state.length;state.readingMore=!1}function pipeOnDrain(src){return function(){var state=src._readableState;debug("pipeOnDrain",state.awaitDrain),state.awaitDrain&&state.awaitDrain--,0===state.awaitDrain&&EElistenerCount(src,"data")&&(state.flowing=!0,flow(src))}}function nReadingNextTick(self){debug("readable nexttick read 0"),self.read(0)}function resume(stream,state){state.resumeScheduled||(state.resumeScheduled=!0,pna.nextTick(resume_,stream,state))}function resume_(stream,state){state.reading||(debug("resume read 0"),stream.read(0)),state.resumeScheduled=!1,state.awaitDrain=0,stream.emit("resume"),flow(stream),state.flowing&&!state.reading&&stream.read(0)}function flow(stream){var state=stream._readableState;for(debug("flow",state.flowing);state.flowing&&null!==stream.read(););}function fromList(n,state){if(0===state.length)return null;var ret;return state.objectMode?ret=state.buffer.shift():!n||n>=state.length?(ret=state.decoder?state.buffer.join(""):1===state.buffer.length?state.buffer.head.data:state.buffer.concat(state.length),state.buffer.clear()):ret=fromListPartial(n,state.buffer,state.decoder),ret}function fromListPartial(n,list,hasStrings){var ret;return n<list.head.data.length?(ret=list.head.data.slice(0,n),list.head.data=list.head.data.slice(n)):ret=n===list.head.data.length?list.shift():hasStrings?copyFromBufferString(n,list):copyFromBuffer(n,list),ret}function copyFromBufferString(n,list){var p=list.head,c=1,ret=p.data;for(n-=ret.length;p=p.next;){var str=p.data,nb=n>str.length?str.length:n;if(ret+=nb===str.length?str:str.slice(0,n),n-=nb,0===n){nb===str.length?(++c,p.next?list.head=p.next:list.head=list.tail=null):(list.head=p,p.data=str.slice(nb));break}++c}return list.length-=c,ret}function copyFromBuffer(n,list){var ret=Buffer.allocUnsafe(n),p=list.head,c=1;for(p.data.copy(ret),n-=p.data.length;p=p.next;){var buf=p.data,nb=n>buf.length?buf.length:n;if(buf.copy(ret,ret.length-n,0,nb),n-=nb,0===n){nb===buf.length?(++c,p.next?list.head=p.next:list.head=list.tail=null):(list.head=p,p.data=buf.slice(nb));break}++c}return list.length-=c,ret}function endReadable(stream){var state=stream._readableState;if(state.length>0)throw new Error('"endReadable()" called on non-empty stream');state.endEmitted||(state.ended=!0,pna.nextTick(endReadableNT,state,stream))}function endReadableNT(state,stream){state.endEmitted||0!==state.length||(state.endEmitted=!0,stream.readable=!1,stream.emit("end"))}function indexOf(xs,x){for(var i=0,l=xs.length;i<l;i++)if(xs[i]===x)return i;return-1}var pna=_dereq_("process-nextick-args");module.exports=Readable;var Duplex,isArray=_dereq_("isarray");Readable.ReadableState=ReadableState;var EElistenerCount=(_dereq_("events").EventEmitter,function(emitter,type){return emitter.listeners(type).length}),Stream=_dereq_("./internal/streams/stream"),Buffer=_dereq_("safe-buffer").Buffer,OurUint8Array=global.Uint8Array||function(){},util=_dereq_("core-util-is");util.inherits=_dereq_("inherits");var debugUtil=_dereq_("util"),debug=void 0;debug=debugUtil&&debugUtil.debuglog?debugUtil.debuglog("stream"):function(){};var StringDecoder,BufferList=_dereq_("./internal/streams/BufferList"),destroyImpl=_dereq_("./internal/streams/destroy");util.inherits(Readable,Stream);var kProxyEvents=["error","close","destroy","pause","resume"];Object.defineProperty(Readable.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(value){this._readableState&&(this._readableState.destroyed=value)}}),Readable.prototype.destroy=destroyImpl.destroy,Readable.prototype._undestroy=destroyImpl.undestroy,Readable.prototype._destroy=function(err,cb){this.push(null),cb(err)},Readable.prototype.push=function(chunk,encoding){var skipChunkCheck,state=this._readableState;return state.objectMode?skipChunkCheck=!0:"string"==typeof chunk&&(encoding=encoding||state.defaultEncoding,encoding!==state.encoding&&(chunk=Buffer.from(chunk,encoding),encoding=""),skipChunkCheck=!0),readableAddChunk(this,chunk,encoding,!1,skipChunkCheck)},Readable.prototype.unshift=function(chunk){return readableAddChunk(this,chunk,null,!0,!1)},Readable.prototype.isPaused=function(){return this._readableState.flowing===!1},Readable.prototype.setEncoding=function(enc){return StringDecoder||(StringDecoder=_dereq_("string_decoder/").StringDecoder),this._readableState.decoder=new StringDecoder(enc),this._readableState.encoding=enc,this};var MAX_HWM=8388608;Readable.prototype.read=function(n){debug("read",n),n=parseInt(n,10);var state=this._readableState,nOrig=n;if(0!==n&&(state.emittedReadable=!1),0===n&&state.needReadable&&(state.length>=state.highWaterMark||state.ended))return debug("read: emitReadable",state.length,state.ended),0===state.length&&state.ended?endReadable(this):emitReadable(this),null;if(n=howMuchToRead(n,state),0===n&&state.ended)return 0===state.length&&endReadable(this),null;var doRead=state.needReadable;debug("need readable",doRead),(0===state.length||state.length-n<state.highWaterMark)&&(doRead=!0,debug("length less than watermark",doRead)),state.ended||state.reading?(doRead=!1,debug("reading or ended",doRead)):doRead&&(debug("do read"),state.reading=!0,state.sync=!0,0===state.length&&(state.needReadable=!0),this._read(state.highWaterMark),state.sync=!1,state.reading||(n=howMuchToRead(nOrig,state)));var ret;return ret=n>0?fromList(n,state):null,null===ret?(state.needReadable=!0,n=0):state.length-=n,0===state.length&&(state.ended||(state.needReadable=!0),nOrig!==n&&state.ended&&endReadable(this)),null!==ret&&this.emit("data",ret),ret},Readable.prototype._read=function(n){this.emit("error",new Error("_read() is not implemented"))},Readable.prototype.pipe=function(dest,pipeOpts){function onunpipe(readable,unpipeInfo){debug("onunpipe"),readable===src&&unpipeInfo&&unpipeInfo.hasUnpiped===!1&&(unpipeInfo.hasUnpiped=!0,cleanup())}function onend(){debug("onend"),dest.end()}function cleanup(){debug("cleanup"),dest.removeListener("close",onclose),dest.removeListener("finish",onfinish),dest.removeListener("drain",ondrain),dest.removeListener("error",onerror),dest.removeListener("unpipe",onunpipe),src.removeListener("end",onend),src.removeListener("end",unpipe),src.removeListener("data",ondata),cleanedUp=!0,!state.awaitDrain||dest._writableState&&!dest._writableState.needDrain||ondrain()}function ondata(chunk){debug("ondata"),increasedAwaitDrain=!1;var ret=dest.write(chunk);!1!==ret||increasedAwaitDrain||((1===state.pipesCount&&state.pipes===dest||state.pipesCount>1&&indexOf(state.pipes,dest)!==-1)&&!cleanedUp&&(debug("false write response, pause",src._readableState.awaitDrain),src._readableState.awaitDrain++,increasedAwaitDrain=!0),src.pause())}function onerror(er){debug("onerror",er),unpipe(),dest.removeListener("error",onerror),0===EElistenerCount(dest,"error")&&dest.emit("error",er)}function onclose(){dest.removeListener("finish",onfinish),unpipe()}function onfinish(){debug("onfinish"),dest.removeListener("close",onclose),unpipe()}function unpipe(){debug("unpipe"),src.unpipe(dest)}var src=this,state=this._readableState;switch(state.pipesCount){case 0:state.pipes=dest;break;case 1:state.pipes=[state.pipes,dest];break;default:state.pipes.push(dest)}state.pipesCount+=1,debug("pipe count=%d opts=%j",state.pipesCount,pipeOpts);var doEnd=(!pipeOpts||pipeOpts.end!==!1)&&dest!==process.stdout&&dest!==process.stderr,endFn=doEnd?onend:unpipe;state.endEmitted?pna.nextTick(endFn):src.once("end",endFn),dest.on("unpipe",onunpipe);var ondrain=pipeOnDrain(src);dest.on("drain",ondrain);var cleanedUp=!1,increasedAwaitDrain=!1;return src.on("data",ondata),prependListener(dest,"error",onerror),dest.once("close",onclose),dest.once("finish",onfinish),dest.emit("pipe",src),state.flowing||(debug("pipe resume"),src.resume()),dest},Readable.prototype.unpipe=function(dest){var state=this._readableState,unpipeInfo={hasUnpiped:!1};if(0===state.pipesCount)return this;if(1===state.pipesCount)return dest&&dest!==state.pipes?this:(dest||(dest=state.pipes),state.pipes=null,state.pipesCount=0,state.flowing=!1,dest&&dest.emit("unpipe",this,unpipeInfo),this);if(!dest){var dests=state.pipes,len=state.pipesCount;state.pipes=null,state.pipesCount=0,state.flowing=!1;for(var i=0;i<len;i++)dests[i].emit("unpipe",this,unpipeInfo);return this}var index=indexOf(state.pipes,dest);return index===-1?this:(state.pipes.splice(index,1),state.pipesCount-=1,1===state.pipesCount&&(state.pipes=state.pipes[0]),dest.emit("unpipe",this,unpipeInfo),this)},Readable.prototype.on=function(ev,fn){var res=Stream.prototype.on.call(this,ev,fn);if("data"===ev)this._readableState.flowing!==!1&&this.resume();else if("readable"===ev){var state=this._readableState;state.endEmitted||state.readableListening||(state.readableListening=state.needReadable=!0,state.emittedReadable=!1,state.reading?state.length&&emitReadable(this):pna.nextTick(nReadingNextTick,this))}return res},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.resume=function(){var state=this._readableState;return state.flowing||(debug("resume"),state.flowing=!0,resume(this,state)),this},Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this},Readable.prototype.wrap=function(stream){var _this=this,state=this._readableState,paused=!1;stream.on("end",function(){if(debug("wrapped end"),state.decoder&&!state.ended){var chunk=state.decoder.end();chunk&&chunk.length&&_this.push(chunk)}_this.push(null)}),stream.on("data",function(chunk){if(debug("wrapped data"),state.decoder&&(chunk=state.decoder.write(chunk)),(!state.objectMode||null!==chunk&&void 0!==chunk)&&(state.objectMode||chunk&&chunk.length)){var ret=_this.push(chunk);ret||(paused=!0,stream.pause())}});for(var i in stream)void 0===this[i]&&"function"==typeof stream[i]&&(this[i]=function(method){return function(){return stream[method].apply(stream,arguments)}}(i));for(var n=0;n<kProxyEvents.length;n++)stream.on(kProxyEvents[n],this.emit.bind(this,kProxyEvents[n]));return this._read=function(n){debug("wrapped _read",n),paused&&(paused=!1,stream.resume())},this},Object.defineProperty(Readable.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Readable._fromList=fromList}).call(this,_dereq_("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":20,"./internal/streams/BufferList":25,"./internal/streams/destroy":26,"./internal/streams/stream":27,_process:18,"core-util-is":5,events:8,inherits:10,isarray:12,"process-nextick-args":17,"safe-buffer":33,"string_decoder/":28,util:3}],23:[function(_dereq_,module,exports){"use strict";function afterTransform(er,data){var ts=this._transformState;ts.transforming=!1;var cb=ts.writecb;if(!cb)return this.emit("error",new Error("write callback called multiple times"));ts.writechunk=null,ts.writecb=null,null!=data&&this.push(data),cb(er);var rs=this._readableState;rs.reading=!1,(rs.needReadable||rs.length<rs.highWaterMark)&&this._read(rs.highWaterMark)}function Transform(options){return this instanceof Transform?(Duplex.call(this,options),this._transformState={afterTransform:afterTransform.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,options&&("function"==typeof options.transform&&(this._transform=options.transform),"function"==typeof options.flush&&(this._flush=options.flush)),void this.on("prefinish",prefinish)):new Transform(options)}function prefinish(){var _this=this;"function"==typeof this._flush?this._flush(function(er,data){done(_this,er,data)}):done(this,null,null)}function done(stream,er,data){if(er)return stream.emit("error",er);if(null!=data&&stream.push(data),stream._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(stream._transformState.transforming)throw new Error("Calling transform done when still transforming");return stream.push(null)}module.exports=Transform;var Duplex=_dereq_("./_stream_duplex"),util=_dereq_("core-util-is");util.inherits=_dereq_("inherits"),util.inherits(Transform,Duplex),Transform.prototype.push=function(chunk,encoding){return this._transformState.needTransform=!1,Duplex.prototype.push.call(this,chunk,encoding)},Transform.prototype._transform=function(chunk,encoding,cb){throw new Error("_transform() is not implemented")},Transform.prototype._write=function(chunk,encoding,cb){var ts=this._transformState;if(ts.writecb=cb,ts.writechunk=chunk,ts.writeencoding=encoding,!ts.transforming){var rs=this._readableState;(ts.needTransform||rs.needReadable||rs.length<rs.highWaterMark)&&this._read(rs.highWaterMark)}},Transform.prototype._read=function(n){var ts=this._transformState;null!==ts.writechunk&&ts.writecb&&!ts.transforming?(ts.transforming=!0,this._transform(ts.writechunk,ts.writeencoding,ts.afterTransform)):ts.needTransform=!0},Transform.prototype._destroy=function(err,cb){var _this2=this;Duplex.prototype._destroy.call(this,err,function(err2){cb(err2),_this2.emit("close")})}},{"./_stream_duplex":20,"core-util-is":5,inherits:10}],24:[function(_dereq_,module,exports){(function(process,global,setImmediate){"use strict";function CorkedRequest(state){var _this=this;this.next=null,this.entry=null,this.finish=function(){onCorkedFinish(_this,state)}}function _uint8ArrayToBuffer(chunk){return Buffer.from(chunk)}function _isUint8Array(obj){return Buffer.isBuffer(obj)||obj instanceof OurUint8Array}function nop(){}function WritableState(options,stream){Duplex=Duplex||_dereq_("./_stream_duplex"),options=options||{};var isDuplex=stream instanceof Duplex;this.objectMode=!!options.objectMode,isDuplex&&(this.objectMode=this.objectMode||!!options.writableObjectMode);var hwm=options.highWaterMark,writableHwm=options.writableHighWaterMark,defaultHwm=this.objectMode?16:16384;hwm||0===hwm?this.highWaterMark=hwm:isDuplex&&(writableHwm||0===writableHwm)?this.highWaterMark=writableHwm:this.highWaterMark=defaultHwm,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var noDecode=options.decodeStrings===!1;this.decodeStrings=!noDecode,this.defaultEncoding=options.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(er){onwrite(stream,er)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}function Writable(options){return Duplex=Duplex||_dereq_("./_stream_duplex"),realHasInstance.call(Writable,this)||this instanceof Duplex?(this._writableState=new WritableState(options,this),this.writable=!0,options&&("function"==typeof options.write&&(this._write=options.write),"function"==typeof options.writev&&(this._writev=options.writev),"function"==typeof options.destroy&&(this._destroy=options.destroy),"function"==typeof options.final&&(this._final=options.final)),void Stream.call(this)):new Writable(options)}function writeAfterEnd(stream,cb){var er=new Error("write after end");stream.emit("error",er),pna.nextTick(cb,er)}function validChunk(stream,state,chunk,cb){var valid=!0,er=!1;return null===chunk?er=new TypeError("May not write null values to stream"):"string"==typeof chunk||void 0===chunk||state.objectMode||(er=new TypeError("Invalid non-string/buffer chunk")),er&&(stream.emit("error",er),pna.nextTick(cb,er),valid=!1),valid}function decodeChunk(state,chunk,encoding){return state.objectMode||state.decodeStrings===!1||"string"!=typeof chunk||(chunk=Buffer.from(chunk,encoding)),chunk}function writeOrBuffer(stream,state,isBuf,chunk,encoding,cb){if(!isBuf){var newChunk=decodeChunk(state,chunk,encoding);chunk!==newChunk&&(isBuf=!0,encoding="buffer",chunk=newChunk)}var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length<state.highWaterMark;if(ret||(state.needDrain=!0),state.writing||state.corked){var last=state.lastBufferedRequest;state.lastBufferedRequest={chunk:chunk,encoding:encoding,isBuf:isBuf,callback:cb,next:null},last?last.next=state.lastBufferedRequest:state.bufferedRequest=state.lastBufferedRequest,state.bufferedRequestCount+=1}else doWrite(stream,state,!1,len,chunk,encoding,cb);return ret}function doWrite(stream,state,writev,len,chunk,encoding,cb){state.writelen=len,state.writecb=cb,state.writing=!0,state.sync=!0,writev?stream._writev(chunk,state.onwrite):stream._write(chunk,encoding,state.onwrite),state.sync=!1}function onwriteError(stream,state,sync,er,cb){--state.pendingcb,sync?(pna.nextTick(cb,er),pna.nextTick(finishMaybe,stream,state),stream._writableState.errorEmitted=!0,stream.emit("error",er)):(cb(er),stream._writableState.errorEmitted=!0,stream.emit("error",er),finishMaybe(stream,state))}function onwriteStateUpdate(state){state.writing=!1,state.writecb=null,state.length-=state.writelen,state.writelen=0}function onwrite(stream,er){var state=stream._writableState,sync=state.sync,cb=state.writecb;if(onwriteStateUpdate(state),er)onwriteError(stream,state,sync,er,cb);else{var finished=needFinish(state);finished||state.corked||state.bufferProcessing||!state.bufferedRequest||clearBuffer(stream,state),sync?asyncWrite(afterWrite,stream,state,finished,cb):afterWrite(stream,state,finished,cb)}}function afterWrite(stream,state,finished,cb){finished||onwriteDrain(stream,state),state.pendingcb--,cb(),finishMaybe(stream,state)}function onwriteDrain(stream,state){0===state.length&&state.needDrain&&(state.needDrain=!1,stream.emit("drain"))}function clearBuffer(stream,state){state.bufferProcessing=!0;var entry=state.bufferedRequest;if(stream._writev&&entry&&entry.next){var l=state.bufferedRequestCount,buffer=new Array(l),holder=state.corkedRequestsFree;holder.entry=entry;for(var count=0,allBuffers=!0;entry;)buffer[count]=entry,entry.isBuf||(allBuffers=!1),entry=entry.next,count+=1;buffer.allBuffers=allBuffers,doWrite(stream,state,!0,state.length,buffer,"",holder.finish),state.pendingcb++,state.lastBufferedRequest=null,holder.next?(state.corkedRequestsFree=holder.next,holder.next=null):state.corkedRequestsFree=new CorkedRequest(state),state.bufferedRequestCount=0}else{for(;entry;){var chunk=entry.chunk,encoding=entry.encoding,cb=entry.callback,len=state.objectMode?1:chunk.length;if(doWrite(stream,state,!1,len,chunk,encoding,cb),entry=entry.next,state.bufferedRequestCount--,state.writing)break}null===entry&&(state.lastBufferedRequest=null)}state.bufferedRequest=entry,state.bufferProcessing=!1}function needFinish(state){return state.ending&&0===state.length&&null===state.bufferedRequest&&!state.finished&&!state.writing}function callFinal(stream,state){stream._final(function(err){state.pendingcb--,err&&stream.emit("error",err),state.prefinished=!0,stream.emit("prefinish"),finishMaybe(stream,state)})}function prefinish(stream,state){state.prefinished||state.finalCalled||("function"==typeof stream._final?(state.pendingcb++,state.finalCalled=!0,pna.nextTick(callFinal,stream,state)):(state.prefinished=!0,stream.emit("prefinish")))}function finishMaybe(stream,state){var need=needFinish(state);return need&&(prefinish(stream,state),0===state.pendingcb&&(state.finished=!0,stream.emit("finish"))),need}function endWritable(stream,state,cb){state.ending=!0,finishMaybe(stream,state),cb&&(state.finished?pna.nextTick(cb):stream.once("finish",cb)),state.ended=!0,stream.writable=!1}function onCorkedFinish(corkReq,state,err){var entry=corkReq.entry;for(corkReq.entry=null;entry;){var cb=entry.callback;state.pendingcb--,cb(err),entry=entry.next}state.corkedRequestsFree?state.corkedRequestsFree.next=corkReq:state.corkedRequestsFree=corkReq}var pna=_dereq_("process-nextick-args");module.exports=Writable;var Duplex,asyncWrite=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:pna.nextTick;Writable.WritableState=WritableState;var util=_dereq_("core-util-is");util.inherits=_dereq_("inherits");var internalUtil={deprecate:_dereq_("util-deprecate")},Stream=_dereq_("./internal/streams/stream"),Buffer=_dereq_("safe-buffer").Buffer,OurUint8Array=global.Uint8Array||function(){},destroyImpl=_dereq_("./internal/streams/destroy");util.inherits(Writable,Stream),WritableState.prototype.getBuffer=function(){for(var current=this.bufferedRequest,out=[];current;)out.push(current),current=current.next;return out},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(_){}}();var realHasInstance;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(realHasInstance=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function(object){return!!realHasInstance.call(this,object)||this===Writable&&(object&&object._writableState instanceof WritableState)}})):realHasInstance=function(object){return object instanceof this},Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Writable.prototype.write=function(chunk,encoding,cb){var state=this._writableState,ret=!1,isBuf=!state.objectMode&&_isUint8Array(chunk);return isBuf&&!Buffer.isBuffer(chunk)&&(chunk=_uint8ArrayToBuffer(chunk)),"function"==typeof encoding&&(cb=encoding,encoding=null),isBuf?encoding="buffer":encoding||(encoding=state.defaultEncoding),"function"!=typeof cb&&(cb=nop),state.ended?writeAfterEnd(this,cb):(isBuf||validChunk(this,state,chunk,cb))&&(state.pendingcb++,ret=writeOrBuffer(this,state,isBuf,chunk,encoding,cb)),ret},Writable.prototype.cork=function(){var state=this._writableState;state.corked++},Writable.prototype.uncork=function(){var state=this._writableState;state.corked&&(state.corked--,state.writing||state.corked||state.finished||state.bufferProcessing||!state.bufferedRequest||clearBuffer(this,state))},Writable.prototype.setDefaultEncoding=function(encoding){if("string"==typeof encoding&&(encoding=encoding.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((encoding+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+encoding);return this._writableState.defaultEncoding=encoding,
|
||
this},Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("_write() is not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(chunk,encoding,cb){var state=this._writableState;"function"==typeof chunk?(cb=chunk,chunk=null,encoding=null):"function"==typeof encoding&&(cb=encoding,encoding=null),null!==chunk&&void 0!==chunk&&this.write(chunk,encoding),state.corked&&(state.corked=1,this.uncork()),state.ending||state.finished||endWritable(this,state,cb)},Object.defineProperty(Writable.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(value){this._writableState&&(this._writableState.destroyed=value)}}),Writable.prototype.destroy=destroyImpl.destroy,Writable.prototype._undestroy=destroyImpl.undestroy,Writable.prototype._destroy=function(err,cb){this.end(),cb(err)}}).call(this,_dereq_("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},_dereq_("timers").setImmediate)},{"./_stream_duplex":20,"./internal/streams/destroy":26,"./internal/streams/stream":27,_process:18,"core-util-is":5,inherits:10,"process-nextick-args":17,"safe-buffer":33,timers:36,"util-deprecate":37}],25:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function copyBuffer(src,target,offset){src.copy(target,offset)}var Buffer=_dereq_("safe-buffer").Buffer,util=_dereq_("util");module.exports=function(){function BufferList(){_classCallCheck(this,BufferList),this.head=null,this.tail=null,this.length=0}return BufferList.prototype.push=function(v){var entry={data:v,next:null};this.length>0?this.tail.next=entry:this.head=entry,this.tail=entry,++this.length},BufferList.prototype.unshift=function(v){var entry={data:v,next:this.head};0===this.length&&(this.tail=entry),this.head=entry,++this.length},BufferList.prototype.shift=function(){if(0!==this.length){var ret=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,ret}},BufferList.prototype.clear=function(){this.head=this.tail=null,this.length=0},BufferList.prototype.join=function(s){if(0===this.length)return"";for(var p=this.head,ret=""+p.data;p=p.next;)ret+=s+p.data;return ret},BufferList.prototype.concat=function(n){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var ret=Buffer.allocUnsafe(n>>>0),p=this.head,i=0;p;)copyBuffer(p.data,ret,i),i+=p.data.length,p=p.next;return ret},BufferList}(),util&&util.inspect&&util.inspect.custom&&(module.exports.prototype[util.inspect.custom]=function(){var obj=util.inspect({length:this.length});return this.constructor.name+" "+obj})},{"safe-buffer":33,util:3}],26:[function(_dereq_,module,exports){"use strict";function destroy(err,cb){var _this=this,readableDestroyed=this._readableState&&this._readableState.destroyed,writableDestroyed=this._writableState&&this._writableState.destroyed;return readableDestroyed||writableDestroyed?(cb?cb(err):!err||this._writableState&&this._writableState.errorEmitted||pna.nextTick(emitErrorNT,this,err),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(err||null,function(err){!cb&&err?(pna.nextTick(emitErrorNT,_this,err),_this._writableState&&(_this._writableState.errorEmitted=!0)):cb&&cb(err)}),this)}function undestroy(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function emitErrorNT(self,err){self.emit("error",err)}var pna=_dereq_("process-nextick-args");module.exports={destroy:destroy,undestroy:undestroy}},{"process-nextick-args":17}],27:[function(_dereq_,module,exports){module.exports=_dereq_("events").EventEmitter},{events:8}],28:[function(_dereq_,module,exports){"use strict";function _normalizeEncoding(enc){if(!enc)return"utf8";for(var retried;;)switch(enc){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return enc;default:if(retried)return;enc=(""+enc).toLowerCase(),retried=!0}}function normalizeEncoding(enc){var nenc=_normalizeEncoding(enc);if("string"!=typeof nenc&&(Buffer.isEncoding===isEncoding||!isEncoding(enc)))throw new Error("Unknown encoding: "+enc);return nenc||enc}function StringDecoder(encoding){this.encoding=normalizeEncoding(encoding);var nb;switch(this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,nb=4;break;case"utf8":this.fillLast=utf8FillLast,nb=4;break;case"base64":this.text=base64Text,this.end=base64End,nb=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(nb)}function utf8CheckByte(byte){return byte<=127?0:byte>>5===6?2:byte>>4===14?3:byte>>3===30?4:byte>>6===2?-1:-2}function utf8CheckIncomplete(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);return nb>=0?(nb>0&&(self.lastNeed=nb-1),nb):--j<i||nb===-2?0:(nb=utf8CheckByte(buf[j]),nb>=0?(nb>0&&(self.lastNeed=nb-2),nb):--j<i||nb===-2?0:(nb=utf8CheckByte(buf[j]),nb>=0?(nb>0&&(2===nb?nb=0:self.lastNeed=nb-3),nb):0))}function utf8CheckExtraBytes(self,buf,p){if(128!==(192&buf[0]))return self.lastNeed=0,"<22>";if(self.lastNeed>1&&buf.length>1){if(128!==(192&buf[1]))return self.lastNeed=1,"<22>";if(self.lastNeed>2&&buf.length>2&&128!==(192&buf[2]))return self.lastNeed=2,"<22>"}}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed,r=utf8CheckExtraBytes(this,buf,p);return void 0!==r?r:this.lastNeed<=buf.length?(buf.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(buf.copy(this.lastChar,p,0,buf.length),void(this.lastNeed-=buf.length))}function utf8Text(buf,i){var total=utf8CheckIncomplete(this,buf,i);if(!this.lastNeed)return buf.toString("utf8",i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);return buf.copy(this.lastChar,0,end),buf.toString("utf8",i,end)}function utf8End(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+"<22>":r}function utf16Text(buf,i){if((buf.length-i)%2===0){var r=buf.toString("utf16le",i);if(r){var c=r.charCodeAt(r.length-1);if(c>=55296&&c<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=buf[buf.length-1],buf.toString("utf16le",i,buf.length-1)}function utf16End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed){var end=this.lastTotal-this.lastNeed;return r+this.lastChar.toString("utf16le",0,end)}return r}function base64Text(buf,i){var n=(buf.length-i)%3;return 0===n?buf.toString("base64",i):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=buf[buf.length-1]:(this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1]),buf.toString("base64",i,buf.length-n))}function base64End(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+this.lastChar.toString("base64",0,3-this.lastNeed):r}function simpleWrite(buf){return buf.toString(this.encoding)}function simpleEnd(buf){return buf&&buf.length?this.write(buf):""}var Buffer=_dereq_("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(encoding){switch(encoding=""+encoding,encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};exports.StringDecoder=StringDecoder,StringDecoder.prototype.write=function(buf){if(0===buf.length)return"";var r,i;if(this.lastNeed){if(r=this.fillLast(buf),void 0===r)return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<buf.length?r?r+this.text(buf,i):this.text(buf,i):r||""},StringDecoder.prototype.end=utf8End,StringDecoder.prototype.text=utf8Text,StringDecoder.prototype.fillLast=function(buf){return this.lastNeed<=buf.length?(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,buf.length),void(this.lastNeed-=buf.length))}},{"safe-buffer":33}],29:[function(_dereq_,module,exports){module.exports=_dereq_("./readable").PassThrough},{"./readable":30}],30:[function(_dereq_,module,exports){exports=module.exports=_dereq_("./lib/_stream_readable.js"),exports.Stream=exports,exports.Readable=exports,exports.Writable=_dereq_("./lib/_stream_writable.js"),exports.Duplex=_dereq_("./lib/_stream_duplex.js"),exports.Transform=_dereq_("./lib/_stream_transform.js"),exports.PassThrough=_dereq_("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":20,"./lib/_stream_passthrough.js":21,"./lib/_stream_readable.js":22,"./lib/_stream_transform.js":23,"./lib/_stream_writable.js":24}],31:[function(_dereq_,module,exports){module.exports=_dereq_("./readable").Transform},{"./readable":30}],32:[function(_dereq_,module,exports){module.exports=_dereq_("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":24}],33:[function(_dereq_,module,exports){function copyProps(src,dst){for(var key in src)dst[key]=src[key]}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}var buffer=_dereq_("buffer"),Buffer=buffer.Buffer;Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),copyProps(Buffer,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if("number"==typeof arg)throw new TypeError("Argument must not be a number");return Buffer(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("Argument must be a number");var buf=Buffer(size);return void 0!==fill?"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf},SafeBuffer.allocUnsafe=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return Buffer(size)},SafeBuffer.allocUnsafeSlow=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(size)}},{buffer:4}],34:[function(_dereq_,module,exports){function Stream(){EE.call(this)}module.exports=Stream;var EE=_dereq_("events").EventEmitter,inherits=_dereq_("inherits");inherits(Stream,EE),Stream.Readable=_dereq_("readable-stream/readable.js"),Stream.Writable=_dereq_("readable-stream/writable.js"),Stream.Duplex=_dereq_("readable-stream/duplex.js"),Stream.Transform=_dereq_("readable-stream/transform.js"),Stream.PassThrough=_dereq_("readable-stream/passthrough.js"),Stream.Stream=Stream,Stream.prototype.pipe=function(dest,options){function ondata(chunk){dest.writable&&!1===dest.write(chunk)&&source.pause&&source.pause()}function ondrain(){source.readable&&source.resume&&source.resume()}function onend(){didOnEnd||(didOnEnd=!0,dest.end())}function onclose(){didOnEnd||(didOnEnd=!0,"function"==typeof dest.destroy&&dest.destroy())}function onerror(er){if(cleanup(),0===EE.listenerCount(this,"error"))throw er}function cleanup(){source.removeListener("data",ondata),dest.removeListener("drain",ondrain),source.removeListener("end",onend),source.removeListener("close",onclose),source.removeListener("error",onerror),dest.removeListener("error",onerror),source.removeListener("end",cleanup),source.removeListener("close",cleanup),dest.removeListener("close",cleanup)}var source=this;source.on("data",ondata),dest.on("drain",ondrain),dest._isStdio||options&&options.end===!1||(source.on("end",onend),source.on("close",onclose));var didOnEnd=!1;return source.on("error",onerror),dest.on("error",onerror),source.on("end",cleanup),source.on("close",cleanup),dest.on("close",cleanup),dest.emit("pipe",source),dest}},{events:8,inherits:10,"readable-stream/duplex.js":19,"readable-stream/passthrough.js":29,"readable-stream/readable.js":30,"readable-stream/transform.js":31,"readable-stream/writable.js":32}],35:[function(_dereq_,module,exports){function assertEncoding(encoding){if(encoding&&!isBufferEncoding(encoding))throw new Error("Unknown encoding: "+encoding)}function passThroughWrite(buffer){return buffer.toString(this.encoding)}function utf16DetectIncompleteChar(buffer){this.charReceived=buffer.length%2,this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(buffer){this.charReceived=buffer.length%3,this.charLength=this.charReceived?3:0}var Buffer=_dereq_("buffer").Buffer,isBufferEncoding=Buffer.isEncoding||function(encoding){switch(encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},StringDecoder=exports.StringDecoder=function(encoding){switch(this.encoding=(encoding||"utf8").toLowerCase().replace(/[-_]/,""),assertEncoding(encoding),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=base64DetectIncompleteChar;break;default:return void(this.write=passThroughWrite)}this.charBuffer=new Buffer(6),this.charReceived=0,this.charLength=0};StringDecoder.prototype.write=function(buffer){for(var charStr="";this.charLength;){var available=buffer.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;if(buffer.copy(this.charBuffer,this.charReceived,0,available),this.charReceived+=available,this.charReceived<this.charLength)return"";buffer=buffer.slice(available,buffer.length),charStr=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var charCode=charStr.charCodeAt(charStr.length-1);if(!(charCode>=55296&&charCode<=56319)){if(this.charReceived=this.charLength=0,0===buffer.length)return charStr;break}this.charLength+=this.surrogateSize,charStr=""}this.detectIncompleteChar(buffer);var end=buffer.length;this.charLength&&(buffer.copy(this.charBuffer,0,buffer.length-this.charReceived,end),end-=this.charReceived),charStr+=buffer.toString(this.encoding,0,end);var end=charStr.length-1,charCode=charStr.charCodeAt(end);if(charCode>=55296&&charCode<=56319){var size=this.surrogateSize;return this.charLength+=size,this.charReceived+=size,this.charBuffer.copy(this.charBuffer,size,0,size),buffer.copy(this.charBuffer,0,0,size),charStr.substring(0,end)}return charStr},StringDecoder.prototype.detectIncompleteChar=function(buffer){for(var i=buffer.length>=3?3:buffer.length;i>0;i--){var c=buffer[buffer.length-i];if(1==i&&c>>5==6){this.charLength=2;break}if(i<=2&&c>>4==14){this.charLength=3;break}if(i<=3&&c>>3==30){this.charLength=4;break}}this.charReceived=i},StringDecoder.prototype.end=function(buffer){var res="";if(buffer&&buffer.length&&(res=this.write(buffer)),this.charReceived){var cr=this.charReceived,buf=this.charBuffer,enc=this.encoding;res+=buf.slice(0,cr).toString(enc)}return res}},{buffer:4}],36:[function(_dereq_,module,exports){(function(setImmediate,clearImmediate){function Timeout(id,clearFn){this._id=id,this._clearFn=clearFn}var nextTick=_dereq_("process/browser.js").nextTick,apply=Function.prototype.apply,slice=Array.prototype.slice,immediateIds={},nextImmediateId=0;exports.setTimeout=function(){return new Timeout(apply.call(setTimeout,window,arguments),clearTimeout)},exports.setInterval=function(){return new Timeout(apply.call(setInterval,window,arguments),clearInterval)},exports.clearTimeout=exports.clearInterval=function(timeout){timeout.close()},Timeout.prototype.unref=Timeout.prototype.ref=function(){},Timeout.prototype.close=function(){this._clearFn.call(window,this._id)},exports.enroll=function(item,msecs){clearTimeout(item._idleTimeoutId),item._idleTimeout=msecs},exports.unenroll=function(item){clearTimeout(item._idleTimeoutId),item._idleTimeout=-1},exports._unrefActive=exports.active=function(item){clearTimeout(item._idleTimeoutId);var msecs=item._idleTimeout;msecs>=0&&(item._idleTimeoutId=setTimeout(function(){item._onTimeout&&item._onTimeout()},msecs))},exports.setImmediate="function"==typeof setImmediate?setImmediate:function(fn){var id=nextImmediateId++,args=!(arguments.length<2)&&slice.call(arguments,1);return immediateIds[id]=!0,nextTick(function(){immediateIds[id]&&(args?fn.apply(null,args):fn.call(null),exports.clearImmediate(id))}),id},exports.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(id){delete immediateIds[id]}}).call(this,_dereq_("timers").setImmediate,_dereq_("timers").clearImmediate)},{"process/browser.js":18,timers:36}],37:[function(_dereq_,module,exports){(function(global){function deprecate(fn,msg){function deprecated(){if(!warned){if(config("throwDeprecation"))throw new Error(msg);config("traceDeprecation")?console.trace(msg):console.warn(msg),warned=!0}return fn.apply(this,arguments)}if(config("noDeprecation"))return fn;var warned=!1;return deprecated}function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null!=val&&"true"===String(val).toLowerCase()}module.exports=deprecate}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],38:[function(_dereq_,module,exports){module.exports=function(arg){return arg&&"object"==typeof arg&&"function"==typeof arg.copy&&"function"==typeof arg.fill&&"function"==typeof arg.readUInt8}},{}],39:[function(_dereq_,module,exports){(function(process,global){function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(ctx.depth=arguments[2]),arguments.length>=4&&(ctx.colors=arguments[3]),isBoolean(opts)?ctx.showHidden=opts:opts&&exports._extend(ctx,opts),isUndefined(ctx.showHidden)&&(ctx.showHidden=!1),isUndefined(ctx.depth)&&(ctx.depth=2),isUndefined(ctx.colors)&&(ctx.colors=!1),isUndefined(ctx.customInspect)&&(ctx.customInspect=!0),ctx.colors&&(ctx.stylize=stylizeWithColor),formatValue(ctx,obj,ctx.depth)}function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];return style?"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m":str}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};return array.forEach(function(val,idx){hash[val]=!0}),hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&(!value.constructor||value.constructor.prototype!==value)){var ret=value.inspect(recurseTimes,ctx);return isString(ret)||(ret=formatValue(ctx,ret,recurseTimes)),ret}var primitive=formatPrimitive(ctx,value);if(primitive)return primitive;var keys=Object.keys(value),visibleKeys=arrayToHash(keys);if(ctx.showHidden&&(keys=Object.getOwnPropertyNames(value)),isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0))return formatError(value);if(0===keys.length){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),"regexp");if(isDate(value))return ctx.stylize(Date.prototype.toString.call(value),"date");if(isError(value))return formatError(value)}var base="",array=!1,braces=["{","}"];if(isArray(value)&&(array=!0,braces=["[","]"]),isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)&&(base=" "+RegExp.prototype.toString.call(value)),isDate(value)&&(base=" "+Date.prototype.toUTCString.call(value)),isError(value)&&(base=" "+formatError(value)),0===keys.length&&(!array||0==value.length))return braces[0]+base+braces[1];if(recurseTimes<0)return isRegExp(value)?ctx.stylize(RegExp.prototype.toString.call(value),"regexp"):ctx.stylize("[Object]","special");ctx.seen.push(value);var output;return output=array?formatArray(ctx,value,recurseTimes,visibleKeys,keys):keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)}),ctx.seen.pop(),reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}return isNumber(value)?ctx.stylize(""+value,"number"):isBoolean(value)?ctx.stylize(""+value,"boolean"):isNull(value)?ctx.stylize("null","null"):void 0}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){for(var output=[],i=0,l=value.length;i<l;++i)hasOwnProperty(value,String(i))?output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),!0)):output.push("");return keys.forEach(function(key){key.match(/^\d+$/)||output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,!0))}),output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;if(desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]},desc.get?str=desc.set?ctx.stylize("[Getter/Setter]","special"):ctx.stylize("[Getter]","special"):desc.set&&(str=ctx.stylize("[Setter]","special")),hasOwnProperty(visibleKeys,key)||(name="["+key+"]"),str||(ctx.seen.indexOf(desc.value)<0?(str=isNull(recurseTimes)?formatValue(ctx,desc.value,null):formatValue(ctx,desc.value,recurseTimes-1),str.indexOf("\n")>-1&&(str=array?str.split("\n").map(function(line){return" "+line}).join("\n").substr(2):"\n"+str.split("\n").map(function(line){return" "+line}).join("\n"))):str=ctx.stylize("[Circular]","special")),isUndefined(name)){if(array&&key.match(/^\d+$/))return str;name=JSON.stringify(""+key),name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(name=name.substr(1,name.length-2),name=ctx.stylize(name,"name")):(name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),name=ctx.stylize(name,"string"))}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0,length=output.reduce(function(prev,cur){return numLinesEst++,cur.indexOf("\n")>=0&&numLinesEst++,prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);return length>60?braces[0]+(""===base?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]:braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}function isBoolean(arg){return"boolean"==typeof arg}function isNull(arg){return null===arg}function isNullOrUndefined(arg){return null==arg}function isNumber(arg){return"number"==typeof arg}function isString(arg){return"string"==typeof arg}function isSymbol(arg){return"symbol"==typeof arg}function isUndefined(arg){return void 0===arg}function isRegExp(re){return isObject(re)&&"[object RegExp]"===objectToString(re)}function isObject(arg){return"object"==typeof arg&&null!==arg}function isDate(d){return isObject(d)&&"[object Date]"===objectToString(d)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(arg){return"function"==typeof arg}function isPrimitive(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"==typeof arg||"undefined"==typeof arg}function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}function timestamp(){var d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){for(var objects=[],i=0;i<arguments.length;i++)objects.push(inspect(arguments[i]));return objects.join(" ")}for(var i=1,args=arguments,len=args.length,str=String(f).replace(formatRegExp,function(x){if("%%"===x)return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}}),x=args[i];i<len;x=args[++i])str+=isNull(x)||!isObject(x)?" "+x:" "+inspect(x);return str},exports.deprecate=function(fn,msg){function deprecated(){if(!warned){if(process.throwDeprecation)throw new Error(msg);process.traceDeprecation?console.trace(msg):console.error(msg),warned=!0}return fn.apply(this,arguments)}if(isUndefined(global.process))return function(){return exports.deprecate(fn,msg).apply(this,arguments)};if(process.noDeprecation===!0)return fn;var warned=!1;return deprecated};var debugEnviron,debugs={};exports.debuglog=function(set){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),set=set.toUpperCase(),!debugs[set])if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else debugs[set]=function(){};return debugs[set]},exports.inspect=inspect,inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=_dereq_("./support/isBuffer");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))},exports.inherits=_dereq_("inherits"),exports._extend=function(origin,add){if(!add||!isObject(add))return origin;for(var keys=Object.keys(add),i=keys.length;i--;)origin[keys[i]]=add[keys[i]];return origin}}).call(this,_dereq_("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":38,_process:18,inherits:10}],40:[function(_dereq_,module,exports){"use strict";!function(){_dereq_("./ctrl/Compatibility");var P4C={EventLauncher:_dereq_("./ctrl/EventLauncher"),Detection:_dereq_("./model/Detection"),Fetcher:_dereq_("./ctrl/Fetcher"),fetchers:{CSV:_dereq_("./ctrl/fetchers/CSV"),Flickr:_dereq_("./ctrl/fetchers/Flickr"),Mapillary:_dereq_("./ctrl/fetchers/Mapillary"),OpenStreetCam:_dereq_("./ctrl/fetchers/OpenStreetCam"),WikiCommons:_dereq_("./ctrl/fetchers/WikiCommons")},LatLng:_dereq_("./model/LatLng"),LatLngBounds:_dereq_("./model/LatLngBounds"),Picture:_dereq_("./model/Picture"),PicturesManager:_dereq_("./ctrl/PicturesManager")};"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=P4C:window.P4C=P4C}()},{"./ctrl/Compatibility":41,"./ctrl/EventLauncher":42,"./ctrl/Fetcher":43,"./ctrl/PicturesManager":44,"./ctrl/fetchers/CSV":45,"./ctrl/fetchers/Flickr":46,"./ctrl/fetchers/Mapillary":47,"./ctrl/fetchers/OpenStreetCam":48,"./ctrl/fetchers/WikiCommons":49,"./model/Detection":50,"./model/LatLng":51,"./model/LatLngBounds":52,"./model/Picture":53}],41:[function(_dereq_,module,exports){"use strict";Array.prototype.includes||(Array.prototype.includes=function(searchElement){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var O=Object(this),len=parseInt(O.length,10)||0;if(0===len)return!1;var k,n=parseInt(arguments[1],10)||0;n>=0?k=n:(k=len+n,k<0&&(k=0));for(var currentElement;k<len;){if(currentElement=O[k],searchElement===currentElement||searchElement!==searchElement&¤tElement!==currentElement)return!0;k++}return!1}),"function"!=typeof Object.assign&&(Object.assign=function(target,varArgs){if(null==target)throw new TypeError("Cannot convert undefined or null to object");for(var to=Object(target),index=1;index<arguments.length;index++){var nextSource=arguments[index];if(null!=nextSource)for(var nextKey in nextSource)Object.prototype.hasOwnProperty.call(nextSource,nextKey)&&(to[nextKey]=nextSource[nextKey])}return to})},{}],42:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),EventLauncher=function(){function EventLauncher(){if(_classCallCheck(this,EventLauncher),"EventLauncher"===this.constructor.name)throw new TypeError("ctrl.eventlauncher.cantinstantiate");return this.eventListeners={},this}return _createClass(EventLauncher,[{key:"on",value:function(event,handler){return void 0===this.eventListeners[event]&&(this.eventListeners[event]=[]),this.eventListeners[event].push(handler),this}},{key:"off",value:function(event,handler){if(void 0===handler||null===handler)this.eventListeners[event]=void 0;else if(void 0!==this.eventListeners[event])for(;this.eventListeners[event].indexOf(handler)>=0;)this.eventListeners[event].splice(this.eventListeners[event].indexOf(handler),1);return this}},{key:"fire",value:function(event,data){if(void 0!==this.eventListeners[event]){var _iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_loop=function(){var f=_step.value;setTimeout(function(){f(data)},0)},_iterator=this.eventListeners[event][Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0)_loop()}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{!_iteratorNormalCompletion&&_iterator.return&&_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}}return this}}]),EventLauncher}();module.exports=EventLauncher},{}],43:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Fetcher=function(){function Fetcher(){if(_classCallCheck(this,Fetcher),"Fetcher"===this.constructor.name)throw new TypeError("ctrl.fetcher.cantinstantiate");if(void 0===this.requestPictures)throw new TypeError("ctrl.fetcher.mustoverride.requestPictures");if(void 0===this.requestSummary)throw new TypeError("ctrl.fetcher.mustoverride.requestSummary");if(void 0===this.tagsToPictures)throw new TypeError("ctrl.fetcher.mustoverride.tagsToPictures");
|
||
if(void 0===this.name)throw new TypeError("ctrl.fetcher.mustoverride.getName");if(void 0===this.logoUrl)throw new TypeError("ctrl.fetcher.mustoverride.getLogoUrl");if(void 0===this.homepageUrl)throw new TypeError("ctrl.fetcher.mustoverride.getHomepageUrl");this.options={mindate:null,maxdate:null}}return _createClass(Fetcher,[{key:"requestPictures",value:function(boundingBox,options){throw new TypeError("ctrl.fetcher.mustoverride.requestPictures")}},{key:"requestSummary",value:function(boundingBox,options){throw new TypeError("ctrl.fetcher.mustoverride.requestSummary")}},{key:"requestDetections",value:function(boundingBox,options){throw new TypeError("ctrl.fetcher.mustoverride.requestDetections")}},{key:"tagsToPictures",value:function(tags){throw new TypeError("ctrl.fetcher.mustoverride.tagsToPictures")}},{key:"ajax",value:function(url,type){return new Promise(function(resolve,reject){var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState===XMLHttpRequest.DONE)if(200===xmlhttp.status)try{resolve("json"==type?JSON.parse(xmlhttp.responseText):"json_h"==type?{json:JSON.parse(xmlhttp.responseText),xmlhttp:xmlhttp}:xmlhttp.responseText)}catch(e){reject(e)}else reject(new Error("fetcher.ajax.fail "+xmlhttp.status))},xmlhttp.open("GET",url,!0),xmlhttp.timeout=15e3,xmlhttp.ontimeout=function(){reject(new Error("fetcher.ajax.timeout"))},xmlhttp.send()})}},{key:"ajaxPost",value:function(url,parameters,responseType){return new Promise(function(resolve,reject){var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState===XMLHttpRequest.DONE)if(200===xmlhttp.status)if("json"==responseType)try{resolve(JSON.parse(xmlhttp.responseText))}catch(e){reject(e)}else resolve(xmlhttp.responseText);else reject(new Error("fetcher.ajaxpost.fail"))};var params="";if(parameters)for(var key in parameters)""!=params&&(params+="&"),params+=key+"="+encodeURIComponent(parameters[key]);xmlhttp.open("POST",url,!0),xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),xmlhttp.timeout=15e3,xmlhttp.ontimeout=function(){reject(new Error("fetcher.ajax.timeout"))},xmlhttp.send(params)})}},{key:"name",get:function(){throw new TypeError("ctrl.fetcher.mustoverride.getName")}}]),Fetcher}();module.exports=Fetcher},{}],44:[function(_dereq_,module,exports){"use strict";function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),CSVFetcher=_dereq_("./fetchers/CSV"),EventLauncher=_dereq_("./EventLauncher"),FlickrFetcher=_dereq_("./fetchers/Flickr"),LatLng=_dereq_("../model/LatLng"),LatLngBounds=_dereq_("../model/LatLngBounds"),Detection=_dereq_("../model/Detection"),MapillaryFetcher=_dereq_("./fetchers/Mapillary"),OpenStreetCamFetcher=_dereq_("./fetchers/OpenStreetCam"),WikiCommonsFetcher=_dereq_("./fetchers/WikiCommons"),MAPILLARY_CLIENT_ID="MLY|4186514921455326|31c8e0e5704a790a12cdb71c37dd4964",FLICKR_API_KEY="1567bc982f9ad3c6a60ce8c736c62809",EARTH_RADIUS=6371e3,DEFAULT_CAMERA_ANGLE=70,deg2rad=function(d){return d*(Math.PI/180)},PicturesManager=function(_EventLauncher){function PicturesManager(options){var _ret;_classCallCheck(this,PicturesManager);var _this=_possibleConstructorReturn(this,(PicturesManager.__proto__||Object.getPrototypeOf(PicturesManager)).call(this));options=options||{};var credentials={mapillary:{key:MAPILLARY_CLIENT_ID},flickr:{key:FLICKR_API_KEY}};if(_this.options=Object.assign({fetcherCredentials:credentials,userDefinedFetchers:null,useOnly:null,ignorefetchers:null,usefetchers:null},options),void 0!=options.fetcherCredentials&&(_this.options.fetcherCredentials=Object.assign(credentials,options.fetcherCredentials)),_this.fetchers={mapillary:new MapillaryFetcher(_this.options.fetcherCredentials.mapillary.key),flickr:new FlickrFetcher(_this.options.fetcherCredentials.flickr.key),openstreetcam:new OpenStreetCamFetcher,wikicommons:new WikiCommonsFetcher},null!==_this.options.userDefinedFetchers)for(var id in _this.options.userDefinedFetchers){var udf=_this.options.userDefinedFetchers[id];if(void 0!==_this.fetchers[id])throw new Error("Can't create user-defined fetcher "+id+": already exists");if(null==udf.csv||0==udf.csv.length)throw new Error("Can't create user-defined fetcher "+id+": invalid csv parameter (must be an URL)");if(void 0!==udf.bbox&&!udf.bbox instanceof LatLngBounds)throw new Error("Can't create user-defined fetcher "+id+": invalid bbox parameter (must be a LatLngBounds, or missing)");_this.fetchers[id]=new CSVFetcher(udf.csv,udf)}return _ret=_this,_possibleConstructorReturn(_this,_ret)}return _inherits(PicturesManager,_EventLauncher),_createClass(PicturesManager,[{key:"getFetcherDetails",value:function(){var details={};for(var f in this.fetchers)details[f]={name:this.fetchers[f].name,homepageUrl:this.fetchers[f].homepageUrl,logoUrl:this.fetchers[f].logoUrl};return details}},{key:"startPicsRetrieval",value:function(boundingBox,options){var _this2=this;options=Object.assign({mindate:null,maxdate:null,usefetchers:null,ignorefetchers:null},this.options,options),options.usefetchers&&options.ignorefetchers&&(options.ignorefetchers=null);var promises=[],_loop=function(fId){(null==options.usefetchers||options.usefetchers.indexOf(fId)>=0)&&(null==options.ignorefetchers||options.ignorefetchers.indexOf(fId)<0)&&promises.push(_this2.fetchers[fId].requestPictures(boundingBox,options).then(function(p){return _this2.fire("fetcherdone",fId),p},function(e){_this2.fire("fetcherfailed",fId),console.log(e)}))};for(var fId in this.fetchers)_loop(fId);if(0==promises.length)throw new Error("ctrl.picturesmanager.picsretrieval.nofetchersused");return Promise.all(promises).then(function(values){var prev=null,result=values.filter(function(a){return null!==a&&void 0!==a});return result.length>0&&(result=result.reduce(function(a,b){return a.concat(b)}).sort(function(a,b){return b.date-a.date}).filter(function(a){if(void 0==a)return!1;if(boundingBox.contains(a.coordinates)){if(null!=prev){var looklike=a.lookAlike(prev);return looklike||(prev=a),!looklike}return prev=a,!0}return!1})),result})}},{key:"startPicsRetrievalAround",value:function(center,radius,options){var _this3=this,deg2rad=function(deg){return deg*Math.PI/180},rad2deg=function(rad){return 180*rad/Math.PI},latRad=deg2rad(center.lat),radiusOnLat=Math.cos(latRad)*EARTH_RADIUS,deltaLat=rad2deg(radius/EARTH_RADIUS),deltaLon=rad2deg(radius/radiusOnLat),bbox=new LatLngBounds(new LatLng(center.lat-deltaLat,center.lng-deltaLon),new LatLng(center.lat+deltaLat,center.lng+deltaLon)),angle=options.cameraAngle&&!isNaN(options.cameraAngle)?parseInt(options.cameraAngle):DEFAULT_CAMERA_ANGLE;return options.towardscenter?this.startPicsRetrieval(bbox,options).then(function(pictures){return pictures.filter(function(p){return p.details.isSpherical||!isNaN(p.direction)&&_this3._canBeSeen(p.coordinates,center,p.direction,angle)})}):this.startPicsRetrieval(bbox,options)}},{key:"startSummaryRetrieval",value:function(boundingBox,options){var _this4=this;options=Object.assign({mindate:null,maxdate:null,usefetchers:null,ignorefetchers:null},this.options,options),options.usefetchers&&options.ignorefetchers&&(options.ignorefetchers=null);var promises=[],_loop2=function(fId){(null==options.usefetchers||options.usefetchers.indexOf(fId)>=0)&&(null==options.ignorefetchers||options.ignorefetchers.indexOf(fId)<0)&&promises.push(_this4.fetchers[fId].requestSummary(boundingBox,options).then(function(s){return _this4.fire("fetcherdone",fId),s},function(e){_this4.fire("fetcherfailed",fId),console.log(e)}))};for(var fId in this.fetchers)_loop2(fId);return Promise.all(promises).then(function(values){values=values.filter(function(v){return null!=v});var result={last:0,amount:0,approxAmount:!1};for(var s in values)values[s].last>result.last&&(result.last=values[s].last),result.approxAmount=result.approxAmount||">"==values[s].amount.charAt(0),result.amount+=parseInt(values[s].amount.substring(1));return result})}},{key:"startDetectionsRetrieval",value:function(boundingBox,options){var _this5=this;options=Object.assign({types:[],usefetchers:null,ignorefetchers:null},this.options,options),options.usefetchers&&options.ignorefetchers&&(options.ignorefetchers=null),null===options.usefetchers&&null===options.ignorefetchers&&(options.usefetchers=["mapillary"]);var promises=[],_loop3=function(fId){(null==options.usefetchers||options.usefetchers.indexOf(fId)>=0)&&(null==options.ignorefetchers||options.ignorefetchers.indexOf(fId)<0)&&promises.push(_this5.fetchers[fId].requestDetections(boundingBox,options).then(function(p){return _this5.fire("fetcherdone",fId),p},function(e){_this5.fire("fetcherfailed",fId),console.log(e)}))};for(var fId in this.fetchers)_loop3(fId);if(0==promises.length)throw new Error("ctrl.picturesmanager.detectionsretrieval.nofetchersused");return Promise.all(promises).then(function(values){var result=values.filter(function(a){return null!==a&&void 0!==a});return result.length>0&&(result=result.reduce(function(a,b){return a.concat(b)}).sort(function(a,b){return b.date-a.date}).filter(function(a){return void 0!=a&&!!boundingBox.contains(a.coordinates)})),options.asgeojson?{type:"FeatureCollection",features:result.map(function(f){return{type:"Feature",geometry:{type:"Point",coordinates:[f.coordinates.lng,f.coordinates.lat]},properties:Object.assign({},Detection.TYPE_DETAILS[f.type].osmTags,{"source:geometry":(_this5.fetchers[f.provider].name||f.provider)+" "+new Date(f.date).toISOString().split("T")[0]})}})}:result})}},{key:"getPicturesFromTags",value:function(tags){var _ref,_this6=this;return(_ref=[]).concat.apply(_ref,_toConsumableArray(Object.keys(this.fetchers).filter(function(k){return"flickr"!=k}).map(function(k){return _this6.fetchers[k].tagsToPictures(tags)})))}},{key:"_canBeSeen",value:function(start,end,startDirection,startOpening){var minDir=startDirection-startOpening/2;minDir<0&&(minDir+=360);var maxDir=startDirection+startOpening/2;maxDir<0&&(maxDir+=360);var dist=Math.sqrt(Math.pow(end.lat-start.lat,2)+Math.pow(end.lng-start.lng,2)),minCoord=new LatLng(dist*Math.cos(deg2rad(minDir))+start.lat,dist*Math.sin(deg2rad(minDir))+start.lng),maxCoord=new LatLng(dist*Math.cos(deg2rad(maxDir))+start.lat,dist*Math.sin(deg2rad(maxDir))+start.lng),bounds=new LatLngBounds(minCoord,maxCoord);return start.lat===end.lat?Math.abs(end.lng-minCoord.lng)<=dist&&bounds.getSouth()<end.lat&&bounds.getNorth()>end.lat:start.lng===end.lng?Math.abs(end.lat-minCoord.lat)<=dist&&bounds.getWest()<end.lng&&bounds.getEast()>end.lng:bounds.contains(end)}}]),PicturesManager}(EventLauncher);module.exports=PicturesManager},{"../model/Detection":50,"../model/LatLng":51,"../model/LatLngBounds":52,"./EventLauncher":42,"./fetchers/CSV":45,"./fetchers/Flickr":46,"./fetchers/Mapillary":47,"./fetchers/OpenStreetCam":48,"./fetchers/WikiCommons":49}],45:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Fetcher=_dereq_("../Fetcher"),LatLng=_dereq_("../../model/LatLng"),LatLngBounds=_dereq_("../../model/LatLngBounds"),Picture=_dereq_("../../model/Picture"),CSVParser=_dereq_("csv-parse/lib/sync"),kdbush=_dereq_("kdbush"),CSV=function(_Fetcher){function CSV(csv,options){_classCallCheck(this,CSV);var _this=_possibleConstructorReturn(this,(CSV.__proto__||Object.getPrototypeOf(CSV)).call(this));if(!("string"==typeof csv&&csv.length>0))throw new Error("ctrl.fetchers.csv.invalidcsvurl");return _this.csvURL=csv,_this.options=Object.assign({bbox:null,license:"Unknown license",user:"Unknown user"},options),_this.csv=null,_this.tree=null,_this.isDownloading=!1,_this}return _inherits(CSV,_Fetcher),_createClass(CSV,[{key:"requestPictures",value:function(boundingBox,options){var _this2=this;return new Promise(function(resolve,reject){options=options||{};var bbox=new LatLngBounds(boundingBox.getSouthWest().wrap(),boundingBox.getNorthEast().wrap());null===_this2.options.bbox||_this2.options.bbox.intersects(bbox)?_this2.getCSV().then(function(){var result=_this2.tree.range(bbox.getWest(),bbox.getSouth(),bbox.getEast(),bbox.getNorth()).map(function(id){return _this2.csv[id]}).filter(function(p){return(null==options.mindate||options.mindate<=1e3*p.timestamp)&&(null==options.maxdate||options.maxdate>=1e3*p.timestamp)}).map(function(p){return new Picture(p.picture_url,1e3*p.timestamp,new LatLng(p.latitude,p.longitude),_this2.name,p.user||_this2.options.user,p.license||_this2.options.license,p.details_url||p.picture_url,isNaN(p.direction)?null:parseInt(p.direction),{image:p.picture_url})});resolve(result)}).catch(reject):resolve([])})}},{key:"requestSummary",value:function(boundingBox,options){var _this3=this;return new Promise(function(resolve,reject){options=options||{};var bbox=new LatLngBounds(boundingBox.getSouthWest().wrap(),boundingBox.getNorthEast().wrap());null===_this3.options.bbox||_this3.options.bbox.intersects(bbox)?_this3.getCSV().then(function(){var last=null,count=0;_this3.tree.range(bbox.getWest(),bbox.getSouth(),bbox.getEast(),bbox.getNorth()).map(function(id){return _this3.csv[id]}).filter(function(p){return(null==options.mindate||options.mindate<=1e3*p.timestamp)&&(null==options.maxdate||options.maxdate>=1e3*p.timestamp)}).forEach(function(p){count++,(null===last||last<1e3*p.timestamp)&&(last=1e3*p.timestamp)}),resolve({last:last,amount:"e"+count,bbox:bbox.toBBoxString()})}).catch(reject):resolve({amount:"e0",bbox:bbox.toBBoxString()})})}},{key:"getCSV",value:function(){var _this4=this;return new Promise(function(resolve,reject){null!==_this4.tree?resolve():_this4.isDownloading?setTimeout(function(){_this4.getCSV().then(resolve)},100):(_this4.isDownloading=!0,_this4.ajax(_this4.csvURL,"csv").then(function(d){_this4.csv=CSVParser(d,{columns:!0,delimiter:";"}),_this4.tree=kdbush(_this4.csv,function(p){return parseFloat(p.longitude)},function(p){return parseFloat(p.latitude)}),resolve()}).catch(reject))})}},{key:"name",get:function(){return this.options&&this.options.name||"CSV Source"}},{key:"logoUrl",get:function(){return this.options&&this.options.logo||""}},{key:"homepageUrl",get:function(){return this.options&&this.options.homepage||""}}]),CSV}(Fetcher);module.exports=CSV},{"../../model/LatLng":51,"../../model/LatLngBounds":52,"../../model/Picture":53,"../Fetcher":43,"csv-parse/lib/sync":7,kdbush:13}],46:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Fetcher=_dereq_("../Fetcher"),LatLng=_dereq_("../../model/LatLng"),LatLngBounds=_dereq_("../../model/LatLngBounds"),Picture=_dereq_("../../model/Picture"),Flickr=function(_Fetcher){function Flickr(apiKey){_classCallCheck(this,Flickr);var _this=_possibleConstructorReturn(this,(Flickr.__proto__||Object.getPrototypeOf(Flickr)).call(this));if(!("string"==typeof apiKey&&apiKey.length>0))throw new Error("ctrl.fetchers.flickr.invalidapikey");return _this.apiKey=apiKey,_this}return _inherits(Flickr,_Fetcher),_createClass(Flickr,[{key:"requestPictures",value:function(boundingBox,options){var data=Object.assign({picsPerRequest:100,page:1,pictures:[],bbox:new LatLngBounds(boundingBox.getSouthWest().wrap(),boundingBox.getNorthEast().wrap())},this.options,options);return this.licenses?this.download(data):this.downloadLicenses(data)}},{key:"requestSummary",value:function(boundingBox,options){var _this2=this;options=Object.assign({},this.options,options);var url="https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key="+this.apiKey+(null!=options.mindate?"&min_taken_date="+new Date(options.mindate).toISOString().split("T")[0]:"")+(null!=options.maxdate?"&max_taken_date="+new Date(options.maxdate).toISOString().split("T")[0]:"")+"&bbox="+boundingBox.getWest()+"%2C"+boundingBox.getSouth()+"%2C"+boundingBox.getEast()+"%2C"+boundingBox.getNorth()+"&has_geo=1&per_page=1&license=4,5,7,8,9,10&format=json&nojsoncallback=1&extras=date_taken";return this.ajax(url,"json").then(function(data){return null!==data&&void 0!==data.photos&&void 0!==data.photos.total&&void 0!==data.photos.photo||_this2.fail(null,null,new Error("ctrl.fetcher.flickr.getsummaryfailed")),parseInt(data.photos.total)>0?{last:new Date(data.photos.photo[0].datetaken.replace(" ","T")).getTime(),amount:"e"+data.photos.total,bbox:boundingBox.toBBoxString()}:{amount:"e0",bbox:boundingBox.toBBoxString()}})}},{key:"downloadLicenses",value:function(info){var _this3=this;return this.ajax("https://api.flickr.com/services/rest/?method=flickr.photos.licenses.getInfo&api_key="+this.apiKey+"&format=json&nojsoncallback=1","json").then(function(d){if(_this3.licenses={},d.stat&&"ok"==d.stat&&d.licenses&&d.licenses.license){for(var i=0;i<d.licenses.license.length;i++){var lcs=d.licenses.license[i];_this3.licenses[lcs.id]=lcs.name}return _this3.download(info)}throw new Error("ctrl.fetcher.flickr.invalidlicensedata")})}},{key:"download",value:function(info){var _this4=this,licenseList=Object.keys(this.licenses).filter(function(v){return v>=4&&6!=v}),url="https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key="+this.apiKey+(null!=info.mindate?"&min_taken_date="+new Date(info.mindate).toISOString().split("T")[0]:"")+(null!=info.maxdate?"&max_taken_date="+new Date(info.maxdate).toISOString().split("T")[0]:"")+"&bbox="+info.bbox.getWest()+"%2C"+info.bbox.getSouth()+"%2C"+info.bbox.getEast()+"%2C"+info.bbox.getNorth()+"&has_geo=1&per_page="+info.picsPerRequest+"&page="+info.page+"&license="+licenseList.join(",")+"&format=json&nojsoncallback=1&extras=license%2Cdate_taken%2Cowner_name%2Cgeo%2Curl_l%2Curl_z";return this.ajax(url,"json").then(function(result){if(null===result||void 0===result.photos||void 0===result.photos.photo)throw new Error("ctrl.fetcher.flickr.getpicturesfailed");if(result.stat&&"ok"===result.stat&&result.photos.photo&&result.photos.photo.length>0){for(var i=0;i<result.photos.photo.length;i++){var pic=result.photos.photo[i];pic.url_l&&pic.datetaken&&pic.latitude&&pic.longitude&&pic.license>0&&info.pictures.push(new Picture(pic.url_l,new Date(pic.datetaken.replace(" ","T")).getTime(),new LatLng(pic.latitude,pic.longitude),_this4.name,pic.ownername,_this4.licenses[pic.license],"https://www.flickr.com/photos/"+pic.owner+"/"+pic.id,null,{flickr:"https://www.flickr.com/photos/"+pic.owner+"/"+pic.id},pic.url_z))}info.page=result.photos.photo.length==info.picsPerRequest?info.page+1:-1}else info.page=-1;return info.page>0?_this4.download(info):info.pictures})}},{key:"name",get:function(){return"Flickr"}},{key:"logoUrl",get:function(){return"https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Flickr_wordmark.svg/640px-Flickr_wordmark.svg.png"}},{key:"homepageUrl",get:function(){return"https://www.flickr.com/"}}]),Flickr}(Fetcher);module.exports=Flickr},{"../../model/LatLng":51,"../../model/LatLngBounds":52,"../../model/Picture":53,"../Fetcher":43}],47:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}var _DTC_TO_MPL,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Fetcher=_dereq_("../Fetcher"),LatLng=_dereq_("../../model/LatLng"),Picture=(_dereq_("../../model/LatLngBounds"),_dereq_("../../model/Picture")),Detection=_dereq_("../../model/Detection"),SphericalMercator=_dereq_("@mapbox/sphericalmercator"),DTC_TO_MPL=(_DTC_TO_MPL={},_defineProperty(_DTC_TO_MPL,Detection.OBJECT_BENCH,"object--bench"),_defineProperty(_DTC_TO_MPL,Detection.SIGN_STOP,["regulatory--stop--g1","regulatory--stop--g2","regulatory--stop--g3","regulatory--stop--g4","regulatory--stop--g5","regulatory--stop--g6","regulatory--stop--g7","regulatory--stop--g8","regulatory--stop--g9","regulatory--stop--g10"]),_defineProperty(_DTC_TO_MPL,Detection.MARK_CROSSING,["marking--discrete--crosswalk-zebra","construction--flat--crosswalk-plain"]),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_BICYCLE_PARKING,"object--bike-rack"),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_CCTV,["object--cctv-camera","information--camera--g1","information--camera--g2","information--camera--g3"]),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_HYDRANT,"object--fire-hydrant"),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_POSTBOX,"object--mailbox"),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_MANHOLE,"object--manhole"),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_PARKING_METER,"object--parking-meter"),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_PHONE,["object--phone-booth","information--telephone--g1","information--telephone--g2"]),_defineProperty(_DTC_TO_MPL,Detection.SIGN_ADVERT,"object--sign--advertisement"),_defineProperty(_DTC_TO_MPL,Detection.SIGN_INFO,"object--sign--information"),_defineProperty(_DTC_TO_MPL,Detection.SIGN_STORE,"object--sign--store"),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_STREET_LIGHT,"object--street-light"),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_POLE,"object--support--pole"),_defineProperty(_DTC_TO_MPL,Detection.OBJECT_UTILITY_POLE,"object--support--utility-pole"),_defineProperty(_DTC_TO_MPL,Detection.SIGN_RESERVED_PARKING,["regulatory--reserved-parking--g1","information--disabled-persons--g1","information--disabled-persons--g2","information--disabled-persons--g3","complementary--disabled-persons--g1"]),_defineProperty(_DTC_TO_MPL,Detection.SIGN_ANIMAL_CROSSING,["warning--camel-crossing--g1","warning--camel-crossing--g2","warning--domestic-animals--g1","warning--domestic-animals--g2","warning--domestic-animals--g3","warning--domestic-animals--g4","warning--domestic-animals--g5","warning--domestic-animals--g6","warning--domestic-animals--g7","warning--domestic-animals--g8","warning--elephant-crossing--g1","warning--frog-crossing--g1","warning--horse-crossing--g1","warning--kangaroo-crossing--g1","warning--kiwi-crossing--g1","warning--kiwi-crossing--g2","warning--koala-crossing--g1","warning--koala-crossing--g2","warning--koala-crossing--g3","warning--koala-crossing--g4","warning--monkey-crossing--g1","warning--panda-crossing--g1","warning--rabbit-crossing--g1","warning--raccoon-crossing--g1","warning--wild-animals--g1","warning--wild-animals--g2","warning--wild-animals--g3","warning--wild-animals--g4","warning--wild-animals--g5","warning--wild-animals--g6","warning--wild-animals--g7","warning--wild-animals--g8","warning--wombat-crossing--g1"]),_defineProperty(_DTC_TO_MPL,Detection.SIGN_RAILWAY_CROSSING,["warning--railroad-crossing-with-barriers--g1","warning--railroad-crossing-with-barriers--g2","warning--railroad-crossing-with-barriers--g3","warning--railroad-crossing-with-barriers--g4","warning--railroad-crossing-with-barriers--g5","warning--railroad-crossing-with-barriers--g6","warning--railroad-crossing-with-barriers--g7","warning--railroad-crossing-without-barriers--g1","warning--railroad-crossing-without-barriers--g2","warning--railroad-crossing-without-barriers--g3","warning--railroad-crossing-without-barriers--g4","warning--railroad-crossing-without-barriers--g5","warning--railroad-crossing-without-barriers--g6","warning--railroad-intersection--g1","warning--railroad-intersection--g2","warning--railroad-intersection--g3","warning--railroad-intersection--g4","warning--railroad-intersection--g5","warning--railroad-intersection--g6","warning--railroad-intersection--g7","warning--railroad-intersection--g8","warning--railroad-intersection--g9"]),_DTC_TO_MPL),MPL_TO_DTC={};Object.entries(DTC_TO_MPL).forEach(function(e){"string"==typeof e[1]?MPL_TO_DTC[e[1]]=parseInt(e[0]):e[1].forEach(function(v){MPL_TO_DTC[v]=parseInt(e[0])})});var Mapillary=function(_Fetcher){function Mapillary(clientId){_classCallCheck(this,Mapillary);var _this=_possibleConstructorReturn(this,(Mapillary.__proto__||Object.getPrototypeOf(Mapillary)).call(this));if(_this._merc=new SphericalMercator,!("string"==typeof clientId&&clientId.length>0))throw new Error("ctrl.fetchers.mapillary.invalidclientid");return _this.clientId=clientId,_this}return _inherits(Mapillary,_Fetcher),_createClass(Mapillary,[{key:"requestPictures",value:function(boundingBox){var _this2=this,options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},url="https://graph.mapillary.com/images?fields=id,camera_type,captured_at,computed_compass_angle,computed_geometry&bbox="+[boundingBox.getWest(),boundingBox.getSouth(),boundingBox.getEast(),boundingBox.getNorth()].join(",")+"&access_token="+this.clientId;return this.ajax(url,"json").then(function(res){if(!res||!res.data)return Promise.reject(new Error("ctrl.fetcher.mapillary.getpicturesfailed"));var images={};if(res.data.filter(function(pic){return(!options.mindate||new Date(pic.captured_at).getTime()>=options.mindate)&&(!options.maxdate||new Date(pic.captured_at).getTime()<=options.maxdate)}).forEach(function(pic){images[pic.id]=pic}),0===Object.keys(images).length)return[];var url2="https://graph.mapillary.com/images?image_ids="+Object.keys(images).join(",")+"&fields=fields=id,thumb_256_url,thumb_2048_url&access_token="+_this2.clientId;return _this2.ajax(url2,"json").then(function(res2){return res2&&res2.data?(res2.data.forEach(function(pic){images[pic.id].url=pic.thumb_2048_url,images[pic.id].thumb=pic.thumb_256_url}),Object.values(images).filter(function(pic){return pic.url&&pic.captured_at&&pic.computed_geometry}).map(function(pic){return new Picture(pic.url,new Date(pic.captured_at).getTime(),new LatLng(pic.computed_geometry.coordinates[1],pic.computed_geometry.coordinates[0]),_this2.name,"Mapillary contributor","CC By-SA 4.0","https://www.mapillary.com/app/?pKey="+pic.id+"&lat="+pic.computed_geometry.coordinates[1]+"&lng="+pic.computed_geometry.coordinates[0]+"&focus=photo",pic.computed_compass_angle,{mapillary:pic.id.toString()},pic.thumb,{isSpherical:"spherical"===pic.camera_type})})):Promise.reject(new Error("ctrl.fetcher.mapillary.getpicturesfailed"))})})}},{key:"requestSummary",value:function(boundingBox){var _this3=this,options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.requestPictures(boundingBox,options).then(function(pics){return pics.length>0?(pics.sort(function(a,b){return b.date-a.date}),{last:pics[0].date,amount:"e"+pics.length,bbox:boundingBox.toBBoxString()}):{amount:"e0",bbox:boundingBox.toBBoxString()}}).catch(function(e){console.error(e),_this3.fail(null,null,new Error("ctrl.fetcher.mapillary.getsummaryfailed"))})}},{key:"requestDetections",value:function(boundingBox){var options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},url="https://graph.mapillary.com/map_features?fields=id,object_value,last_seen_at,geometry&bbox="+[boundingBox.getWest(),boundingBox.getSouth(),boundingBox.getEast(),boundingBox.getNorth()].join(",")+(options.types?"&object_values="+options.types.map(function(ot){return"string"==typeof DTC_TO_MPL[ot]?DTC_TO_MPL[ot]:DTC_TO_MPL[ot].join(",")}).join(","):"")+"&access_token="+this.clientId;return this.ajax(url,"json").then(function(res){return res&&res.data?res.data.map(function(dtc){return new Detection(MPL_TO_DTC[dtc.object_value],new LatLng(dtc.geometry.coordinates[1],dtc.geometry.coordinates[0]),new Date(dtc.last_seen_at).getTime(),"mapillary");
|
||
}):Promise.reject(new Error("ctrl.fetcher.mapillary.getdetectionsfailed"))})}},{key:"tagsToPictures",value:function(tags){var result=[];return Object.keys(tags).filter(function(k){return k.startsWith("mapillary")}).forEach(function(k){tags[k].split(";").forEach(function(mid){/^[0-9A-Za-z_\-]{22}$/.test(mid.trim())&&result.push("https://images.mapillary.com/"+mid.trim()+"/thumb-2048.jpg")})}),result}},{key:"name",get:function(){return"Mapillary"}},{key:"logoUrl",get:function(){return"https://upload.wikimedia.org/wikipedia/commons/5/51/Mapillary_dotcompass_2019.png"}},{key:"homepageUrl",get:function(){return"https://www.mapillary.com/"}}]),Mapillary}(Fetcher);module.exports=Mapillary},{"../../model/Detection":50,"../../model/LatLng":51,"../../model/LatLngBounds":52,"../../model/Picture":53,"../Fetcher":43,"@mapbox/sphericalmercator":1}],48:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Fetcher=_dereq_("../Fetcher"),LatLng=_dereq_("../../model/LatLng"),LatLngBounds=_dereq_("../../model/LatLngBounds"),Picture=_dereq_("../../model/Picture"),API_URL="https://openstreetcam.org/1.0/",OpenStreetCam=function(_Fetcher){function OpenStreetCam(){return _classCallCheck(this,OpenStreetCam),_possibleConstructorReturn(this,(OpenStreetCam.__proto__||Object.getPrototypeOf(OpenStreetCam)).call(this))}return _inherits(OpenStreetCam,_Fetcher),_createClass(OpenStreetCam,[{key:"requestPictures",value:function(boundingBox,options){var data=Object.assign({picsPerRequest:100,page:0,pictures:[],bbox:new LatLngBounds(boundingBox.getSouthWest().wrap(),boundingBox.getNorthEast().wrap())},this.options,options);return this.download(data)}},{key:"requestSummary",value:function(boundingBox,options){var _this2=this;options=Object.assign({},this.options,options),options.bbox=boundingBox;var url=API_URL+"list/nearby-photos/",params={coordinate:boundingBox.getCenter().lat+","+boundingBox.getCenter().lng,radius:boundingBox.getNorthEast().distanceTo(boundingBox.getSouthWest())/2};return options.mindate&&(params.date=new Date(options.mindate).toISOString().split("T")[0]),this.ajaxPost(url,params,"json").then(function(data){if(null!==data&&void 0!==data.status&&"600"===data.status.apiCode||_this2.fail(null,null,new Error("ctrl.fetcher.openstreetcam.getsummaryfailed")),data.currentPageItems&&data.currentPageItems.length>0){data.currentPageItems.sort(function(a,b){return b.timestamp-a.timestamp});var amount=data.currentPageItems.length,last=1e3*data.currentPageItems[0].timestamp;if(options.maxdate&&last>options.maxdate)for(var i=0;i<data.currentPageItems.length&&last>options.maxdate;)i++,amount--,last=i<data.currentPageItems.length?1e3*data.currentPageItems[i].timestamp:0;return{last:last,amount:amount<1e3?"e"+amount:">1000",bbox:options.bbox.toBBoxString()}}return{amount:"e0",bbox:options.bbox.toBBoxString()}})}},{key:"tagsToPictures",value:function(tags){var result=[];return tags.image&&tags.image.split(";").forEach(function(img){(img.startsWith("http://")||img.startsWith("https://"))&&result.push(img)}),result}},{key:"download",value:function(data){var _this3=this,url=API_URL+"list/nearby-photos/",params={coordinate:data.bbox.getCenter().lat+","+data.bbox.getCenter().lng,radius:data.bbox.getNorthEast().distanceTo(data.bbox.getSouthWest())/2};return data.mindate&&(params.date=new Date(data.mindate).toISOString().split("T")[0]),this.ajaxPost(url,params,"json").then(function(result){if(null!==result&&void 0!==result.status&&"600"===result.status.apiCode||_this3.fail(null,null,new Error("ctrl.fetcher.openstreetcam.getpicturesfailed")),result.currentPageItems&&result.currentPageItems.length>0){result.currentPageItems.sort(function(a,b){return parseInt(a.timestamp)-parseInt(b.timestamp)});for(var i=0;i<result.currentPageItems.length;i++){var pic=result.currentPageItems[i],coords=new LatLng(pic.lat,pic.lng);if(data.bbox.contains(coords)&&(!data.maxdate||1e3*pic.timestamp<=data.maxdate)){var _url="https://"+pic.lth_name.replace(/^storage([0-9]+)\//,"storage$1.openstreetcam.org/");data.pictures.push(new Picture(_url,1e3*pic.timestamp,coords,_this3.name,pic.username,"CC By-SA 4.0","https://openstreetcam.org/details/"+pic.sequence_id+"/"+pic.sequence_index,pic.heading?parseFloat(pic.heading)<0?(parseFloat(pic.heading)+360)%360:parseFloat(pic.heading):null,{image:_url}))}}}return data.pictures})}},{key:"name",get:function(){return"OpenStreetCam"}},{key:"logoUrl",get:function(){return"https://wiki.openstreetmap.org/w/images/thumb/e/eb/Openstreetview-logo-camera.png/600px-Openstreetview-logo-camera.png"}},{key:"homepageUrl",get:function(){return"https://openstreetcam.org/"}}]),OpenStreetCam}(Fetcher);module.exports=OpenStreetCam},{"../../model/LatLng":51,"../../model/LatLngBounds":52,"../../model/Picture":53,"../Fetcher":43}],49:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Fetcher=_dereq_("../Fetcher"),LatLng=_dereq_("../../model/LatLng"),LatLngBounds=_dereq_("../../model/LatLngBounds"),Picture=_dereq_("../../model/Picture"),WikiCommons=function(_Fetcher){function WikiCommons(){return _classCallCheck(this,WikiCommons),_possibleConstructorReturn(this,(WikiCommons.__proto__||Object.getPrototypeOf(WikiCommons)).call(this))}return _inherits(WikiCommons,_Fetcher),_createClass(WikiCommons,[{key:"requestPictures",value:function(boundingBox,options){var data=Object.assign({picsPerRequest:100,continue:null,pictures:[],bbox:new LatLngBounds(boundingBox.getSouthWest().wrap(),boundingBox.getNorthEast().wrap())},this.options,options);return this.download(data)}},{key:"requestSummary",value:function(boundingBox,options){options=Object.assign({bbox:boundingBox},this.options,options);var url="https://commons.wikimedia.org/w/api.php?action=query&format=json&origin=*&prop=coordinates|imageinfo&generator=geosearch&iiprop=timestamp|user|url|extmetadata|metadata|size&iiextmetadatafilter=LicenseShortName&ggsbbox="+boundingBox.getNorth()+"|"+boundingBox.getWest()+"|"+boundingBox.getSouth()+"|"+boundingBox.getEast()+"&ggslimit=100&iilimit=99&colimit=99&ggsnamespace=6&&iimetadataversion=latest";return this.ajax(url,"json").then(function(data){if(data.query){if(data.query.pages&&Object.keys(data.query.pages).length>0){var lastDate=null,picAmount=0;for(var picId in data.query.pages){var pic=data.query.pages[picId];if(pic.imageinfo&&pic.imageinfo.length>0&&pic.coordinates&&pic.coordinates.length>0&&pic.imageinfo[0].url&&pic.imageinfo[0].timestamp&&pic.coordinates[0].lat&&pic.coordinates[0].lon&&pic.imageinfo[0].user&&pic.imageinfo[0].extmetadata.LicenseShortName){var date=null;if(pic.imageinfo[0].metadata&&pic.imageinfo[0].metadata.length>0)for(var mdId=0;mdId<pic.imageinfo[0].metadata.length&&null==date;){if("DateTime"==pic.imageinfo[0].metadata[mdId].name){var ts=pic.imageinfo[0].metadata[mdId].value;ts.match(/^[0-9]{4}:[0-9]{2}:[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/)&&(ts=ts.replace(/^([0-9]{4}):([0-9]{2}):([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/,"$1-$2-$3T$4:$5:$6Z"),date=new Date(ts).getTime())}mdId++}null==date&&(date=new Date(pic.imageinfo[0].timestamp).getTime()),!isNaN(date)&&(null==options.mindate||date>=options.mindate)&&(null==options.maxdate||date<=options.maxdate)&&(picAmount++,(null==lastDate||lastDate<=date)&&(lastDate=date))}}return picAmount>0?{last:lastDate,amount:">"+picAmount,bbox:options.bbox.toBBoxString()}:{amount:"e0",bbox:options.bbox.toBBoxString()}}return{amount:"e0",bbox:options.bbox.toBBoxString()}}if(""===data.batchcomplete)return{amount:"e0",bbox:options.bbox.toBBoxString()};throw new Error("ctrl.fetcher.wikicommons.getlightfailed")})}},{key:"tagsToPictures",value:function(tags){var _this2=this,result=[];return tags.wikimedia_commons&&tags.wikimedia_commons.split(";").forEach(function(pic){if(pic.startsWith("File:")){var wmid=pic.substring(5).replace(/ /g,"_"),digest=_this2._md5(wmid),url="https://upload.wikimedia.org/wikipedia/commons/"+digest[0]+"/"+digest[0]+digest[1]+"/"+encodeURIComponent(wmid);result.push(_this2.toThumbURL(url))}}),result}},{key:"download",value:function(info){var _this3=this,url="https://commons.wikimedia.org/w/api.php?action=query&format=json&origin=*&prop=coordinates|imageinfo&continue="+(info.continue&&info.continue.continue?info.continue.continue:"")+(info.continue&&info.continue.cocontinue?"&cocontinue="+info.continue.cocontinue:"")+"&generator=geosearch&iiprop=timestamp|user|url|extmetadata|metadata|size&iiextmetadatafilter=LicenseShortName&ggsbbox="+info.bbox.getNorth()+"|"+info.bbox.getWest()+"|"+info.bbox.getSouth()+"|"+info.bbox.getEast()+"&ggslimit="+info.picsPerRequest+"&iilimit="+(info.picsPerRequest-1)+"&colimit="+(info.picsPerRequest-1)+"&ggsnamespace=6&&iimetadataversion=latest";return this.ajax(url,"json").then(function(result){if(result.query&&result.query.pages&&Object.keys(result.query.pages).length>0){for(var picId in result.query.pages){var pic=result.query.pages[picId];if(pic.imageinfo&&pic.imageinfo.length>0&&pic.coordinates&&pic.coordinates.length>0&&pic.imageinfo[0].url&&pic.imageinfo[0].timestamp&&pic.coordinates[0].lat&&pic.coordinates[0].lon&&pic.imageinfo[0].user&&pic.imageinfo[0].extmetadata.LicenseShortName){var date=null;if(pic.imageinfo[0].metadata&&pic.imageinfo[0].metadata.length>0)for(var mdId=0;mdId<pic.imageinfo[0].metadata.length&&null==date;){if("DateTime"==pic.imageinfo[0].metadata[mdId].name){var ts=pic.imageinfo[0].metadata[mdId].value;ts.match(/^[0-9]{4}:[0-9]{2}:[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/)&&(ts=ts.replace(/^([0-9]{4}):([0-9]{2}):([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/,"$1-$2-$3T$4:$5:$6Z"),date=new Date(ts).getTime())}mdId++}null==date&&(date=new Date(pic.imageinfo[0].timestamp).getTime()),!isNaN(date)&&(null==info.mindate||date>=info.mindate)&&(null==info.maxdate||date<=info.maxdate)&&info.pictures.push(new Picture(pic.imageinfo[0].width&&pic.imageinfo[0].width>1024?_this3.toThumbURL(pic.imageinfo[0].url):pic.imageinfo[0].url,date,new LatLng(pic.coordinates[0].lat,pic.coordinates[0].lon),_this3.name,pic.imageinfo[0].user,pic.imageinfo[0].extmetadata.LicenseShortName.value,pic.imageinfo[0].descriptionurl,null,{wikimedia_commons:pic.title},_this3.toThumbURL(pic.imageinfo[0].url,640)))}}info.continue=result.continue&&(result.continue.cocontinue||result.continue.continue)?result.continue:null}else info.continue=null;return null!==info.continue?_this3.download(info):info.pictures})}},{key:"toThumbURL",value:function(url,size){size=size||1024;var rgx=/^(.+wikipedia\/commons)\/([a-zA-Z0-9]\/[a-zA-Z0-9]{2})\/(.+)$/,rgxRes=rgx.exec(url);return rgxRes[1]+"/thumb/"+rgxRes[2]+"/"+rgxRes[3]+"/"+size+"px-"+rgxRes[3]}},{key:"_md5",value:function(str){var xl=void 0,rotateLeft=function(lValue,iShiftBits){return lValue<<iShiftBits|lValue>>>32-iShiftBits},addUnsigned=function(lX,lY){var lX4=void 0,lY4=void 0,lX8=void 0,lY8=void 0,lResult=void 0;return lX8=2147483648&lX,lY8=2147483648&lY,lX4=1073741824&lX,lY4=1073741824&lY,lResult=(1073741823&lX)+(1073741823&lY),lX4&lY4?2147483648^lResult^lX8^lY8:lX4|lY4?1073741824&lResult?3221225472^lResult^lX8^lY8:1073741824^lResult^lX8^lY8:lResult^lX8^lY8},_F=function(x,y,z){return x&y|~x&z},_G=function(x,y,z){return x&z|y&~z},_H=function(x,y,z){return x^y^z},_I=function(x,y,z){return y^(x|~z)},_FF=function(a,b,c,d,x,s,ac){return a=addUnsigned(a,addUnsigned(addUnsigned(_F(b,c,d),x),ac)),addUnsigned(rotateLeft(a,s),b)},_GG=function(a,b,c,d,x,s,ac){return a=addUnsigned(a,addUnsigned(addUnsigned(_G(b,c,d),x),ac)),addUnsigned(rotateLeft(a,s),b)},_HH=function(a,b,c,d,x,s,ac){return a=addUnsigned(a,addUnsigned(addUnsigned(_H(b,c,d),x),ac)),addUnsigned(rotateLeft(a,s),b)},_II=function(a,b,c,d,x,s,ac){return a=addUnsigned(a,addUnsigned(addUnsigned(_I(b,c,d),x),ac)),addUnsigned(rotateLeft(a,s),b)},convertToWordArray=function(str){for(var lWordCount=void 0,lMessageLength=str.length,lNumberOfWords_temp1=lMessageLength+8,lNumberOfWords_temp2=(lNumberOfWords_temp1-lNumberOfWords_temp1%64)/64,lNumberOfWords=16*(lNumberOfWords_temp2+1),lWordArray=new Array(lNumberOfWords-1),lBytePosition=0,lByteCount=0;lByteCount<lMessageLength;)lWordCount=(lByteCount-lByteCount%4)/4,lBytePosition=lByteCount%4*8,lWordArray[lWordCount]=lWordArray[lWordCount]|str.charCodeAt(lByteCount)<<lBytePosition,lByteCount++;return lWordCount=(lByteCount-lByteCount%4)/4,lBytePosition=lByteCount%4*8,lWordArray[lWordCount]=lWordArray[lWordCount]|128<<lBytePosition,lWordArray[lNumberOfWords-2]=lMessageLength<<3,lWordArray[lNumberOfWords-1]=lMessageLength>>>29,lWordArray},wordToHex=function(lValue){var wordToHexValue="",wordToHexValue_temp="",lByte=void 0,lCount=void 0;for(lCount=0;lCount<=3;lCount++)lByte=lValue>>>8*lCount&255,wordToHexValue_temp="0"+lByte.toString(16),wordToHexValue+=wordToHexValue_temp.substr(wordToHexValue_temp.length-2,2);return wordToHexValue},x=[],k=void 0,AA=void 0,BB=void 0,CC=void 0,DD=void 0,a=void 0,b=void 0,c=void 0,d=void 0,S11=7,S12=12,S13=17,S14=22,S21=5,S22=9,S23=14,S24=20,S31=4,S32=11,S33=16,S34=23,S41=6,S42=10,S43=15,S44=21;for(str=this._utf8_encode(str),x=convertToWordArray(str),a=1732584193,b=4023233417,c=2562383102,d=271733878,xl=x.length,k=0;k<xl;k+=16)AA=a,BB=b,CC=c,DD=d,a=_FF(a,b,c,d,x[k+0],S11,3614090360),d=_FF(d,a,b,c,x[k+1],S12,3905402710),c=_FF(c,d,a,b,x[k+2],S13,606105819),b=_FF(b,c,d,a,x[k+3],S14,3250441966),a=_FF(a,b,c,d,x[k+4],S11,4118548399),d=_FF(d,a,b,c,x[k+5],S12,1200080426),c=_FF(c,d,a,b,x[k+6],S13,2821735955),b=_FF(b,c,d,a,x[k+7],S14,4249261313),a=_FF(a,b,c,d,x[k+8],S11,1770035416),d=_FF(d,a,b,c,x[k+9],S12,2336552879),c=_FF(c,d,a,b,x[k+10],S13,4294925233),b=_FF(b,c,d,a,x[k+11],S14,2304563134),a=_FF(a,b,c,d,x[k+12],S11,1804603682),d=_FF(d,a,b,c,x[k+13],S12,4254626195),c=_FF(c,d,a,b,x[k+14],S13,2792965006),b=_FF(b,c,d,a,x[k+15],S14,1236535329),a=_GG(a,b,c,d,x[k+1],S21,4129170786),d=_GG(d,a,b,c,x[k+6],S22,3225465664),c=_GG(c,d,a,b,x[k+11],S23,643717713),b=_GG(b,c,d,a,x[k+0],S24,3921069994),a=_GG(a,b,c,d,x[k+5],S21,3593408605),d=_GG(d,a,b,c,x[k+10],S22,38016083),c=_GG(c,d,a,b,x[k+15],S23,3634488961),b=_GG(b,c,d,a,x[k+4],S24,3889429448),a=_GG(a,b,c,d,x[k+9],S21,568446438),d=_GG(d,a,b,c,x[k+14],S22,3275163606),c=_GG(c,d,a,b,x[k+3],S23,4107603335),b=_GG(b,c,d,a,x[k+8],S24,1163531501),a=_GG(a,b,c,d,x[k+13],S21,2850285829),d=_GG(d,a,b,c,x[k+2],S22,4243563512),c=_GG(c,d,a,b,x[k+7],S23,1735328473),b=_GG(b,c,d,a,x[k+12],S24,2368359562),a=_HH(a,b,c,d,x[k+5],S31,4294588738),d=_HH(d,a,b,c,x[k+8],S32,2272392833),c=_HH(c,d,a,b,x[k+11],S33,1839030562),b=_HH(b,c,d,a,x[k+14],S34,4259657740),a=_HH(a,b,c,d,x[k+1],S31,2763975236),d=_HH(d,a,b,c,x[k+4],S32,1272893353),c=_HH(c,d,a,b,x[k+7],S33,4139469664),b=_HH(b,c,d,a,x[k+10],S34,3200236656),a=_HH(a,b,c,d,x[k+13],S31,681279174),d=_HH(d,a,b,c,x[k+0],S32,3936430074),c=_HH(c,d,a,b,x[k+3],S33,3572445317),b=_HH(b,c,d,a,x[k+6],S34,76029189),a=_HH(a,b,c,d,x[k+9],S31,3654602809),d=_HH(d,a,b,c,x[k+12],S32,3873151461),c=_HH(c,d,a,b,x[k+15],S33,530742520),b=_HH(b,c,d,a,x[k+2],S34,3299628645),a=_II(a,b,c,d,x[k+0],S41,4096336452),d=_II(d,a,b,c,x[k+7],S42,1126891415),c=_II(c,d,a,b,x[k+14],S43,2878612391),b=_II(b,c,d,a,x[k+5],S44,4237533241),a=_II(a,b,c,d,x[k+12],S41,1700485571),d=_II(d,a,b,c,x[k+3],S42,2399980690),c=_II(c,d,a,b,x[k+10],S43,4293915773),b=_II(b,c,d,a,x[k+1],S44,2240044497),a=_II(a,b,c,d,x[k+8],S41,1873313359),d=_II(d,a,b,c,x[k+15],S42,4264355552),c=_II(c,d,a,b,x[k+6],S43,2734768916),b=_II(b,c,d,a,x[k+13],S44,1309151649),a=_II(a,b,c,d,x[k+4],S41,4149444226),d=_II(d,a,b,c,x[k+11],S42,3174756917),c=_II(c,d,a,b,x[k+2],S43,718787259),b=_II(b,c,d,a,x[k+9],S44,3951481745),a=addUnsigned(a,AA),b=addUnsigned(b,BB),c=addUnsigned(c,CC),d=addUnsigned(d,DD);var temp=wordToHex(a)+wordToHex(b)+wordToHex(c)+wordToHex(d);return temp.toLowerCase()}},{key:"_utf8_encode",value:function(argString){if(null===argString||"undefined"==typeof argString)return"";var string=argString+"",utftext="",start=void 0,end=void 0,stringl=0;start=end=0,stringl=string.length;for(var n=0;n<stringl;n++){var c1=string.charCodeAt(n),enc=null;if(c1<128)end++;else if(c1>127&&c1<2048)enc=String.fromCharCode(c1>>6|192,63&c1|128);else if(55296!=(63488&c1))enc=String.fromCharCode(c1>>12|224,c1>>6&63|128,63&c1|128);else{if(55296!=(64512&c1))throw new RangeError("Unmatched trail surrogate at "+n);var c2=string.charCodeAt(++n);if(56320!=(64512&c2))throw new RangeError("Unmatched lead surrogate at "+(n-1));c1=((1023&c1)<<10)+(1023&c2)+65536,enc=String.fromCharCode(c1>>18|240,c1>>12&63|128,c1>>6&63|128,63&c1|128)}null!==enc&&(end>start&&(utftext+=string.slice(start,end)),utftext+=enc,start=end=n+1)}return end>start&&(utftext+=string.slice(start,stringl)),utftext}},{key:"name",get:function(){return"Wikimedia Commons"}},{key:"logoUrl",get:function(){return"https://commons.wikimedia.org/static/images/project-logos/commonswiki.png"}},{key:"homepageUrl",get:function(){return"https://commons.wikimedia.org"}}]),WikiCommons}(Fetcher);module.exports=WikiCommons},{"../../model/LatLng":51,"../../model/LatLngBounds":52,"../../model/Picture":53,"../Fetcher":43}],50:[function(_dereq_,module,exports){"use strict";function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _Detection$TYPE_DETAI,Detection=function Detection(type,coordinates,date,provider){if(_classCallCheck(this,Detection),"number"!=typeof type||type<0)throw new Error("model.detection.invalid.type");if(null===coordinates||void 0===coordinates||"number"!=typeof coordinates.lat||"number"!=typeof coordinates.lng)throw new Error("model.detection.invalid.coordinates");if("number"!=typeof date||isNaN(date))throw new Error("model.detection.invalid.date");try{new Date(date)}catch(e){throw new Error("model.detection.invalid.date")}if("string"!=typeof provider||0===provider.length)throw new Error("model.detection.invalid.provider");this.type=type,this.coordinates=coordinates,this.date=date,this.provider=provider};Detection.OBJECT_BENCH=1,Detection.SIGN_STOP=2,Detection.MARK_CROSSING=3,Detection.OBJECT_BICYCLE_PARKING=4,Detection.OBJECT_CCTV=5,Detection.OBJECT_HYDRANT=6,Detection.OBJECT_POSTBOX=7,Detection.OBJECT_MANHOLE=8,Detection.OBJECT_PARKING_METER=9,Detection.OBJECT_PHONE=10,Detection.SIGN_ADVERT=11,Detection.SIGN_INFO=12,Detection.SIGN_STORE=13,Detection.OBJECT_STREET_LIGHT=14,Detection.OBJECT_POLE=15,Detection.OBJECT_UTILITY_POLE=19,Detection.SIGN_RESERVED_PARKING=16,Detection.SIGN_ANIMAL_CROSSING=17,Detection.SIGN_RAILWAY_CROSSING=18,Detection.TYPE_DETAILS=(_Detection$TYPE_DETAI={},_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_BENCH,{name:"Bench",osmTags:{amenity:"bench"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Garden_bench_001.jpg/320px-Garden_bench_001.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.SIGN_STOP,{name:"Stop sign",osmTags:{traffic_sign:"stop"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Vienna_Convention_road_sign_B2a.svg/320px-Vienna_Convention_road_sign_B2a.svg.png"}),_defineProperty(_Detection$TYPE_DETAI,Detection.MARK_CROSSING,{name:"Pedestrian crossing",osmTags:{highway:"crossing"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/3/37/A_closeup_of_Pedastrian_cross.JPG/320px-A_closeup_of_Pedastrian_cross.JPG"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_BICYCLE_PARKING,{name:"Bicycle parking",osmTags:{amenity:"bicycle_parking"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/AlewifeBikeParking.agr.2001.JPG/320px-AlewifeBikeParking.agr.2001.JPG"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_CCTV,{name:"CCTV camera",osmTags:{man_made:"surveillance"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/AxisCCTV.jpg/320px-AxisCCTV.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_HYDRANT,{name:"Fire hydrant",osmTags:{emergency:"fire_hydrant","fire_hydrant:type":"pillar"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Brandkraan.jpg/320px-Brandkraan.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_POSTBOX,{name:"Post box",osmTags:{amenity:"post_box"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Mt_Abu_mailbox.jpg/320px-Mt_Abu_mailbox.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_MANHOLE,{name:"Manhole",osmTags:{manhole:"unknown"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/French_Quater_New_Orleans_Curious_Lid_NIOPSI.jpg/320px-French_Quater_New_Orleans_Curious_Lid_NIOPSI.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_PARKING_METER,{name:"Parking meter",osmTags:{amenity:"vending_machine",vending:"parking_tickets"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/f2/Riga_%2813.08.2011%29_405.JPG/320px-Riga_%2813.08.2011%29_405.JPG"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_PHONE,{name:"Telephone (public/emergency)",osmTags:{amenity:"telephone"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/Telefono_publico_venezolano_2012_000.jpg/320px-Telefono_publico_venezolano_2012_000.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.SIGN_ADVERT,{name:"Advert sign",osmTags:{advertising:"sign"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/The_Chevron_sign_of_excellence%2C_Chevron_Motoroils%2C_enamel_advertising_sign.JPG/320px-The_Chevron_sign_of_excellence%2C_Chevron_Motoroils%2C_enamel_advertising_sign.JPG"}),_defineProperty(_Detection$TYPE_DETAI,Detection.SIGN_INFO,{name:"Information sign",osmTags:{advertising:"board"},symbol:"https://wiki.openstreetmap.org/w/images/thumb/f/fc/IMG_6076.JPG/320px-IMG_6076.JPG"}),_defineProperty(_Detection$TYPE_DETAI,Detection.SIGN_STORE,{name:"Store sign",osmTags:{advertising:"sign"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/Kruidvat_store_sign%2C_Winschoten_%282019%29_01.jpg/320px-Kruidvat_store_sign%2C_Winschoten_%282019%29_01.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_STREET_LIGHT,{name:"Street light",osmTags:{highway:"street_lamp"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Rome_(Italy)%2C_street_light_--_2013_--_3484.jpg/320px-Rome_(Italy)%2C_street_light_--_2013_--_3484.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_POLE,{name:"Pole",osmTags:{power:"pole"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/Rusty_can_on_a_public_pole%2C_Winschoten_%282019%29_01.jpg/270px-Rusty_can_on_a_public_pole%2C_Winschoten_%282019%29_01.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.OBJECT_UTILITY_POLE,{name:"Utility pole",osmTags:{man_made:"utility_pole"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Top_of_power_line_pole_-_east_side.jpg/320px-Top_of_power_line_pole_-_east_side.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.SIGN_RESERVED_PARKING,{name:"Reserved parking",osmTags:{amenity:"parking_space","capacity:disabled":1},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Reserved_Parking_disabled_persons.jpg/320px-Reserved_Parking_disabled_persons.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.SIGN_ANIMAL_CROSSING,{name:"Animal crossing sign",osmTags:{hazard:"animal_crossing"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/Animal_crossing_sign.jpg/320px-Animal_crossing_sign.jpg"}),_defineProperty(_Detection$TYPE_DETAI,Detection.SIGN_RAILWAY_CROSSING,{name:"Railway crossing sign",osmTags:{railway:"level_crossing"},symbol:"https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/France_road_sign_A8.svg/320px-France_road_sign_A8.svg.png"}),_Detection$TYPE_DETAI),module.exports=Detection},{}],51:[function(_dereq_,module,exports){"use strict";var LatLng=function LatLng(lat,lng,alt){if((!(lat instanceof LatLng||lat&&lat.length&&2==lat.length||lat.lat&&lat.lng)||void 0!==lng)&&(isNaN(lat)||isNaN(lng)))throw new Error("Invalid LatLng object: ("+lat+", "+lng+")");lat instanceof LatLng||lat.lat&&lat.lng?(this.lat=lat.lat,this.lng=lat.lng,this.alt=lat.alt):2==lat.length?(this.lat=lat[0],this.lng=lat[1]):(this.lat=+lat,this.lng=+lng,void 0!==alt&&(this.alt=+alt))};LatLng.prototype={equals:function(obj,maxMargin){if(!obj)return!1;obj=new LatLng(obj);var margin=Math.max(Math.abs(this.lat-obj.lat),Math.abs(this.lng-obj.lng));return margin<=(void 0===maxMargin?1e-9:maxMargin)},toString:function(precision){return"LatLng("+this.lat+", "+this.lng+")"},wrap:function(){for(var lng=this.lng;lng<-180;)lng+=360;for(;lng>180;)lng-=360;for(var lat=this.lat;lat<-90;)lat+=180;for(;lat>90;)lat-=180;return new LatLng(lat,lng,this.alt)},toBounds:function(sizeInMeters){var latAccuracy=180*sizeInMeters/40075017,lngAccuracy=latAccuracy/Math.cos(Math.PI/180*this.lat);return L.latLngBounds([this.lat-latAccuracy,this.lng-lngAccuracy],[this.lat+latAccuracy,this.lng+lngAccuracy])},clone:function(){return new LatLng(this.lat,this.lng,this.alt)},distanceTo:function(other){var rad=Math.PI/180,lat1=this.lat*rad,lat2=other.lat*rad,a=Math.sin(lat1)*Math.sin(lat2)+Math.cos(lat1)*Math.cos(lat2)*Math.cos((other.lng-this.lng)*rad);return 6371e3*Math.acos(Math.min(a,1))}},module.exports=LatLng},{}],52:[function(_dereq_,module,exports){"use strict";var LatLng=_dereq_("./LatLng"),LatLngBounds=function LatLngBounds(corner1,corner2){if(corner1){var latlngs=corner2?[corner1,corner2]:corner1;if(corner1 instanceof LatLngBounds)this._southWest=corner1._southWest,this._northEast=corner1._northEast;else for(var i=0,len=latlngs.length;i<len;i++)this.extend(latlngs[i])}};LatLngBounds.prototype={extend:function(obj){var sw2,ne2,sw=this._southWest,ne=this._northEast;if(obj instanceof LatLng)sw2=obj,ne2=obj;else if(obj instanceof LatLngBounds){if(sw2=obj._southWest,ne2=obj._northEast,!sw2||!ne2)return this}else{if(!obj||!obj.length||2!=obj.length)return obj?this.extend(new LatLng(obj)||new LatLngBounds(obj)):this;sw2=new LatLng(obj[0],obj[1]),ne2=sw2}return sw||ne?(sw.lat=Math.min(sw2.lat,sw.lat),sw.lng=Math.min(sw2.lng,sw.lng),ne.lat=Math.max(ne2.lat,ne.lat),ne.lng=Math.max(ne2.lng,ne.lng)):(this._southWest=new LatLng(sw2.lat,sw2.lng),this._northEast=new LatLng(ne2.lat,ne2.lng)),this},pad:function(bufferRatio){var sw=this._southWest,ne=this._northEast,heightBuffer=Math.abs(sw.lat-ne.lat)*bufferRatio,widthBuffer=Math.abs(sw.lng-ne.lng)*bufferRatio;return new LatLngBounds(new LatLng(sw.lat-heightBuffer,sw.lng-widthBuffer),new LatLng(ne.lat+heightBuffer,ne.lng+widthBuffer))},getCenter:function(){return new LatLng((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new LatLng(this.getNorth(),this.getWest())},getSouthEast:function(){return new LatLng(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(obj){obj="number"==typeof obj[0]||obj instanceof LatLng||"lat"in obj?new LatLng(obj):new LatLngBounds(obj);var sw2,ne2,sw=this._southWest,ne=this._northEast;return obj instanceof LatLngBounds?(sw2=obj.getSouthWest(),ne2=obj.getNorthEast()):sw2=ne2=obj,sw2.lat>=sw.lat&&ne2.lat<=ne.lat&&sw2.lng>=sw.lng&&ne2.lng<=ne.lng},intersects:function(bounds){bounds=new LatLngBounds(bounds);var sw=this._southWest,ne=this._northEast,sw2=bounds.getSouthWest(),ne2=bounds.getNorthEast(),latIntersects=ne2.lat>=sw.lat&&sw2.lat<=ne.lat,lngIntersects=ne2.lng>=sw.lng&&sw2.lng<=ne.lng;return latIntersects&&lngIntersects},overlaps:function(bounds){bounds=new LatLngBounds(bounds);var sw=this._southWest,ne=this._northEast,sw2=bounds.getSouthWest(),ne2=bounds.getNorthEast(),latOverlaps=ne2.lat>sw.lat&&sw2.lat<ne.lat,lngOverlaps=ne2.lng>sw.lng&&sw2.lng<ne.lng;return latOverlaps&&lngOverlaps},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(bounds){return!!bounds&&(bounds=new LatLngBounds(bounds),this._southWest.equals(bounds.getSouthWest())&&this._northEast.equals(bounds.getNorthEast()))},isValid:function(){return!(!this._southWest||!this._northEast)}},module.exports=LatLngBounds},{"./LatLng":51}],53:[function(_dereq_,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Picture=function(){function Picture(pictureUrl,date,coords,provider,author,license,detailsUrl,direction,osmTags,thumbUrl,details){if(_classCallCheck(this,Picture),!("string"==typeof pictureUrl&&pictureUrl.length>0))throw new Error("model.picture.invalid.pictureUrl");if(this.pictureUrl=pictureUrl,"number"!=typeof date||isNaN(date))throw new Error("model.picture.invalid.date");try{new Date(date),this.date=date}catch(e){
|
||
throw new Error("model.picture.invalid.date")}if(null===coords||void 0===coords||"number"!=typeof coords.lat||"number"!=typeof coords.lng)throw new Error("model.picture.invalid.coords");if(this.coordinates=coords,!("string"==typeof provider&&provider.length>0))throw new Error("model.picture.invalid.provider");this.provider=provider,this.author=author||null,this.license=license||null,this.detailsUrl=detailsUrl||null,this.direction="number"==typeof direction&&direction>=0&&direction<360?direction:null,this.osmTags=osmTags||null,this.thumbUrl=thumbUrl||null,this.details=details||{}}return _createClass(Picture,[{key:"lookAlike",value:function(other){return this.coordinates.equals(other.coordinates)&&this.date===other.date&&this.direction===other.direction}}]),Picture}();module.exports=Picture},{}]},{},[40])(40)});
|