PageSourceSearch

https://www.o-p-i.fr/aupays/wp-content/plugins/w2dc/core/resources/js/supercluster.min.js?ver=3.2.1

js o-p-i.fr collected 2026-09-24 21:11:38 UTC 12,756 bytes, 1 lines download raw bytes

vendor: 5,549 bytes, line 1
1!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):(global="undefined"!=typeof globalThis?globalThis:global||self).Supercluster=factory()}(this,(function(){"use strict";const ARRAY_TYPES=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class KDBush{static from(data){if(!(data instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[magic,versionAndType]=new Uint8Array(data,0,2);if(219!==magic)throw new Error("Data does not appear to be in a KDBush format.");const version=versionAndType>>4;if(1!==version)throw new Error(`Got v${version} data when expected v1.`);const ArrayType=ARRAY_TYPES[15&versionAndType];if(!ArrayType)throw new Error("Unrecognized array type.");const[nodeSize]=new Uint16Array(data,2,1),[numItems]=new Uint32Array(data,4,1);return new KDBush(numItems,nodeSize,ArrayType,data)}constructor(numItems,nodeSize=64,ArrayType=Float64Array,data){if(isNaN(numItems)||numItems<=0)throw new Error(`Unpexpected numItems value: ${numItems}.`);this.numItems=+numItems,this.nodeSize=Math.min(Math.max(+nodeSize,2),65535),this.ArrayType=ArrayType,this.IndexArrayType=numItems<65536?Uint16Array:Uint32Array;const arrayTypeIndex=ARRAY_TYPES.indexOf(this.ArrayType),coordsByteSize=2*numItems*this.ArrayType.BYTES_PER_ELEMENT,idsByteSize=numItems*this.IndexArrayType.BYTES_PER_ELEMENT,padCoords=(8-idsByteSize%8)%8;if(arrayTypeIndex<0)throw new Error(`Unexpected typed array class: ${ArrayType}.`);data&&data instanceof ArrayBuffer?(this.data=data,this.ids=new this.IndexArrayType(this.data,8,numItems),this.coords=new this.ArrayType(this.data,8+idsByteSize+padCoords,2*numItems),this._pos=2*numItems,this._finished=!0):(this.data=new ArrayBuffer(8+coordsByteSize+idsByteSize+padCoords),this.ids=new this.IndexArrayType(this.data,8,numItems),this.coords=new this.ArrayType(this.data,8+idsByteSize+padCoords,2*numItems),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+arrayTypeIndex]),new Uint16Array(this.data,2,1)[0]=nodeSize,new Uint32Array(this.data,4,1)[0]=numItems)}add(x,y){const index=this._pos>>1;return this.ids[index]=index,this.coords[this._pos++]=x,this.coords[this._pos++]=y,index}finish(){const numAdded=this._pos>>1;if(numAdded!==this.numItems)throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);return sort(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(minX,minY,maxX,maxY){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:ids,coords:coords,nodeSize:nodeSize}=this,stack=[0,ids.length-1,0],result=[];for(;stack.length;){const axis=stack.pop()||0,right=stack.pop()||0,left=stack.pop()||0;if(right-left<=nodeSize){for(let i=left;i<=right;i++){const x=coords[2*i],y=coords[2*i+1];x>=minX&&x<=maxX&&y>=minY&&y<=maxY&&result.push(ids[i])}continue}const m=left+right>>1,x=coords[2*m],y=coords[2*m+1];x>=minX&&x<=maxX&&y>=minY&&y<=maxY&&result.push(ids[m]),(0===axis?minX<=x:minY<=y)&&(stack.push(left),stack.push(m-1),stack.push(1-axis)),(0===axis?maxX>=x:maxY>=y)&&(stack.push(m+1),stack.push(right),stack.push(1-axis))}return result}within(qx,qy,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:ids,coords:coords,nodeSize:nodeSize}=this,stack=[0,ids.length-1,0],result=[],r2=r*r;for(;stack.length;){const axis=stack.pop()||0,right=stack.pop()||0,left=stack.pop()||0;if(right-left<=nodeSize){for(let i=left;i<=right;i++)sqDist(coords[2*i],coords[2*i+1],qx,qy)<=r2&&result.push(ids[i]);continue}const m=left+right>>1,x=coords[2*m],y=coords[2*m+1];sqDist(x,y,qx,qy)<=r2&&result.push(ids[m]),(0===axis?qx-r<=x:qy-r<=y)&&(stack.push(left),stack.push(m-1),stack.push(1-axis)),(0===axis?qx+r>=x:qy+r>=y)&&(stack.push(m+1),stack.push(right),stack.push(1-axis))}return result}}function sort(ids,coords,nodeSize,left,right,axis){if(right-left<=nodeSize)return;const m=left+right>>1;select(ids,coords,m,left,right,axis),sort(ids,coords,nodeSize,left,m-1,1-axis),sort(ids,coords,nodeSize,m+1,right,1-axis)}function select(ids,coords,k,left,right,axis){for(;right>left;){if(right-left>600){const 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);select(ids,coords,k,Math.max(left,Math.floor(k-m*s/n+sd)),Math.min(right,Math.floor(k+(n-m)*s/n+sd)),axis)}const t=coords[2*k+axis];let i=left,j=right;for(swapItem(ids,coords,left,k),coords[2*right+axis]>t&&swapItem(ids,coords,left,right);i<j;){for(swapItem(ids,coords,i,j),i++,j--;coords[2*i+axis]<t;)i++;for(;coords[2*j+axis]>t;)j--}coords[2*left+axis]===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){const tmp=arr[i];arr[i]=arr[j],arr[j]=tmp}function sqDist(ax,ay,bx,by){const dx=ax-bx,dy=ay-by;return dx*dx+dy*dy}const defaultOptions={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:props=>props},fround=Math.fround||(tmp=new Float32Array(1),x=>(tmp[0]=+x,tmp[0]));var tmp;const OFFSET_ID=3,OFFSET_NUM=5,OFFSET_PROP=6;function getClusterJSON(data,i,clusterProps){return{type:"Feature",id:data[i+OFFSET_ID],properties:getClusterProperties(data,i,clusterProps),geometry:{type:"Point",coordinates:[(x=data[i],360*(x-.5)),yLat(data[i+1]
vendor: 2,207 bytes, line 1
1)]}};var x}function getClusterProperties(data,i,clusterProps){const count=data[i+OFFSET_NUM],abbrev=count>=1e4?`${Math.round(count/1e3)}k`:count>=1e3?Math.round(count/100)/10+"k":count,propIndex=data[i+OFFSET_PROP],properties=-1===propIndex?{}:Object.assign({},clusterProps[propIndex]);return Object.assign(properties,{cluster:!0,cluster_id:data[i+OFFSET_ID],point_count:count,point_count_abbreviated:abbrev})}function lngX(lng){return lng/360+.5}function latY(lat){const sin=Math.sin(lat*Math.PI/180),y=.5-.25*Math.log((1+sin)/(1-sin))/Math.PI;return y<0?0:y>1?1:y}function yLat(y){const y2=(180-360*y)*Math.PI/180;return 360*Math.atan(Math.exp(y2))/Math.PI-90}return class{constructor(options){this.options=Object.assign(Object.create(defaultOptions),options),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(points){const{log:log,minZoom:minZoom,maxZoom:maxZoom}=this.options;log&&console.time("total time");const timerId=`prepare ${points.length} points`;log&&console.time(timerId),this.points=points;const data=[];for(let i=0;i<points.length;i++){const p=points[i];if(!p.geometry)continue;const[lng,lat]=p.geometry.coordinates,x=fround(lngX(lng)),y=fround(latY(lat));data.push(x,y,1/0,i,-1,1),this.options.reduce&&data.push(0)}let tree=this.trees[maxZoom+1]=this._createTree(data);log&&console.timeEnd(timerId);for(let z=maxZoom;z>=minZoom;z--){const now=+Date.now();tree=this.trees[z]=this._createTree(this._cluster(tree,z)),log&&console.log("z%d: %d clusters in %dms",z,tree.numItems,+Date.now()-now)}return log&&console.timeEnd("total time"),this}getClusters(bbox,zoom){let minLng=((bbox[0]+180)%360+360)%360-180;const minLat=Math.max(-90,Math.min(90,bbox[1]));let maxLng=180===bbox[2]?180:((bbox[2]+180)%360+360)%360-180;const maxLat=Math.max(-90,Math.min(90,bbox[3]));if(bbox[2]-bbox[0]>=360)minLng=-180,maxLng=180;else if(minLng>maxLng){const easternHem=this.getClusters([minLng,minLat,180,maxLat],zoom),westernHem=this.getClusters([-180,minLat,maxLng,maxLat],zoom);return easternHem.concat(westernHem)}const tree=this.trees[this._limitZoom(zoom)],ids=tree.range(lngX(minLng),latY(maxLat),lngX(maxLng),latY(minLat)),data=tree.data,cluster
vendor: 5,000 bytes, line 1
1s=[];for(const id of ids){const k=this.stride*id;clusters.push(data[k+OFFSET_NUM]>1?getClusterJSON(data,k,this.clusterProps):this.points[data[k+OFFSET_ID]])}return clusters}getChildren(clusterId){const originId=this._getOriginId(clusterId),originZoom=this._getOriginZoom(clusterId),errorMsg="No cluster with the specified id.",tree=this.trees[originZoom];if(!tree)throw new Error(errorMsg);const data=tree.data;if(originId*this.stride>=data.length)throw new Error(errorMsg);const r=this.options.radius/(this.options.extent*Math.pow(2,originZoom-1)),x=data[originId*this.stride],y=data[originId*this.stride+1],ids=tree.within(x,y,r),children=[];for(const id of ids){const k=id*this.stride;data[k+4]===clusterId&&children.push(data[k+OFFSET_NUM]>1?getClusterJSON(data,k,this.clusterProps):this.points[data[k+OFFSET_ID]])}if(0===children.length)throw new Error(errorMsg);return children}getLeaves(clusterId,limit,offset){limit=limit||10,offset=offset||0;const leaves=[];return this._appendLeaves(leaves,clusterId,limit,offset,0),leaves}getTile(z,x,y){const tree=this.trees[this._limitZoom(z)],z2=Math.pow(2,z),{extent:extent,radius:radius}=this.options,p=radius/extent,top=(y-p)/z2,bottom=(y+1+p)/z2,tile={features:[]};return this._addTileFeatures(tree.range((x-p)/z2,top,(x+1+p)/z2,bottom),tree.data,x,y,z2,tile),0===x&&this._addTileFeatures(tree.range(1-p/z2,top,1,bottom),tree.data,z2,y,z2,tile),x===z2-1&&this._addTileFeatures(tree.range(0,top,p/z2,bottom),tree.data,-1,y,z2,tile),tile.features.length?tile:null}getClusterExpansionZoom(clusterId){let expansionZoom=this._getOriginZoom(clusterId)-1;for(;expansionZoom<=this.options.maxZoom;){const children=this.getChildren(clusterId);if(expansionZoom++,1!==children.length)break;clusterId=children[0].properties.cluster_id}return expansionZoom}_appendLeaves(result,clusterId,limit,offset,skipped){const children=this.getChildren(clusterId);for(const child of children){const props=child.properties;if(props&&props.cluster?skipped+props.point_count<=offset?skipped+=props.point_count:skipped=this._appendLeaves(result,props.cluster_id,limit,offset,skipped):skipped<offset?skipped++:result.push(child),result.length===limit)break}return skipped}_createTree(data){const tree=new KDBush(data.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<data.length;i+=this.stride)tree.add(data[i],data[i+1]);return tree.finish(),tree.data=data,tree}_addTileFeatures(ids,data,x,y,z2,tile){for(const i of ids){const k=i*this.stride,isCluster=data[k+OFFSET_NUM]>1;let tags,px,py;if(isCluster)tags=getClusterProperties(data,k,this.clusterProps),px=data[k],py=data[k+1];else{const p=this.points[data[k+OFFSET_ID]];tags=p.properties;const[lng,lat]=p.geometry.coordinates;px=lngX(lng),py=latY(lat)}const f={type:1,geometry:[[Math.round(this.options.extent*(px*z2-x)),Math.round(this.options.extent*(py*z2-y))]],tags:tags};let id;id=isCluster||this.options.generateId?data[k+OFFSET_ID]:this.points[data[k+OFFSET_ID]].id,void 0!==id&&(f.id=id),tile.features.push(f)}}_limitZoom(z){return Math.max(this.options.minZoom,Math.min(Math.floor(+z),this.options.maxZoom+1))}_cluster(tree,zoom){const{radius:radius,extent:extent,reduce:reduce,minPoints:minPoints}=this.options,r=radius/(extent*Math.pow(2,zoom)),data=tree.data,nextData=[],stride=this.stride;for(let i=0;i<data.length;i+=stride){if(data[i+2]<=zoom)continue;data[i+2]=zoom;const x=data[i],y=data[i+1],neighborIds=tree.within(data[i],data[i+1],r),numPointsOrigin=data[i+OFFSET_NUM];let numPoints=numPointsOrigin;for(const neighborId of neighborIds){const k=neighborId*stride;data[k+2]>zoom&&(numPoints+=data[k+OFFSET_NUM])}if(numPoints>numPointsOrigin&&numPoints>=minPoints){let clusterProperties,wx=x*numPointsOrigin,wy=y*numPointsOrigin,clusterPropIndex=-1;const id=((i/stride|0)<<5)+(zoom+1)+this.points.length;for(const neighborId of neighborIds){const k=neighborId*stride;if(data[k+2]<=zoom)continue;data[k+2]=zoom;const numPoints2=data[k+OFFSET_NUM];wx+=data[k]*numPoints2,wy+=data[k+1]*numPoints2,data[k+4]=id,reduce&&(clusterProperties||(clusterProperties=this._map(data,i,!0),clusterPropIndex=this.clusterProps.length,this.clusterProps.push(clusterProperties)),reduce(clusterProperties,this._map(data,k)))}data[i+4]=id,nextData.push(wx/numPoints,wy/numPoints,1/0,id,-1,numPoints),reduce&&nextData.push(clusterPropIndex)}else{for(let j=0;j<stride;j++)nextData.push(data[i+j]);if(numPoints>1)for(const neighborId of neighborIds){const k=neighborId*stride;if(!(data[k+2]<=zoom)){data[k+2]=zoom;for(let j=0;j<stride;j++)nextData.push(data[k+j])}}}}return nextData}_getOriginId(clusterId){return clusterId-this.points.length>>5}_getOriginZoom(clusterId){return(clusterId-this.points.length)%32}_map(data,i,clone){if(data[i+OFFSET_NUM]>1){const props=this.clusterProps[data[i+OFFSET_PROP]];return clone?Object.assign({},props):props}const original=this.points[data[i+OFFSET_ID]].properties,result=this.options.map(original);return clone&&result===original?Object.assign({},result):result}}}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.