Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@2gis/general

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@2gis/general - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

dist/general.js

@@ -1,2 +0,2 @@

!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.General=e():r.General=e()}(this,function(){return function(r){function e(t){if(n[t])return n[t].exports;var i=n[t]={i:t,l:!1,exports:{}};return r[t].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=r,e.c=n,e.i=function(r){return r},e.d=function(r,n,t){e.o(r,n)||Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:t})},e.n=function(r){var n=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(n,"a",n),n},e.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},e.p="/dist/",e(e.s=1)}([function(r,e,n){"use strict";var t=n(2);n.d(e,"a",function(){return o});var i=n(4),o=function(){function r(){var r=this;this.worker=new i,this.queue=[],this.currentJob=void 0,this.markerArray=new Float32Array(1e3*t.a),this.worker.onmessage=function(e){if(void 0!==r.currentJob){var n=r.currentJob,t=n.markers,i=n.resolve;r.recordResult(t,e.data),r.markerArray=e.data,r.currentJob=void 0,r.dequeue(),i()}}}return r.prototype.generalize=function(r,e,n,t,i){var o=this,a={bounds:r,pixelRatio:e,priorityGroups:n,sprites:t.sprites};return new Promise(function(r){o.queue.push({message:a,markers:i,resolve:r}),o.dequeue()})},r.prototype.clear=function(){this.queue=[]},r.prototype.pack=function(r){r.length*t.a>this.markerArray.length&&(this.markerArray=new Float32Array(r.length*t.a));for(var e=this.markerArray,n=0,i=0;n<r.length;n++,i+=t.a){var o=r[n],a=o.iconIndex,u=o.prevGroupIndex;this.markerArray[i+t.b.pixelPositionX]=o.pixelPosition[0],this.markerArray[i+t.b.pixelPositionY]=o.pixelPosition[1],e[i+t.b.groupIndex]=o.groupIndex,e[i+t.b.iconIndex]=void 0!==a?a:NaN,e[i+t.b.prevGroupIndex]=void 0!==u?u:NaN}},r.prototype.dequeue=function(){if(void 0===this.currentJob){var r=this.queue.shift();if(void 0!==r){this.pack(r.markers);var e=r.message;e.markers=this.markerArray,e.markerCount=r.markers.length,this.worker.postMessage(e,[e.markers.buffer]),this.currentJob=r}}},r.prototype.recordResult=function(r,e){for(var n=0,i=0;n<r.length;n++,i+=t.a){var o=e[i+t.b.iconIndex],a=e[i+t.b.prevGroupIndex];r[n].iconIndex=o!==o?void 0:o,r[n].prevGroupIndex=a!==a?void 0:a}},r}()},function(r,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=n(0);n.d(e,"General",function(){return t.a})},function(r,e,n){"use strict";n.d(e,"b",function(){return t}),n.d(e,"a",function(){return i});var t={pixelPositionX:0,pixelPositionY:1,groupIndex:2,iconIndex:3,prevGroupIndex:4},i=Object.keys(t).length},function(r,e){var n=window.URL||window.webkitURL;r.exports=function(r,e){try{try{var t;try{var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;t=new i,t.append(r),t=t.getBlob()}catch(e){t=new Blob([r])}return new Worker(n.createObjectURL(t))}catch(e){return new Worker("data:application/javascript,"+encodeURIComponent(r))}}catch(r){if(!e)throw Error("Inline worker is not supported");return new Worker(e)}}},function(r,e,n){r.exports=function(){return n(3)('!function(n){function r(i){if(e[i])return e[i].exports;var t=e[i]={i:i,l:!1,exports:{}};return n[i].call(t.exports,t,t.exports,r),t.l=!0,t.exports}var e={};r.m=n,r.c=e,r.i=function(n){return n},r.d=function(n,e,i){r.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(e,"a",e),e},r.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},r.p="/dist/",r(r.s=1)}([function(n,r,e){"use strict";function i(n){for(var r=n.bounds,e=n.pixelRatio,i=n.priorityGroups,p=n.sprites,v=n.markers,d=n.markerCount,l=1+(r.maxX-r.minX>>3)<<3,X=r.maxY-r.minY,Y=l*X+8>>3,b=new Uint8Array(Y),g=new Uint8Array(Y),y=new Uint8Array(Y),I=0;I<d;I++){var P=v[I*m.a+m.b.prevGroupIndex],h=v[I*m.a+m.b.pixelPositionX],G=v[I*m.a+m.b.pixelPositionY];if(!a(P)){var O=i[P],j=O.iconIndex,k=O.margin,w=O.degradation,_=p[j];if(!_)continue;var A=_.size,M=_.anchor,U=_.pixelDensity;s(f,l,X,e,A,M,U,h,G,k),u(f)||o(b,l,f),s(c,l,X,e,A,M,U,h,G,w),u(c)||o(y,l,c)}}for(var I=0;I<i.length;I++){var z=i[I],D=z.safeZone,j=z.iconIndex,k=z.margin,w=z.degradation,_=p[j];if(_){var A=_.size,M=_.anchor,U=_.pixelDensity;g.set(y);for(var C=0;C<d;C++){var R=C*m.a,Z=v[R+m.b.groupIndex],P=v[R+m.b.prevGroupIndex],h=v[R+m.b.pixelPositionX],G=v[R+m.b.pixelPositionY];Z>I||!a(P)||(s(f,l,X,e,A,M,U,h,G,k),u(f)||Z===I&&t(g,l,f)||(s(x,l,X,e,A,M,U,h,G,D),u(x)||t(b,l,x)||(s(c,l,X,e,A,M,U,h,G,w),o(b,l,f),o(y,l,c),v[R+m.b.iconIndex]=j,v[R+m.b.prevGroupIndex]=I)))}}}}function t(n,r,e){for(var i=e.minX,t=e.minY,o=e.maxX,a=e.maxY,u=t;u<a;u++){var s=u*r+i>>3,m=u*r+o>>3,x=0;if(s===m)x=n[s]&255>>(7&i)&255<<8-(7&o);else{x=n[s]&255>>(7&i);for(var f=s+1;f<m;f++)x=n[f]|x;x=n[m]&255<<8-(7&o)|x}if(0!==x)return!0}return!1}function o(n,r,e){for(var i=e.minX,t=e.minY,o=e.maxX,a=e.maxY,u=t;u<a;u++){var s=u*r+i>>3,m=u*r+o>>3;if(s===m)n[s]=n[s]|255>>(7&i)&255<<8-(7&o);else{n[s]=n[s]|255>>(7&i);for(var x=s+1;x<m;x++)n[x]=255;n[m]=n[m]|255<<8-(7&o)}}}function a(n){return n!==n}function u(n){return n.minX===n.maxX||n.minY===n.maxY}function s(n,r,e,i,t,o,a,u,s,m){var x=i/a,f=u*i-t[0]*x*o[0]-m|0,c=s*i-t[1]*x*o[1]-m|0,p=u*i+t[0]*x*(1-o[0])+m|0,v=s*i+t[1]*x*(1-o[1])+m|0;n.minX=f>0?f<r?f:r:0,n.minY=c>0?c<e?c:e:0,n.maxX=p>0?p<r?p:r:0,n.maxY=v>0?v<e?v:e:0}var m=e(2);r.a=i;var x={minX:0,minY:0,maxX:0,maxY:0},f={minX:0,minY:0,maxX:0,maxY:0},c={minX:0,minY:0,maxX:0,maxY:0}},function(n,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e(0);onmessage=function(n){var r=n.data;e.i(i.a)(r),postMessage(r.markers)}},function(n,r,e){"use strict";e.d(r,"b",function(){return i}),e.d(r,"a",function(){return t});var i={pixelPositionX:0,pixelPositionY:1,groupIndex:2,iconIndex:3,prevGroupIndex:4},t=Object.keys(i).length}]);\n//# sourceMappingURL=dde090990a6feb572c38.worker.js.map',null)}}])});
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.General=e():r.General=e()}(this,function(){return function(r){function e(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return r[t].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=r,e.c=n,e.d=function(r,n,t){e.o(r,n)||Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:t})},e.n=function(r){var n=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(n,"a",n),n},e.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},e.p="/dist/",e(e.s=1)}([function(r,e,n){"use strict";n.d(e,"a",function(){return t}),n.d(e,"b",function(){return o});var t={pixelPositionX:0,pixelPositionY:1,groupIndex:2,iconIndex:3,prevGroupIndex:4},o=Object.keys(t).length},function(r,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=n(2);n.d(e,"General",function(){return t.a})},function(r,e,n){"use strict";n.d(e,"a",function(){return a});var t=n(0),o=n(3),i=n.n(o),a=function(){function r(){var r=this;this.worker=i()(4),this.queue=[],this.currentJob=void 0,this.markerArray=new Float32Array(1e3*t.b),this.worker.onmessage=function(e){if(void 0!==r.currentJob){var n=r.currentJob,t=n.markers,o=n.resolve;r.recordResult(t,e.data),r.markerArray=e.data,r.currentJob=void 0,r.dequeue(),o()}}}return r.prototype.generalize=function(r,e,n,t,o){var i=this,a={bounds:r,pixelRatio:e,priorityGroups:n,sprites:t.sprites};return new Promise(function(r){i.queue.push({message:a,markers:o,resolve:r}),i.dequeue()})},r.prototype.clear=function(){this.queue=[]},r.prototype.pack=function(r){r.length*t.b>this.markerArray.length&&(this.markerArray=new Float32Array(r.length*t.b));for(var e=this.markerArray,n=0,o=0;n<r.length;n++,o+=t.b){var i=r[n],a=i.iconIndex,u=i.prevGroupIndex;this.markerArray[o+t.a.pixelPositionX]=i.pixelPosition[0],this.markerArray[o+t.a.pixelPositionY]=i.pixelPosition[1],e[o+t.a.groupIndex]=i.groupIndex,e[o+t.a.iconIndex]=void 0!==a?a:NaN,e[o+t.a.prevGroupIndex]=void 0!==u?u:NaN}},r.prototype.dequeue=function(){if(void 0===this.currentJob){var r=this.queue.shift();if(void 0!==r){this.pack(r.markers);var e=r.message;e.markers=this.markerArray,e.markerCount=r.markers.length,this.worker.postMessage(e,[e.markers.buffer]),this.currentJob=r}}},r.prototype.recordResult=function(r,e){for(var n=0,o=0;n<r.length;n++,o+=t.b){var i=e[o+t.a.iconIndex],a=e[o+t.a.prevGroupIndex];r[n].iconIndex=i!==i?void 0:i,r[n].prevGroupIndex=a!==a?void 0:a}},r}()},function(r,e,n){function t(r){function e(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return r[t].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};e.m=r,e.c=n,e.i=function(r){return r},e.d=function(r,n,t){e.o(r,n)||Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:t})},e.n=function(r){var n=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(n,"a",n),n},e.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},e.p="/",e.oe=function(r){throw console.error(r),r};var t=e(e.s=ENTRY_MODULE);return t.default||t}function o(r){return(r+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function i(r){var e=[],n=r.toString(),t=n.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!t)return e;for(var i,a=t[1],u=new RegExp("(\\\\n|\\W)"+o(a)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\w|/|@]+).*?\\)","g");i=u.exec(n);)e.push(i[3]);return e}function a(r,e){for(var n=[e],t=[],o={};n.length;){var a=n.pop();if(!o[a]&&r[a]){o[a]=!0,t.push(a);var u=i(r[a]);n=n.concat(u)}}return t}r.exports=function(r,e){e=e||{};var o=n.m,i=e.all?Object.keys(o):a(o,r),u="("+t.toString().replace("ENTRY_MODULE",JSON.stringify(r))+")({"+i.map(function(r){return JSON.stringify(r)+": "+o[r].toString()}).join(",")+"})(self);",s=new window.Blob([u],{type:"text/javascript"});if(e.bare)return s;var c=window.URL||window.webkitURL||window.mozURL||window.msURL,f=c.createObjectURL(s),p=new window.Worker(f);return p.objectURL=f,p}},function(r,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=n(5);e.default=function(r){r.onmessage=function(e){var n=e.data;Object(t.a)(n),r.postMessage(n.markers)}}},function(r,e,n){"use strict";function t(r){for(var e=r.bounds,n=r.pixelRatio,t=r.priorityGroups,l=r.sprites,m=r.markers,x=r.markerCount,v=1+(e.maxX-e.minX>>3)<<3,b=e.maxY-e.minY,h=v*b+8>>3,y=new Uint8Array(h),g=new Uint8Array(h),w=new Uint8Array(h),k=0;k<x;k++){var Y=m[k*c.b+c.a.prevGroupIndex],I=m[k*c.b+c.a.pixelPositionX],X=m[k*c.b+c.a.pixelPositionY];if(!a(Y)){var P=t[Y],j=P.iconIndex,O=P.margin,A=P.degradation,G=l[j];if(!G)continue;var R=G.size,U=G.anchor,_=G.pixelDensity;s(p,v,b,n,R,U,_,I,X,O),u(p)||i(y,v,p),s(d,v,b,n,R,U,_,I,X,A),u(d)||i(w,v,d)}}for(var k=0;k<t.length;k++){var J=t[k],L=J.safeZone,j=J.iconIndex,O=J.margin,A=J.degradation,G=l[j];if(G){var R=G.size,U=G.anchor,_=G.pixelDensity;g.set(w);for(var M=0;M<x;M++){var N=M*c.b,q=m[N+c.a.groupIndex],Y=m[N+c.a.prevGroupIndex],I=m[N+c.a.pixelPositionX],X=m[N+c.a.pixelPositionY];q>k||!a(Y)||(s(p,v,b,n,R,U,_,I,X,O),u(p)||q===k&&o(g,v,p)||(s(f,v,b,n,R,U,_,I,X,L),u(f)||o(y,v,f)||(s(d,v,b,n,R,U,_,I,X,A),i(y,v,p),i(w,v,d),m[N+c.a.iconIndex]=j,m[N+c.a.prevGroupIndex]=k)))}}}}function o(r,e,n){for(var t=n.minX,o=n.minY,i=n.maxX,a=n.maxY,u=o;u<a;u++){var s=u*e+t>>3,c=u*e+i>>3,f=0;if(s===c)f=r[s]&255>>(7&t)&255<<8-(7&i);else{f=r[s]&255>>(7&t);for(var p=s+1;p<c;p++)f=r[p]|f;f=r[c]&255<<8-(7&i)|f}if(0!==f)return!0}return!1}function i(r,e,n){for(var t=n.minX,o=n.minY,i=n.maxX,a=n.maxY,u=o;u<a;u++){var s=u*e+t>>3,c=u*e+i>>3;if(s===c)r[s]=r[s]|255>>(7&t)&255<<8-(7&i);else{r[s]=r[s]|255>>(7&t);for(var f=s+1;f<c;f++)r[f]=255;r[c]=r[c]|255<<8-(7&i)}}}function a(r){return r!==r}function u(r){return r.minX===r.maxX||r.minY===r.maxY}function s(r,e,n,t,o,i,a,u,s,c){var f=t/a,p=u*t-o[0]*f*i[0]-c|0,d=s*t-o[1]*f*i[1]-c|0,l=u*t+o[0]*f*(1-i[0])+c|0,m=s*t+o[1]*f*(1-i[1])+c|0;r.minX=p>0?p<e?p:e:0,r.minY=d>0?d<n?d:n:0,r.maxX=l>0?l<e?l:e:0,r.maxY=m>0?m<n?m:n:0}e.a=t;var c=n(0),f={minX:0,minY:0,maxX:0,maxY:0},p={minX:0,minY:0,maxX:0,maxY:0},d={minX:0,minY:0,maxX:0,maxY:0}}])});
//# sourceMappingURL=general.js.map
{
"name": "@2gis/general",
"version": "0.0.2",
"version": "0.0.3",
"description": "Fast marker generalization algorithm",

@@ -30,23 +30,23 @@ "contributors": [

"unit-dev": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha -w --compilers ts:ts-node/register test/**/*.spec.ts",
"lint": "tslint src/**/*.ts demo/**/*.ts test/**/*.ts"
"lint": "tslint 'src/**/*.ts' 'demo/**/*.ts' 'test/**/*.ts'"
},
"devDependencies": {
"2gis-maps": "^3.2.0",
"@2gis/markerdrawer": "^0.0.2",
"@types/leaflet": "^1.0.56",
"2gis-maps": "^3.3.5",
"@2gis/markerdrawer": "^0.0.9",
"@types/leaflet": "^1.0.66",
"@types/mocha": "^2.2.41",
"@types/node": "^7.0.12",
"@types/node": "^8.0.14",
"@types/rbush": "^2.0.2",
"mocha": "^3.3.0",
"mocha": "^3.4.2",
"rbush": "^2.0.1",
"ts-loader": "^2.0.3",
"ts-node": "^3.0.2",
"tslib": "^1.6.0",
"tslint": "^5.2.0",
"tslint-eslint-rules": "^4.0.0",
"typescript": "^2.2.1",
"webpack": "^2.3.1",
"webpack-dev-server": "^2.4.2",
"worker-loader": "^0.8.0"
"ts-loader": "^2.3.1",
"ts-node": "^3.2.1",
"tslib": "^1.7.1",
"tslint": "^5.5.0",
"tslint-eslint-rules": "^4.1.1",
"typescript": "^2.4.2",
"webpack": "^3.3.0",
"webpack-dev-server": "^2.5.1",
"webworkify-webpack": "^2.0.5"
}
}

@@ -11,2 +11,3 @@ # General [![Build Status](https://travis-ci.org/2gis/general.svg?branch=master)](https://travis-ci.org/2gis/general)

- [Использование](#Использование)
- [Релиз](#Релиз)

@@ -117,1 +118,7 @@ ## Общий принцип работы ##

Также, генерализация выставляет маркерам дополнительный параметр `prevGroupIndex`, чтобы при повторной генерализации, обрабатывать только новые маркера. Это помогает избежать моментов, когда при добавление новых маркеров, старые маркеры генерализуются в новых условиях по-новому.
## Релиз ##
1. `npm version patch` – обновить версию в `package.json`
2. `git push --follow-tags` – запушить изменения на github
3. `rm -rf dist && npm run build` – собрать проект
4. `npm publish` – отправить в npm

@@ -11,5 +11,4 @@ import { stride, offsets } from './markerArray';

} from './types';
import work from 'webworkify-webpack';
const Worker = require('worker-loader?inline&fallback=false!ts-loader!./worker');
export class General {

@@ -22,3 +21,3 @@ private worker: Worker;

constructor() {
this.worker = new Worker();
this.worker = work(require.resolve('./worker'));
this.queue = [];

@@ -106,3 +105,3 @@ this.currentJob = undefined;

let message = job.message as WorkerMessage;
const message = job.message as WorkerMessage;
message.markers = this.markerArray;

@@ -129,3 +128,3 @@ message.markerCount = job.markers.length;

}
};
}
}

@@ -143,3 +143,3 @@ import { BBox, Vec2, WorkerMessage } from '../types';

}
};
}

@@ -146,0 +146,0 @@ /**

import { WorkerMessage } from '../types';
import { generalize } from './generalize';
declare const postMessage: (message: any, transfer?: any[]) => void;
export interface WorkerGlobalScope {
onmessage: (event: { data: WorkerMessage }) => void;
postMessage: (message: any, transfer?: any[]) => void;
}
onmessage = (event) => {
const data: WorkerMessage = event.data;
generalize(data);
postMessage(data.markers);
export default (self: WorkerGlobalScope) => {
self.onmessage = (event) => {
const data = event.data;
generalize(data);
self.postMessage(data.markers);
};
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc