silverstripe-webpack/app/client/dist/js/app_Site.Controllers.MapElementController.js

1 line
26 KiB
JavaScript
Raw Normal View History

2022-01-15 13:49:49 +01:00
!function(){var t={8545:function(t){function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function DBSCAN(t,r,o,i){this.dataset=[],this.epsilon=1,this.minPts=2,this.distance=this._euclideanDistance,this.clusters=[],this.noise=[],this._visited=[],this._assigned=[],this._datasetLength=0,this._init(t,r,o,i)}DBSCAN.prototype.run=function(t,r,o,i){this._init(t,r,o,i);for(var a=0;a<this._datasetLength;a++)if(1!==this._visited[a]){this._visited[a]=1;var u=this._regionQuery(a);if(u.length<this.minPts)this.noise.push(a);else{var c=this.clusters.length;this.clusters.push([]),this._addToCluster(a,c),this._expandCluster(c,u)}}return this.clusters},DBSCAN.prototype._init=function(t,r,o,i){if(t){if(!(t instanceof Array))throw Error("Dataset must be of type array, "+_typeof(t)+" given");this.dataset=t,this.clusters=[],this.noise=[],this._datasetLength=t.length,this._visited=new Array(this._datasetLength),this._assigned=new Array(this._datasetLength)}r&&(this.epsilon=r),o&&(this.minPts=o),i&&(this.distance=i)},DBSCAN.prototype._expandCluster=function(t,r){for(var o=0;o<r.length;o++){var i=r[o];if(1!==this._visited[i]){this._visited[i]=1;var a=this._regionQuery(i);a.length>=this.minPts&&(r=this._mergeArrays(r,a))}1!==this._assigned[i]&&this._addToCluster(i,t)}},DBSCAN.prototype._addToCluster=function(t,r){this.clusters[r].push(t),this._assigned[t]=1},DBSCAN.prototype._regionQuery=function(t){for(var r=[],o=0;o<this._datasetLength;o++){this.distance(this.dataset[t],this.dataset[o])<this.epsilon&&r.push(o)}return r},DBSCAN.prototype._mergeArrays=function(t,r){for(var o=r.length,i=0;i<o;i++){var a=r[i];t.indexOf(a)<0&&t.push(a)}return t},DBSCAN.prototype._euclideanDistance=function(t,r){for(var o=0,i=Math.min(t.length,r.length);i--;)o+=(t[i]-r[i])*(t[i]-r[i]);return Math.sqrt(o)},t.exports&&(t.exports=DBSCAN)},1361:function(t){function KMEANS(t,r,o){this.k=3,this.dataset=[],this.assignments=[],this.centroids=[],this.init(t,r,o)}KMEANS.prototype.init=function(t,r,o){this.assignments=[],this.centroids=[],"undefined"!==typeof t&&(this.dataset=t),"undefined"!==typeof r&&(this.k=r),"undefined"!==typeof o&&(this.distance=o)},KMEANS.prototype.run=function(t,r){this.init(t,r);for(var o=this.dataset.length,i=0;i<this.k;i++)this.centroids[i]=this.randomCentroid();for(var a=!0;a;){a=this.assign();for(var u=0;u<this.k;u++){for(var c=new Array(h),l=0,p=0;p<h;p++)c[p]=0;for(var d=0;d<o;d++){var h=this.dataset[d].length;if(u===this.assignments[d]){for(p=0;p<h;p++)c[p]+=this.dataset[d][p];l++}}if(l>0){for(p=0;p<h;p++)c[p]/=l;this.centroids[u]=c}else this.centroids[u]=this.randomCentroid(),a=!0}}return this.getClusters()},KMEANS.prototype.randomCentroid=function(){var t,r,o=this.dataset.length-1;do{r=Math.round(Math.random()*o),t=this.dataset[r]}while(this.centroids.indexOf(t)>=0);return t},KMEANS.prototype.assign=function(){for(var t,r=!1,o=this.dataset.length,i=0;i<o;i++)(t=this.argmin(this.dataset[i],this.centroids,this.distance))!=this.assignments[i]&&(this.assignments[i]=t,r=!0);return r},KMEANS.prototype.getClusters=function(){for(var t,r=new Array(this.k),o=0;o<this.assignments.length;o++)"undefined"===typeof r[t=this.assignments[o]]&&(r[t]=[]),r[t].push(o);return r},KMEANS.prototype.argmin=function(t,r,o){for(var i,a=Number.MAX_VALUE,u=0,c=r.length,l=0;l<c;l++)(i=o(t,r[l]))<a&&(a=i,u=l);return u},KMEANS.prototype.distance=function(t,r){for(var o=0,i=Math.min(t.length,r.length);i--;){var a=t[i]-r[i];o+=a*a}return Math.sqrt(o)},t.exports&&(t.exports=KMEANS)},1402:function(t,r,o){function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}if(t.exports)var i=o(3162);function OPTICS(t,r,o,i){this.epsilon=1,this.minPts=1,this.distance=this._euclideanDistance,this._reachability=[]