@evergis/sgis
Advanced tools
Comparing version 0.5.0-alpha.37 to 0.5.0-alpha.38
@@ -17,6 +17,8 @@ import { Coordinates } from '../baseTypes'; | ||
protected readonly chunkSize: number; | ||
protected previousRenders: VectorRender[]; | ||
protected cachedPaths: Record<number, PathRecord>; | ||
constructor({ path, renders, chunkSize }: PathRenderParams); | ||
initializePath(): void; | ||
addRendersToPath(): void; | ||
protected initializePath(): void; | ||
protected addRendersToPath(): void; | ||
private validateCache; | ||
updateRenders(renders: VectorRender[]): void; | ||
@@ -23,0 +25,0 @@ protected abstract addObject(path: Path2D, render: VectorRender): any; |
@@ -63,4 +63,4 @@ import { PolyControl } from "./controls/PolyControl"; | ||
export { Control } from "./controls/Control"; | ||
export declare const version = "0.5.0-alpha.37"; | ||
export declare const releaseDate = "02.12.2022"; | ||
export declare const version = "0.5.0-alpha.38"; | ||
export declare const releaseDate = "07.12.2022"; | ||
export declare const controls: { | ||
@@ -67,0 +67,0 @@ Circle: typeof Circle; |
@@ -17,6 +17,8 @@ import { Coordinates } from '../baseTypes'; | ||
protected readonly chunkSize: number; | ||
protected previousRenders: VectorRender[]; | ||
protected cachedPaths: Record<number, PathRecord>; | ||
constructor({ path, renders, chunkSize }: PathRenderParams); | ||
initializePath(): void; | ||
addRendersToPath(): void; | ||
protected initializePath(): void; | ||
protected addRendersToPath(): void; | ||
private validateCache; | ||
updateRenders(renders: VectorRender[]): void; | ||
@@ -23,0 +25,0 @@ protected abstract addObject(path: Path2D, render: VectorRender): any; |
@@ -21,14 +21,4 @@ import { VectorRender } from './Render'; | ||
addRendersToPath() { | ||
this.validateCache(); | ||
for (let i = 0; i <= Math.round(this.renders.length / this.chunkSize); i++) { | ||
for (let j = 0; j < this.chunkSize; j++) { | ||
const render = this.renders[i * this.chunkSize + j]; | ||
if (!render) { | ||
break; | ||
} | ||
if (render && render.updateNeeded) { | ||
this.updateNeeded = true; | ||
this.cachedPaths[i] = Object.assign(Object.assign({}, this.cachedPaths[i]), { updateNeeded: true }); | ||
break; | ||
} | ||
} | ||
if (this.cachedPaths[i] && !this.cachedPaths[i].updateNeeded) { | ||
@@ -55,8 +45,38 @@ this.path.addPath(this.cachedPaths[i].path); | ||
} | ||
this.previousRenders = this.renders; | ||
} | ||
validateCache() { | ||
if (!this.previousRenders) { | ||
return; | ||
} | ||
const isAdd = this.previousRenders.length < this.renders.length; | ||
const isDelete = this.previousRenders.length > this.renders.length; | ||
if (isDelete) { | ||
this.cachedPaths = {}; | ||
return; | ||
} | ||
for (let i = 0; i <= Math.round(this.renders.length / this.chunkSize); i++) { | ||
for (let j = 0; j < this.chunkSize; j++) { | ||
const render = this.renders[i * this.chunkSize + j]; | ||
if (!render) { | ||
break; | ||
} | ||
if (render && render.updateNeeded) { | ||
this.updateNeeded = true; | ||
this.cachedPaths[i] = Object.assign(Object.assign({}, this.cachedPaths[i]), { updateNeeded: true }); | ||
if (isAdd && this.cachedPaths[i + 1]) { | ||
for (let j = i + 1; j <= Math.round(this.renders.length / this.chunkSize); j++) { | ||
if (this.cachedPaths[j]) { | ||
this.cachedPaths[j] = Object.assign(Object.assign({}, this.cachedPaths[j]), { updateNeeded: true }); | ||
} | ||
} | ||
return; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
updateRenders(renders) { | ||
this.path = new Path2D(); | ||
if (this.renders.length > renders.length) { | ||
this.cachedPaths = {}; | ||
} | ||
this.renders = renders; | ||
@@ -63,0 +83,0 @@ this.addRendersToPath(); |
@@ -63,4 +63,4 @@ import { PolyControl } from "./controls/PolyControl"; | ||
export { Control } from "./controls/Control"; | ||
export declare const version = "0.5.0-alpha.37"; | ||
export declare const releaseDate = "02.12.2022"; | ||
export declare const version = "0.5.0-alpha.38"; | ||
export declare const releaseDate = "07.12.2022"; | ||
export declare const controls: { | ||
@@ -67,0 +67,0 @@ Circle: typeof Circle; |
@@ -65,4 +65,4 @@ import { PolyControl } from "./controls/PolyControl"; | ||
export { Control } from "./controls/Control"; | ||
export const version = "0.5.0-alpha.37"; | ||
export const releaseDate = "02.12.2022"; | ||
export const version = "0.5.0-alpha.38"; | ||
export const releaseDate = "07.12.2022"; | ||
let utilsModulesExt = {}; | ||
@@ -69,0 +69,0 @@ Object.assign(utilsModulesExt, utilsModule, { Color: Color }); |
{ | ||
"name": "@evergis/sgis", | ||
"version": "0.5.0-alpha.37", | ||
"version": "0.5.0-alpha.38", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/sGis_bundle.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
3057159
37859