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

@evergis/sgis

Package Overview
Dependencies
Maintainers
6
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evergis/sgis - npm Package Compare versions

Comparing version 0.5.0-alpha.6 to 0.5.0-alpha.7

7

es/layers/ClusterLayer.d.ts

@@ -8,2 +8,3 @@ import { Layer, LayerConstructorParams } from './Layer';

import { IClusterProvider } from "./clusterProviders/GridClusterProvider";
import { Handler } from "../EventHandler";
export interface ClusterLayerConstructorParams extends LayerConstructorParams {

@@ -17,4 +18,6 @@ clusterSymbol?: Symbol<Feature>;

export declare class ClusterLayer extends Layer {
private _clusterSymbol;
readonly _clusterSymbol: Symbol<Feature>;
private _gridClusterProvider;
private _clusterEventHandlers;
private _clusters;
/**

@@ -26,2 +29,4 @@ * @param __namedParameters - properties to be set to the corresponding fields.

getFeatures(bbox: Bbox, resolution: number): FeatureGroup[];
addClusterEvent(type: string, handler: Handler): void;
removeClusterEvent(type: string, handler: Handler): void;
/**

@@ -28,0 +33,0 @@ * Adds a feature or an array of features to the layer.

@@ -15,2 +15,4 @@ import { Layer } from './Layer';

super({ delayedUpdate, ...layerParams });
this._clusterEventHandlers = [];
this._clusters = [];
this._clusterSymbol = clusterSymbol;

@@ -21,3 +23,4 @@ this._gridClusterProvider = gridClusterProvider;

let renders = [];
this.getFeatures(bbox, resolution).forEach((cluster) => {
this._clusters = this.getFeatures(bbox, resolution);
this._clusters.forEach((cluster) => {
if (cluster.symbol !== this._clusterSymbol) {

@@ -30,2 +33,3 @@ cluster.symbol = this._clusterSymbol;

else {
this._clusterEventHandlers.forEach(({ type, handler }) => !cluster.hasListener(type, handler) && cluster.on(type, handler));
renders = renders.concat(cluster.render(resolution, bbox.crs));

@@ -48,2 +52,10 @@ }

}
addClusterEvent(type, handler) {
this._clusterEventHandlers.push({ type, handler });
}
removeClusterEvent(type, handler) {
const index = this._clusterEventHandlers.findIndex(item => item.type === type && item.handler === handler);
this._clusterEventHandlers.splice(index, 1);
this._clusters.forEach(cluster => cluster.off(type, handler));
}
/**

@@ -50,0 +62,0 @@ * Adds a feature or an array of features to the layer.

4

es/layers/clusterProviders/GridClusterProvider.d.ts

@@ -13,5 +13,7 @@ import { FeatureGroup } from "../../features/FeatureGroup";

readonly _size: number;
readonly _distance?: number;
private _resolution;
private _cache;
constructor(size?: number);
constructor(size?: number, distance?: number);
private getDistanceGrid(grid, bbox, resolution);
getClusters(bbox: Bbox, resolution: number): FeatureGroup[];

@@ -18,0 +20,0 @@ add(features: Feature | Feature[]): void;

import { FeatureGroup } from "../../features/FeatureGroup";
import { error } from "../../utils/utils";
import { distance } from "../../geotools";
export class GridClusterProvider {
constructor(size = 88) {
constructor(size = 88, distance) {
this._features = [];

@@ -9,3 +10,35 @@ this._size = size;

this._cache = [];
this._distance = distance;
}
getDistanceGrid(grid, bbox, resolution) {
for (const group in grid) {
const gridPosition = group.split("-");
const x = +gridPosition[0];
const y = +gridPosition[1];
const nearest = [
`${x + 1}-${y}`,
`${x + 1}-${y + 1}`,
`${x}-${y + 1}`,
`${x - 1}-${y + 1}`,
`${x - 1}-${y}`,
`${x - 1}-${y - 1}`,
`${x}-${y - 1}`,
`${x + 1}-${y - 1}`
];
grid[group] = new FeatureGroup(grid[group], { crs: bbox.crs });
for (const nearestGridKey of nearest) {
const currGroups = grid[group];
const nearestGroups = grid[nearestGridKey];
if (nearestGroups) {
const nearestFeatureGroup = nearestGroups instanceof FeatureGroup ? nearestGroups : new FeatureGroup(nearestGroups, { crs: bbox.crs });
if (distance(grid[group], nearestFeatureGroup) / resolution < this._distance) {
const features = [...currGroups.features, ...nearestFeatureGroup.features];
grid[group] = new FeatureGroup(features, { crs: bbox.crs });
delete grid[nearestGridKey];
}
}
}
}
return Object.values(grid);
}
getClusters(bbox, resolution) {

@@ -16,3 +49,3 @@ if (this._resolution !== resolution) {

const size = this._size * resolution;
const groups = {};
const grid = {};
for (let i = 0; i < this._features.length; i++) {

@@ -22,9 +55,16 @@ const point = this._features[i].projectTo(bbox.crs);

const indexY = Math.floor(point.centroid[1] / size);
if (groups[`${indexX}-${indexY}`]) {
groups[`${indexX}-${indexY}`].push(this._features[i]);
if (grid[`${indexX}-${indexY}`]) {
grid[`${indexX}-${indexY}`].push(this._features[i]);
}
else
groups[`${indexX}-${indexY}`] = [this._features[i]];
else {
grid[`${indexX}-${indexY}`] = [this._features[i]];
}
;
}
this._cache = Object.keys(groups).map(group => new FeatureGroup(groups[group], { crs: bbox.crs }));
if (this._distance) {
this._cache = this.getDistanceGrid(grid, bbox, resolution);
}
else {
this._cache = Object.keys(grid).map(group => new FeatureGroup(grid[group], { crs: bbox.crs }));
}
}

@@ -51,3 +91,3 @@ return this._cache.filter(feature => feature.crs.canProjectTo(bbox.crs) &&

toRemove.forEach(f => {
let index = this._features.indexOf(f);
const index = this._features.indexOf(f);
if (index === -1)

@@ -54,0 +94,0 @@ error(new Error(`Feature ${f} is not in the GridClusterProvider`));

@@ -134,4 +134,5 @@ import { Arc } from "../../renders/Arc";

this._ctx.beginPath();
this._ctx.lineCap = 'round';
this._ctx.lineJoin = 'round';
this._ctx.lineCap = render.lineCap;
this._ctx.lineJoin = render.lineJoin;
this._ctx.miterLimit = render.miterLimit;
this._ctx.lineWidth = render.strokeWidth;

@@ -138,0 +139,0 @@ this._ctx.strokeStyle = render.strokeColor;

@@ -29,2 +29,8 @@ import { VectorRender } from "./Render";

shadow?: Shadow;
/** @see [[PolyRender.lineCap]] */
lineCap?: "butt" | "round" | "square";
/** @see [[PolyRender.lineJoin]] */
lineJoin?: "bevel" | "miter" | "round";
/** @see [[PolyRender.miterLimit]] */
miterLimit?: number;
}

@@ -35,3 +41,3 @@ /**

*/
export declare class PolyRender extends VectorRender {
export declare class PolyRender extends VectorRender implements PolyRenderConstructorParams {
coordinates: Coordinates[][];

@@ -59,2 +65,29 @@ /** Whether the first and the last points should be connected. */

/**
* Property of the Canvas 2D API determines the shape used to draw the end points of lines.
*
* - `"butt"`
* The ends of lines are squared off at the endpoints.
* - `"round"`
* The ends of lines are rounded.
* - `"square"`
* The ends of lines are squared off by adding a box with an equal width and half the height of the line's thickness.
*/
lineCap: "butt" | "round" | "square";
/**
* Property of the Canvas 2D API determines the shape used to join two line segments where they meet.
*
* - `"bevel"`
* Fills an additional triangular area between the common endpoint of connected segments, and the separate outside rectangular corners of each segment.
* - `"round"`
* Rounds off the corners of a shape by filling an additional sector of disc centered at the common endpoint of connected segments. The radius for these rounded corners is equal to the line width.
* - `"miter"`
* Connected segments are joined by extending their outside edges to connect at a single point, with the effect of filling an additional lozenge-shaped area. This setting is affected by the miterLimit property
*/
lineJoin: "bevel" | "miter" | "round";
/**
* Property of the Canvas 2D API sets the miter limit ratio.
* @docs https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
*/
miterLimit: number;
/**
* @param coordinates - the coordinates of the polygon.

@@ -61,0 +94,0 @@ * @param options - properties to be assigned to the instance

@@ -40,2 +40,29 @@ import { VectorRender } from "./Render";

this.shadow = null;
/**
* Property of the Canvas 2D API determines the shape used to draw the end points of lines.
*
* - `"butt"`
* The ends of lines are squared off at the endpoints.
* - `"round"`
* The ends of lines are rounded.
* - `"square"`
* The ends of lines are squared off by adding a box with an equal width and half the height of the line's thickness.
*/
this.lineCap = "round";
/**
* Property of the Canvas 2D API determines the shape used to join two line segments where they meet.
*
* - `"bevel"`
* Fills an additional triangular area between the common endpoint of connected segments, and the separate outside rectangular corners of each segment.
* - `"round"`
* Rounds off the corners of a shape by filling an additional sector of disc centered at the common endpoint of connected segments. The radius for these rounded corners is equal to the line width.
* - `"miter"`
* Connected segments are joined by extending their outside edges to connect at a single point, with the effect of filling an additional lozenge-shaped area. This setting is affected by the miterLimit property
*/
this.lineJoin = "round";
/**
* Property of the Canvas 2D API sets the miter limit ratio.
* @docs https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
*/
this.miterLimit = 10;
Object.assign(this, options);

@@ -42,0 +69,0 @@ this.coordinates = coordinates;

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

import { Symbol, SymbolConstructor } from "../symbols/Symbol";
import { Symbol } from "../symbols/Symbol";
import { Feature } from "../features/Feature";

@@ -15,3 +15,3 @@ export declare type SerializedSymbol = {

*/
export declare const registerSymbol: (constructor: SymbolConstructor, name: string, properties: string[]) => void;
export declare const registerSymbol: <C extends Symbol<Feature>>(constructor: new () => C, name: string, properties: (keyof C)[]) => void;
/**

@@ -18,0 +18,0 @@ * Serializes symbol to a key-value JSON object.

@@ -63,4 +63,4 @@ import { PolyControl } from "./controls/PolyControl";

export { Control } from "./controls/Control";
export declare const version = "0.5.0-alpha.6";
export declare const releaseDate = "22.07.2020";
export declare const version = "0.5.0-alpha.7";
export declare const releaseDate = "11.08.2020";
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.6";
export const releaseDate = "22.07.2020";
export const version = "0.5.0-alpha.7";
export const releaseDate = "11.08.2020";
let utilsModulesExt = {};

@@ -69,0 +69,0 @@ Object.assign(utilsModulesExt, utilsModule, { Color: Color });

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

import { PolyRenderConstructorParams } from "../../renders/Poly";
import { Symbol } from "../Symbol";

@@ -6,3 +7,3 @@ import { Render } from "../../renders/Render";

import { Shadow } from "../../baseTypes";
export interface BrushFillConstructorParams {
export interface BrushFillConstructorParams extends Pick<PolyRenderConstructorParams, "lineDash" | "lineCap" | "lineJoin" | "miterLimit"> {
/** @see [[BrushFill.strokeColor]] */

@@ -12,4 +13,2 @@ strokeColor?: string;

strokeWidth?: number;
/** @see [[BrushFill.lineDash]] */
lineDash?: number[];
/** @see [[BrushFill.fillBrush]] */

@@ -28,3 +27,3 @@ fillBrush?: number[][];

*/
export declare class BrushFill extends Symbol<Polygon> {
export declare class BrushFill extends Symbol<Polygon> implements BrushFillConstructorParams {
_brush: HTMLImageElement;

@@ -38,6 +37,12 @@ _fillBackground: string;

strokeWidth: number;
/** Dash pattern for the line as specified in HTML CanvasRenderingContext2D.setLineDash() specification */
/** @see [[PolyRender.lineDash]] */
lineDash: number[];
/** Emulation CanvasRenderingContext2D.filter drop-shadow. */
shadow: Shadow;
/** @see [[PolyRender.lineCap]] */
lineCap: "butt" | "round" | "square";
/** @see [[PolyRender.lineJoin]] */
lineJoin: "bevel" | "miter" | "round";
/** @see [[PolyRender.miterLimit]] */
miterLimit: number;
private _initialized;

@@ -44,0 +49,0 @@ /**

@@ -34,6 +34,12 @@ import { registerSymbol } from "../../serializers/symbolSerializer";

this.strokeWidth = 1;
/** Dash pattern for the line as specified in HTML CanvasRenderingContext2D.setLineDash() specification */
/** @see [[PolyRender.lineDash]] */
this.lineDash = [];
/** Emulation CanvasRenderingContext2D.filter drop-shadow. */
this.shadow = null;
/** @see [[PolyRender.lineCap]] */
this.lineCap = "round";
/** @see [[PolyRender.lineJoin]] */
this.lineJoin = "round";
/** @see [[PolyRender.miterLimit]] */
this.miterLimit = 10;
this._initialized = false;

@@ -56,3 +62,6 @@ if (options)

lineDash: this.lineDash,
shadow: this.shadow
shadow: this.shadow,
lineCap: this.lineCap,
lineJoin: this.lineJoin,
miterLimit: this.miterLimit,
})];

@@ -105,2 +114,2 @@ }

}
registerSymbol(BrushFill, 'polygon.BrushFill', ['fillBrush', 'fillBackground', 'fillForeground', 'strokeColor', 'strokeWidth', 'shadow']);
registerSymbol(BrushFill, 'polygon.BrushFill', ['fillBrush', 'fillBackground', 'fillForeground', 'strokeColor', 'strokeWidth', 'lineDash', 'shadow', 'lineCap', 'lineJoin', 'miterLimit']);

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

import { PolyRenderConstructorParams } from "../../renders/Poly";
import { Symbol } from "../Symbol";

@@ -6,3 +7,3 @@ import { Crs } from "../../Crs";

import { Shadow } from "../../baseTypes";
export interface ImageFillConstructorParams {
export interface ImageFillConstructorParams extends Pick<PolyRenderConstructorParams, "lineDash" | "lineCap" | "lineJoin" | "miterLimit"> {
/** @see [[ImageFill.strokeColor]] */

@@ -12,4 +13,2 @@ strokeColor?: string;

strokeWidth?: number;
/** @see [[ImageFill.lineDash]] */
lineDash?: number[];
/** @see [[ImageFill.src]] */

@@ -24,3 +23,3 @@ src?: string;

*/
export declare class ImageFill extends Symbol<Polygon> {
export declare class ImageFill extends Symbol<Polygon> implements ImageFillConstructorParams {
private _image;

@@ -32,4 +31,10 @@ private _src;

strokeWidth: number;
/** Dash pattern for the line as specified in HTML CanvasRenderingContext2D.setLineDash() specification. */
/** @see [[PolyRender.lineDash]] */
lineDash: number[];
/** @see [[PolyRender.lineCap]] */
lineCap: "butt" | "round" | "square";
/** @see [[PolyRender.lineJoin]] */
lineJoin: "bevel" | "miter" | "round";
/** @see [[PolyRender.miterLimit]] */
miterLimit: number;
/** Emulation CanvasRenderingContext2D.filter drop-shadow. */

@@ -36,0 +41,0 @@ shadow: Shadow;

@@ -17,2 +17,10 @@ import { registerSymbol } from "../../serializers/symbolSerializer";

this._image = new Image();
/** @see [[PolyRender.lineDash]] */
this.lineDash = [];
/** @see [[PolyRender.lineCap]] */
this.lineCap = "round";
/** @see [[PolyRender.lineJoin]] */
this.lineJoin = "round";
/** @see [[PolyRender.miterLimit]] */
this.miterLimit = 10;
/** Emulation CanvasRenderingContext2D.filter drop-shadow. */

@@ -42,3 +50,6 @@ this.shadow = null;

lineDash: this.lineDash,
shadow: this.shadow
shadow: this.shadow,
lineCap: this.lineCap,
lineJoin: this.lineJoin,
miterLimit: this.miterLimit,
})];

@@ -59,2 +70,2 @@ }

}
registerSymbol(ImageFill, 'polygon.ImageFill', ['src', 'strokeColor', 'strokeWidth', 'shadow']);
registerSymbol(ImageFill, 'polygon.ImageFill', ['src', 'strokeColor', 'strokeWidth', 'lineDash', 'shadow', 'lineCap', 'lineJoin', 'miterLimit']);
import { Symbol } from "../Symbol";
import { PolyRenderConstructorParams } from "../../renders/Poly";
import { Crs } from "../../Crs";

@@ -6,3 +7,3 @@ import { Render } from "../../renders/Render";

import { Shadow } from "../../baseTypes";
export interface PolygonSymbolConstructorParams {
export interface PolygonSymbolConstructorParams extends Pick<PolyRenderConstructorParams, "lineDash" | "lineCap" | "lineJoin" | "miterLimit"> {
/** @see [[PolygonSymbol.fillColor]] */

@@ -14,4 +15,2 @@ fillColor?: string;

strokeWidth?: number;
/** @see [[PolygonSymbol.lineDash]] */
lineDash?: number[];
/** @see [[PolygonSymbol.shadow]] */

@@ -24,3 +23,3 @@ shadow?: Shadow;

*/
export declare class PolygonSymbol extends Symbol<Polygon> {
export declare class PolygonSymbol extends Symbol<Polygon> implements PolygonSymbolConstructorParams {
/** Fill color of the polygon. Can be any valid css color string. */

@@ -32,6 +31,12 @@ fillColor: string;

strokeWidth: number;
/** Dash pattern for the line as specified in HTML CanvasRenderingContext2D.setLineDash() specification */
/** @see [[PolyRender.lineDash]] */
lineDash: number[];
/** Emulation CanvasRenderingContext2D.filter shadow. */
shadow: Shadow;
/** @see [[PolyRender.lineCap]] */
lineCap: "butt" | "round" | "square";
/** @see [[PolyRender.lineJoin]] */
lineJoin: "bevel" | "miter" | "round";
/** @see [[PolyRender.miterLimit]] */
miterLimit: number;
/**

@@ -38,0 +43,0 @@ * @param options - key-value list of the properties to be assigned to the instance.

@@ -22,6 +22,12 @@ import { registerSymbol } from "../../serializers/symbolSerializer";

this.strokeWidth = 1;
/** Dash pattern for the line as specified in HTML CanvasRenderingContext2D.setLineDash() specification */
/** @see [[PolyRender.lineDash]] */
this.lineDash = [];
/** Emulation CanvasRenderingContext2D.filter shadow. */
this.shadow = null;
/** @see [[PolyRender.lineCap]] */
this.lineCap = "round";
/** @see [[PolyRender.lineJoin]] */
this.lineJoin = "round";
/** @see [[PolyRender.miterLimit]] */
this.miterLimit = 10;
Object.assign(this, options);

@@ -40,6 +46,9 @@ }

lineDash: this.lineDash,
shadow: this.shadow
shadow: this.shadow,
lineCap: this.lineCap,
lineJoin: this.lineJoin,
miterLimit: this.miterLimit,
})];
}
}
registerSymbol(PolygonSymbol, 'polygon.Simple', ['fillColor', 'strokeColor', 'strokeWidth', 'shadow']);
registerSymbol(PolygonSymbol, 'polygon.Simple', ['fillColor', 'strokeColor', 'strokeWidth', 'lineDash', 'shadow', 'lineCap', 'lineJoin', 'miterLimit']);
import { Symbol } from "./Symbol";
import { PolyRenderConstructorParams } from "../renders/Poly";
import { Render } from "../renders/Render";

@@ -7,3 +8,3 @@ import { Crs } from "../Crs";

import { Shadow } from "../baseTypes";
export interface PolylineSymbolConstructorParams {
export interface PolylineSymbolConstructorParams extends Pick<PolyRenderConstructorParams, "lineDash" | "lineCap" | "lineJoin" | "miterLimit"> {
/** @see [[PolylineSymbol.strokeColor]] */

@@ -13,4 +14,2 @@ strokeColor?: string;

strokeWidth?: number;
/** @see [[PolylineSymbol.lineDash]] */
lineDash?: number[];
/** @see [[PolylineSymbol.shadow]] */

@@ -23,3 +22,3 @@ shadow?: Shadow;

*/
export declare class PolylineSymbol extends Symbol<Polyline> {
export declare class PolylineSymbol extends Symbol<Polyline> implements PolylineSymbolConstructorParams {
/** Stroke color of the outline. Can be any valid css color string. */

@@ -29,6 +28,12 @@ strokeColor: string;

strokeWidth: number;
/** Dash pattern for the line as specified in HTML CanvasRenderingContext2D.setLineDash() specification */
/** @see [[PolyRender.lineDash]] */
lineDash: number[];
/** Emulation CanvasRenderingContext2D.filter drop-shadow. */
shadow: Shadow;
/** @see [[PolyRender.lineCap]] */
lineCap: "butt" | "round" | "square";
/** @see [[PolyRender.lineJoin]] */
lineJoin: "bevel" | "miter" | "round";
/** @see [[PolyRender.miterLimit]] */
miterLimit: number;
/**

@@ -35,0 +40,0 @@ * @param options - key-value list of the properties to be assigned to the instance.

@@ -20,6 +20,12 @@ import { Symbol } from "./Symbol";

this.strokeWidth = 1;
/** Dash pattern for the line as specified in HTML CanvasRenderingContext2D.setLineDash() specification */
/** @see [[PolyRender.lineDash]] */
this.lineDash = [];
/** Emulation CanvasRenderingContext2D.filter drop-shadow. */
this.shadow = null;
/** @see [[PolyRender.lineCap]] */
this.lineCap = "round";
/** @see [[PolyRender.lineJoin]] */
this.lineJoin = "round";
/** @see [[PolyRender.miterLimit]] */
this.miterLimit = 10;
Object.assign(this, options);

@@ -37,3 +43,6 @@ }

lineDash: this.lineDash,
shadow: this.shadow
shadow: this.shadow,
lineCap: this.lineCap,
lineJoin: this.lineJoin,
miterLimit: this.miterLimit,
})];

@@ -56,2 +65,2 @@ }

}
registerSymbol(PolylineSymbol, 'polyline.Simple', ['strokeColor', 'strokeWidth', 'shadow']);
registerSymbol(PolylineSymbol, 'polyline.Simple', ['strokeColor', 'strokeWidth', 'shadow', 'lineCap', 'lineDash', 'lineJoin', 'miterLimit']);

@@ -25,2 +25,4 @@ /**

point[1] = point[1] - center[1];
// FIX_ME:
// @ts-ignore
point[2] = 1;

@@ -27,0 +29,0 @@ });

{
"name": "@evergis/sgis",
"version": "0.5.0-alpha.6",
"version": "0.5.0-alpha.7",
"description": "",

@@ -26,3 +26,4 @@ "main": "dist/sGis_bundle.js",

"rollup:esm": "rollup --config config/rollup-esm.config.js",
"prepublishOnly": "npm ci && npm run build-code"
"prepublishOnly": "npm ci && npm run build-code",
"watch": "tsc-watch --rootDir source --outDir es"
},

@@ -53,2 +54,3 @@ "repository": {

"ts-jest": "^21.2.4",
"tsc-watch": "^4.2.9",
"typedoc": "git+https://github.com/Maximkaaa/typedoc.git#dev",

@@ -55,0 +57,0 @@ "typedoc-default-themes": "https://github.com/Maximkaaa/typedoc-default-themes#dev",

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

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