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

@evergis/sp-api

Package Overview
Dependencies
Maintainers
5
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evergis/sp-api - npm Package Compare versions

Comparing version 0.4.20 to 0.4.21

dist/layers/ClusterFeature.d.ts

2

dist/DataFilter.js

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

import { ClusterSymbol } from "./layers/ClusterLayer";
import { ClusterSymbol } from "./layers/ClusterSymbol";
import { parseJSON } from "./utils";

@@ -3,0 +3,0 @@ import * as serializer from "@evergis/sgis/serializers/symbolSerializer";

@@ -18,3 +18,3 @@ import { SpatialProcessor } from "./SpatialProcessor";

import { TileService } from "./services/TileService";
import { ClusterLayer, ClusterSymbol } from "./layers/ClusterLayer";
import { ClusterLayer } from "./layers/ClusterLayer";
import { DataViewLayer } from "./layers/DataViewLayer";

@@ -30,2 +30,3 @@ import { Controller } from "./controllers/Controller";

import { ServiceSnappingProvider } from "./ServiceSnappingProvider";
import { ClusterSymbol } from "./layers/ClusterSymbol";
declare const _default: {

@@ -32,0 +33,0 @@ sp: {

@@ -18,3 +18,3 @@ import { SpatialProcessor } from "./SpatialProcessor";

import { TileService } from "./services/TileService";
import { ClusterLayer, ClusterSymbol } from "./layers/ClusterLayer";
import { ClusterLayer } from "./layers/ClusterLayer";
import { DataViewLayer } from "./layers/DataViewLayer";

@@ -30,2 +30,3 @@ import { Controller } from "./controllers/Controller";

import { ServiceSnappingProvider } from "./ServiceSnappingProvider";
import { ClusterSymbol } from "./layers/ClusterSymbol";
const sp = {

@@ -68,6 +69,6 @@ SpatialProcessor: SpatialProcessor,

ServiceSnappingProvider: ServiceSnappingProvider,
version: "0.4.20",
releaseDate: "19.03.2019"
version: "0.4.21",
releaseDate: "27.03.2019"
};
export default { sp };
//# sourceMappingURL=everGis.js.map
import { Layer } from "@evergis/sgis/layers/Layer";
import { PointSymbol } from "@evergis/sgis/symbols/point/Point";
import { VectorLabel } from "@evergis/sgis/renders/VectorLabel";
import { Arc } from "@evergis/sgis/renders/Arc";
import { Bbox } from "@evergis/sgis/Bbox";
import { Render } from "@evergis/sgis/renders/Render";
import { ClusterSymbol } from "./ClusterSymbol";
export declare class ClusterLayer extends Layer {

@@ -28,45 +26,1 @@ _updateRequest: any[];

}
export declare class ClusterSymbol extends PointSymbol {
private _sortedPieValues;
size: number;
fillColor: string;
strokeColor: string;
strokeWidth: number;
clusterSize: number;
minSize: number;
maxSize: number;
sizeAggregationIndex: number;
sizeAggregationMaxValue: number;
pieAggregationIndex: number;
_pieGroups: {};
labelText: any;
_singleObjectSymbol: any;
gridSize: number;
constructor(properties?: Object);
renderFunction(feature: any, resolution: any, crs: any): any;
_renderLabel(position: any, feature: any): VectorLabel;
_applySizeClassifier(circleRender: any, feature: any): void;
_applyChartClassifier(feature: any, center: any, radius: any): Arc[];
resetClassification(): void;
clearPieGroups(): void;
addPieGroup(attributeValue: any, color: any): void;
_sortPieGroups(): void;
clone(): ClusterSymbol;
serialize(): {
size: number;
fillColor: string;
strokeColor: string;
strokeWidth: number;
clusterSize: number;
minSize: number;
maxSize: number;
sizeAggregationIndex: number;
sizeAggregationMaxValue: number;
pieAggregationIndex: number;
_pieGroups: {};
labelText: any;
singleObjectSymbol: any;
gridSize: number;
};
singleObjectSymbol: any;
}

@@ -1,31 +0,6 @@

var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};
import { Layer } from "@evergis/sgis/layers/Layer";
import { PointSymbol } from "@evergis/sgis/symbols/point/Point";
import { VectorLabel } from "@evergis/sgis/renders/VectorLabel";
import { ajax } from "../utils";
import { PointFeature } from "@evergis/sgis/features/PointFeature";
import { Polygon } from "@evergis/sgis/features/Polygon";
import * as symbolSerializer from "@evergis/sgis/serializers/symbolSerializer";
import { Arc } from "@evergis/sgis/renders/Arc";
import { Symbol } from "@evergis/sgis/symbols/Symbol";
import { HorizontalAlignment, VerticalAlignment } from "@evergis/sgis/renders/VectorLabel";
class ClusterFeature extends PointFeature {
constructor(position, _a) {
var { objectCount, aggregations, setNo, ids, boundingPolygon } = _a, params = __rest(_a, ["objectCount", "aggregations", "setNo", "ids", "boundingPolygon"]);
super(position, params);
this.objectCount = objectCount;
this.aggregations = aggregations;
this.setNo = setNo;
this.ids = ids;
this.boundingPolygon = boundingPolygon;
}
}
import { ClusterSymbol } from "./ClusterSymbol";
import { ClusterFeature } from "./ClusterFeature";
export class ClusterLayer extends Layer {

@@ -137,158 +112,2 @@ constructor(serviceUrl, sessionId, symbol = new ClusterSymbol()) {

}
export class ClusterSymbol extends PointSymbol {
constructor(properties) {
super();
this.size = 50;
this.fillColor = 'rgba(0, 183, 255, 1)';
this.strokeColor = 'white';
this.strokeWidth = 2;
this.clusterSize = 10;
this.minSize = 50;
this.maxSize = 50;
this.sizeAggregationIndex = -1;
this.sizeAggregationMaxValue = 0;
this.pieAggregationIndex = -1;
this._pieGroups = {};
this.labelText = null;
this._singleObjectSymbol = null;
this.gridSize = 100;
if (properties)
Object.assign(this, properties);
}
renderFunction(feature, resolution, crs) {
if (this.singleObjectSymbol && feature.objectCount === 1)
return this.singleObjectSymbol.renderFunction(feature, resolution, crs);
let renders = super.renderFunction.call(this, feature, resolution, crs);
this._applySizeClassifier(renders[0], feature);
if (this.pieAggregationIndex >= 0) {
let pieChart = this._applyChartClassifier(feature, renders[0].center, renders[0].radius);
if (pieChart && pieChart.length > 0) {
renders[0].radius -= this.clusterSize;
renders = pieChart.concat(renders);
}
}
if (this.labelText)
renders.push(this._renderLabel(renders[0].center, feature));
return renders;
}
_renderLabel(position, feature) {
let text = this.labelText.replace('{__qty}', feature.objectCount || '');
return new VectorLabel({ position, text, fontSize: 10, horizontalAlignment: HorizontalAlignment.Center, verticalAlignment: VerticalAlignment.Middle });
}
_applySizeClassifier(circleRender, feature) {
if (feature.objectCount === undefined || !this.minSize || !this.maxSize || !this.sizeAggregationMaxValue)
return;
let minSize = this.minSize;
let maxSize = this.maxSize;
let maxCount = this.sizeAggregationMaxValue;
let value = this.sizeAggregationIndex <= 0 ? feature.objectCount : feature.aggregations[this.sizeAggregationIndex].value;
let size = Math.min(this.maxSize, (minSize + value / maxCount * (maxSize - minSize)));
circleRender.radius = size / 2;
}
_applyChartClassifier(feature, center, radius) {
if (!feature.aggregations || !feature.aggregations[this.pieAggregationIndex])
return;
let aggr = feature.aggregations[this.pieAggregationIndex];
if (!aggr)
return;
let totalCount = aggr.reduce((sum, item) => sum + item.count, 0);
if (!totalCount)
return;
let startAngle = -Math.PI / 2;
let pies = {};
Object.keys(this._pieGroups).forEach(key => pies[key] = 0);
if (!this._sortedPieValues)
this._sortPieGroups();
aggr.forEach(distinct => {
let pieValue;
if (this._pieGroups[distinct.value]) {
pieValue = distinct.value;
}
else {
for (let i = 0; i < this._sortedPieValues.length; i++) {
if (distinct.value > this._sortedPieValues[i])
continue;
pieValue = this._sortedPieValues[i];
break;
}
}
if (pieValue === undefined) {
pieValue = this._sortedPieValues[this._sortedPieValues.length - 1];
}
if (this._pieGroups[pieValue]) {
pies[pieValue] += distinct.count;
}
});
let renders = Object.keys(pies).filter(key => pies[key] > 0).map(key => {
let count = pies[key];
let angle = count / totalCount * Math.PI * 2;
let fillColor = this._pieGroups[key] || this.fillColor;
let arc = new Arc(center, {
fillColor: fillColor,
strokeColor: this.strokeColor,
strokeWidth: this.strokeWidth,
radius: radius,
startAngle: startAngle,
endAngle: startAngle + angle,
isSector: true
});
startAngle += angle;
return arc;
});
return renders;
}
resetClassification() {
this.sizeAggregationIndex = -1;
this.sizeAggregationMaxValue = 1;
this.pieAggregationIndex = -1;
this._pieGroups = {};
}
clearPieGroups() {
this._pieGroups = {};
}
addPieGroup(attributeValue, color) {
this._pieGroups[attributeValue] = color;
this._sortPieGroups();
}
_sortPieGroups() {
let keys = Object.keys(this._pieGroups);
this._sortedPieValues = keys.map(key => isNaN(key) ? key : parseFloat(key)).sort((a, b) => {
if (a < b)
return -1;
if (a > b)
return 1;
return 0;
});
}
clone() {
return new ClusterSymbol(this.serialize());
}
serialize() {
return {
size: this.size,
fillColor: this.fillColor,
strokeColor: this.strokeColor,
strokeWidth: this.strokeWidth,
clusterSize: this.clusterSize,
minSize: this.minSize,
maxSize: this.maxSize,
sizeAggregationIndex: this.sizeAggregationIndex,
sizeAggregationMaxValue: this.sizeAggregationMaxValue,
pieAggregationIndex: this.pieAggregationIndex,
_pieGroups: this._pieGroups,
labelText: this.labelText,
singleObjectSymbol: this.singleObjectSymbol && (this.singleObjectSymbol.serialize && this.singleObjectSymbol.serialize() || symbolSerializer.serialize(this.singleObjectSymbol)),
gridSize: this.gridSize
};
}
get singleObjectSymbol() { return this._singleObjectSymbol; }
set singleObjectSymbol(symbol) {
if (!symbol || symbol instanceof Symbol) {
this._singleObjectSymbol = symbol;
}
else {
this._singleObjectSymbol = symbolSerializer.deserialize(symbol);
}
}
}
//# sourceMappingURL=ClusterLayer.js.map
import { Layer } from "@evergis/sgis/layers/Layer";
import { ClusterLayer, ClusterSymbol } from "./ClusterLayer";
import { ClusterLayer } from "./ClusterLayer";
import { SpDynamicLayer } from "./SpDynamicLayer";
import { ClusterSymbol } from "./ClusterSymbol";
export class DataViewLayer extends Layer {

@@ -5,0 +6,0 @@ constructor(service) {

{
"name": "@evergis/sp-api",
"version": "0.4.20",
"version": "0.4.21",
"description": "",

@@ -29,3 +29,3 @@ "main": "dist/compilation/everGis.js",

"peerDependencies": {
"@evergis/sgis": ">=0.4.0"
"@evergis/sgis": ">=0.4.7"
},

@@ -36,5 +36,5 @@ "devDependencies": {

"rollup-plugin-node-resolve": "^3.0.0",
"@evergis/sgis": "^0.4.1",
"@evergis/sgis": "^0.4.7",
"typescript": "^2.5.3"
}
}

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

import {ClusterSymbol} from "./layers/ClusterLayer";
import {ClusterSymbol} from "./layers/ClusterSymbol";
import {parseJSON} from "./utils";

@@ -3,0 +3,0 @@ import * as serializer from "@evergis/sgis/serializers/symbolSerializer";

@@ -18,3 +18,3 @@ import {SpatialProcessor} from "./SpatialProcessor";

import {TileService} from "./services/TileService";
import {ClusterLayer, ClusterSymbol} from "./layers/ClusterLayer";
import {ClusterLayer} from "./layers/ClusterLayer";
import {DataViewLayer} from "./layers/DataViewLayer";

@@ -30,2 +30,3 @@ import {Controller} from "./controllers/Controller";

import {ServiceSnappingProvider} from "./ServiceSnappingProvider";
import {ClusterSymbol} from "./layers/ClusterSymbol";

@@ -69,6 +70,6 @@ const sp = {

ServiceSnappingProvider: ServiceSnappingProvider,
version: "0.4.20",
releaseDate: "19.03.2019"
version: "0.4.21",
releaseDate: "27.03.2019"
};
export default {sp};
import {Layer} from "@evergis/sgis/layers/Layer";
import {PointSymbol} from "@evergis/sgis/symbols/point/Point";
import {VectorLabel} from "@evergis/sgis/renders/VectorLabel";
import {ajax} from "../utils";
import {PointFeature} from "@evergis/sgis/features/PointFeature";
import {Polygon} from "@evergis/sgis/features/Polygon";
import * as symbolSerializer from "@evergis/sgis/serializers/symbolSerializer";
import {Arc} from "@evergis/sgis/renders/Arc";
import {Symbol} from "@evergis/sgis/symbols/Symbol";
import {Bbox} from "@evergis/sgis/Bbox";
import {Render} from "@evergis/sgis/renders/Render";
import {Feature, FeatureParams} from "@evergis/sgis/features/Feature";
import {HorizontalAlignment, VerticalAlignment} from "@evergis/sgis/renders/VectorLabel";
import {Coordinates} from "@evergis/sgis/baseTypes";
import {Feature} from "@evergis/sgis/features/Feature";
import {StaticVectorImageRender} from "@evergis/sgis/renders/StaticVectorImageRender";
import {ClusterSymbol} from "./ClusterSymbol";
import {ClusterFeature} from "./ClusterFeature";
interface ClusterFeatureParams extends FeatureParams {
objectCount: number;
aggregations: any;
setNo: number;
ids: number[];
boundingPolygon: any;
}
class ClusterFeature extends PointFeature {
objectCount: number;
aggregations: any;
setNo: number;
ids: number[];
boundingPolygon: any;
constructor(position: Coordinates, {objectCount, aggregations, setNo, ids, boundingPolygon, ...params}: ClusterFeatureParams) {
super(position, params);
this.objectCount = objectCount;
this.aggregations = aggregations;
this.setNo = setNo;
this.ids = ids;
this.boundingPolygon = boundingPolygon;
}
}
export class ClusterLayer extends Layer {

@@ -172,179 +141,1 @@ _updateRequest: any[];

export class ClusterSymbol extends PointSymbol {
private _sortedPieValues: (string | number)[];
size = 50;
fillColor = 'rgba(0, 183, 255, 1)';
strokeColor = 'white';
strokeWidth = 2;
clusterSize = 10;
minSize = 50;
maxSize = 50;
sizeAggregationIndex = -1;
sizeAggregationMaxValue = 0;
pieAggregationIndex = -1;
_pieGroups = {};
labelText = null;
_singleObjectSymbol = null;
gridSize = 100;
constructor(properties?: Object) {
super();
if (properties) Object.assign(this, properties);
}
renderFunction(feature, resolution, crs) {
if (this.singleObjectSymbol && feature.objectCount === 1) return this.singleObjectSymbol.renderFunction(feature, resolution, crs);
let renders = super.renderFunction.call(this, feature, resolution, crs);
this._applySizeClassifier(renders[0], feature);
if (this.pieAggregationIndex >= 0) {
let pieChart = this._applyChartClassifier(feature, renders[0].center, renders[0].radius);
if (pieChart && pieChart.length > 0) {
renders[0].radius -= this.clusterSize;
renders = pieChart.concat(renders);
}
}
if (this.labelText) renders.push(this._renderLabel(renders[0].center, feature));
return renders;
}
_renderLabel(position, feature) {
let text = this.labelText.replace('{__qty}', feature.objectCount || '');
return new VectorLabel({position, text, fontSize: 10, horizontalAlignment: HorizontalAlignment.Center, verticalAlignment: VerticalAlignment.Middle});
}
_applySizeClassifier(circleRender, feature) {
if (feature.objectCount === undefined || !this.minSize || !this.maxSize || !this.sizeAggregationMaxValue) return;
let minSize = this.minSize;
let maxSize = this.maxSize;
let maxCount = this.sizeAggregationMaxValue;
let value = this.sizeAggregationIndex <= 0 ? feature.objectCount : feature.aggregations[this.sizeAggregationIndex].value;
let size = Math.min(this.maxSize, (minSize + value / maxCount * (maxSize - minSize)));
circleRender.radius = size / 2;
}
_applyChartClassifier(feature, center, radius) {
if (!feature.aggregations || !feature.aggregations[this.pieAggregationIndex]) return;
let aggr = feature.aggregations[this.pieAggregationIndex];
if (!aggr) return;
let totalCount = aggr.reduce((sum, item) => sum + item.count, 0);
if (!totalCount) return;
let startAngle = -Math.PI / 2;
let pies = {};
Object.keys(this._pieGroups).forEach(key => pies[key] = 0);
if (!this._sortedPieValues) this._sortPieGroups();
aggr.forEach(distinct => {
let pieValue;
if (this._pieGroups[distinct.value]) {
pieValue = distinct.value;
} else {
for (let i = 0; i < this._sortedPieValues.length; i++) {
if (distinct.value > this._sortedPieValues[i]) continue;
pieValue = this._sortedPieValues[i];
break;
}
}
if (pieValue === undefined) {
pieValue = this._sortedPieValues[this._sortedPieValues.length - 1];
}
if (this._pieGroups[pieValue]) {
pies[pieValue] += distinct.count;
}
});
let renders = Object.keys(pies).filter(key => pies[key] > 0).map(key => {
let count = pies[key];
let angle = count / totalCount * Math.PI * 2;
let fillColor = this._pieGroups[key] || this.fillColor;
let arc = new Arc(center, {
fillColor: fillColor,
strokeColor: this.strokeColor,
strokeWidth: this.strokeWidth,
radius: radius,
startAngle: startAngle,
endAngle: startAngle + angle,
isSector: true
});
startAngle += angle;
return arc;
});
return renders;
}
resetClassification() {
this.sizeAggregationIndex = -1;
this.sizeAggregationMaxValue = 1;
this.pieAggregationIndex = -1;
this._pieGroups = {};
}
clearPieGroups() {
this._pieGroups = {};
}
addPieGroup(attributeValue, color) {
this._pieGroups[attributeValue] = color;
this._sortPieGroups();
}
_sortPieGroups() {
let keys = Object.keys(this._pieGroups);
this._sortedPieValues = keys.map(key => isNaN(<any>key) ? key : parseFloat(key)).sort((a, b) => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
});
}
clone() {
return new ClusterSymbol(this.serialize());
}
serialize() {
return {
size: this.size,
fillColor: this.fillColor,
strokeColor: this.strokeColor,
strokeWidth: this.strokeWidth,
clusterSize: this.clusterSize,
minSize: this.minSize,
maxSize: this.maxSize,
sizeAggregationIndex: this.sizeAggregationIndex,
sizeAggregationMaxValue: this.sizeAggregationMaxValue,
pieAggregationIndex: this.pieAggregationIndex,
_pieGroups: this._pieGroups,
labelText: this.labelText,
singleObjectSymbol: this.singleObjectSymbol && (this.singleObjectSymbol.serialize && this.singleObjectSymbol.serialize() || symbolSerializer.serialize(this.singleObjectSymbol)),
gridSize: this.gridSize
};
}
get singleObjectSymbol() { return this._singleObjectSymbol; }
set singleObjectSymbol(symbol) {
if (!symbol || symbol instanceof Symbol) {
this._singleObjectSymbol = symbol;
} else {
this._singleObjectSymbol = symbolSerializer.deserialize(symbol);
}
}
}
import {Layer} from "@evergis/sgis/layers/Layer";
import {DynamicLayer} from "@evergis/sgis/layers/DynamicLayer";
import {ClusterLayer, ClusterSymbol} from "./ClusterLayer";
import {ClusterLayer} from "./ClusterLayer";
import {SpDynamicLayer} from "./SpDynamicLayer";
import {Bbox} from "@evergis/sgis/Bbox";
import {Render} from "@evergis/sgis/renders/Render";
import {ClusterSymbol} from "./ClusterSymbol";

@@ -8,0 +9,0 @@ export class DataViewLayer extends Layer {

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

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