@golemio/mvt-maps 0.0.1 → 0.0.2-rc.1856556618

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
14
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.V2MvtController = void 0;
25
16
  const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
@@ -29,17 +20,17 @@ const MvtClusterService_1 = require("../services/MvtClusterService");
29
20
  let V2MvtController = exports.V2MvtController = class V2MvtController {
30
21
  constructor(service) {
31
22
  this.service = service;
32
- this.getAll = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
23
+ this.getAll = async (req, res, next) => {
33
24
  try {
34
25
  const params = this.parseParams(req);
35
- const result = yield this.service.getTile(params.table, params.geometry, params.x, params.y, params.z, params.maxZoom, params.attributes, params.radius);
26
+ const result = await this.service.getTile(params.table, params.geometry, params.x, params.y, params.z, params.maxZoom, params.attributes, params.radius, params.clusterPoint);
36
27
  res.setHeader("Content-Type", "application/vnd.mapbox-vector-tile");
37
28
  res.status(200).send(result);
38
29
  }
39
30
  catch (err) {
40
31
  next(err);
41
32
  }
42
- });
33
+ };
43
34
  }
44
35
  parseParams(req) {
45
36
  try {
@@ -54,6 +45,7 @@ let V2MvtController = exports.V2MvtController = class V2MvtController {
54
45
  : [req.query.attributes],
55
46
  radius: req.query.radius ? parseInt(req.query.radius) : undefined,
56
47
  maxZoom: parseInt(req.query.maxZoom),
48
+ clusterPoint: req.query.clusterPoint ? req.query.clusterPoint : undefined,
57
49
  };
58
50
  }
59
51
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"V2MvtController.js","sourceRoot":"","sources":["../../../src/output-gateway/controllers/V2MvtController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,6EAAwE;AACxE,iEAAwE;AAExE,sEAAoE;AACpE,qEAAmE;AAG5D,IAAM,eAAe,6BAArB,MAAM,eAAe;IACxB,YAA4D,OAAkC;QAA1B,YAAO,GAAP,OAAO,CAAmB;QAEvF,WAAM,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACtE,IAAI;gBACA,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;gBACrC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CACrC,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,CAAC,EACR,MAAM,CAAC,CAAC,EACR,MAAM,CAAC,CAAC,EACR,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,MAAM,CAChB,CAAC;gBAEF,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,oCAAoC,CAAC,CAAC;gBACpE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAChC;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,CAAC;aACb;QACL,CAAC,CAAA,CAAC;IArB+F,CAAC;IAuB1F,WAAW,CAAC,GAAY;QAC5B,IAAI;YACA,OAAO;gBACH,CAAC,EAAE,QAAQ,CAAC,GAAG,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AK,CAAC,UAAoB,CAAC;gBACtC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAgB,CAAC,CAAC,CAAC,CAAC,SAAS;gBAC3E,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,OAAiB,CAAC;gBAC9C,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAE,GAAG,CAAC,KAAK,CAAC,YAAuB,CAAC,CAAC,CAAC,SAAS;aACxF,CAAC;SACL;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,6BAAY,CAAC,qBAAqB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;SAClF;IACL,CAAC;CACJ,CAAA;0BA5CY,eAAe;IAD3B,IAAA,qBAAU,GAAE;IAEI,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,iBAAiB,CAAC,CAAA;qCAAkB,qCAAiB;GADrF,eAAe,CA4C3B"}
@@ -26,6 +26,7 @@ class V2MvtRouter extends AbstractRouter_1.AbstractRouter {
26
26
  (0, express_validator_1.query)("attributes.*").exists().isString().not().isArray(),
27
27
  (0, express_validator_1.query)("maxZoom").exists().isInt(),
28
28
  (0, express_validator_1.query)("radius").optional().isInt(),
29
+ (0, express_validator_1.query)("clusterPoint").optional().isString().not().isArray(),
29
30
  ], Validation_1.checkErrors, this.cacheHeaderMiddleware.getMiddleware(5 * 60, 60), this.controller.getAll);
30
31
  }
31
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"V2MvtRouter.js","sourceRoot":"","sources":["../../../src/output-gateway/routers/V2MvtRouter.ts"],"names":[],"mappings":";;;AAAA,kCAA0C;AAC1C,sEAAoE;AACpE,sFAAmF;AAEnF,+DAAuE;AACvE,6EAA2E;AAC3E,mFAA2E;AAC3E,2CAA2C;AAG3C,MAAM,WAAY,S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,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE;YAClD,IAAA,yBAAK,EAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE;YACrD,IAAA,yBAAK,EAAC,YAAY,CAAC,CAAC,MAAM,EAAE;YAC5B,IAAA,yBAAK,EAAC,cAAc,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE;YACzD,IAAA,yBAAK,EAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;YACjC,IAAA,yBAAK,EAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;YAClC,IAAA,yBAAK,EAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE;SAC9D,EACD,wBAAW,EACX,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,EACpD,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;IACN,CAAC;CACJ;AAED,MAAM,WAAW,GAAmB,IAAI,WAAW,EAAE,CAAC;AAE7C,kCAAW"}
@@ -7,4 +7,5 @@ export interface IMvtParams {
7
7
  attributes: string[];
8
8
  radius?: number;
9
9
  maxZoom: number;
10
+ clusterPoint?: string;
10
11
  }
@@ -1,10 +1,12 @@
1
- import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
2
1
  import { ILogger } from "@golemio/core/dist/helpers";
2
+ import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
3
3
  export declare class MvtClusterService {
4
4
  private connector;
5
5
  private logger;
6
6
  constructor(connector: IDatabaseConnector, logger: ILogger);
7
- getTile(table: string, geometry: string, x: number, y: number, z: number, zoomLevel: number, attributes: string[], radius?: number): Promise<Uint8Array>;
8
- private defaultGetBaseQuery;
9
- private defaultGetTileQuery;
7
+ getTile(table: string, geometry: string, x: number, y: number, z: number, zoomLevel: number, attributes: string[], radius?: number, clusterPoint?: string): Promise<Uint8Array>;
8
+ private getBaseQuery;
9
+ private getLevelClusterQuery;
10
+ private getLevelGroupQuery;
11
+ private getTileQuery;
10
12
  }
@@ -11,75 +11,100 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
14
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.MvtClusterService = void 0;
25
- const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
26
16
  const clusterbuster_1 = require("@golemio/clusterbuster");
27
17
  const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
28
- const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
29
18
  const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
19
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
20
+ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
30
21
  let MvtClusterService = exports.MvtClusterService = class MvtClusterService {
31
22
  constructor(connector, logger) {
32
23
  this.connector = connector;
33
24
  this.logger = logger;
34
- this.defaultGetBaseQuery = ({ x, y, z, table, geometry, maxZoomLevel, attributes, query, }) => `
35
- SELECT
36
- ${geometry} AS center,
25
+ this.getBaseQuery = (clusterPoint) => {
26
+ return ({ x, y, z, table, geometry, maxZoomLevel, attributes, query }) => `SELECT
27
+ ${clusterPoint} AS center,
28
+ ${geometry} as zoomGeom,
37
29
  1 AS size,
38
30
  0 AS clusterNo,
39
31
  ${maxZoomLevel + 1} AS expansionZoom${attributes}
40
32
  FROM ${table}
41
33
  WHERE
42
34
  ST_Intersects(TileBBox(${z}, ${x}, ${y}, 4326), ${geometry})
43
- ${query.length > 0 ? `AND ${query.join(" AND ")}` : ""}
44
- `;
45
- this.defaultGetTileQuery = ({ x, y, z, table, geometry, extent, bufferSize, attributes }) => `
46
- SELECT
47
- ST_AsMVTGeom(${geometry}, TileBBox(${z}, ${x}, ${y}, 4326), ${extent}, ${bufferSize}, false) AS geom,
35
+ ${query.length > 0 ? `AND ${query.join(" AND ")}` : ""}`;
36
+ };
37
+ this.getLevelClusterQuery = ({ parentTable, zoomLevel, radius, attributes, zoomToDistance, }) => {
38
+ return `SELECT
39
+ center,
40
+ zoomGeom,
41
+ expansionZoom,
42
+ clusterNo AS previousClusterNo,
43
+ size,
44
+ ST_ClusterDBSCAN(center, ${zoomToDistance(zoomLevel, radius)}, 1) over () as clusters${attributes}
45
+ FROM ${parentTable}`;
46
+ };
47
+ this.getLevelGroupQuery = ({ zoomLevel, attributes }) => {
48
+ return `SELECT
49
+ SUM(size) as size,
50
+ clusters AS clusterNo,
51
+ (
52
+ CASE COUNT(previousClusterNo)
53
+ WHEN 1 THEN FIRST(expansionZoom)
54
+ ELSE ${zoomLevel + 1} END
55
+ ) AS expansionZoom, ${attributes}
56
+ ST_Centroid(ST_Collect(center)) as center,
57
+ FIRST(zoomGeom) as zoomGeom
58
+ FROM clustered_${zoomLevel}
59
+ GROUP BY clusters`;
60
+ };
61
+ this.getTileQuery = ({ x, y, z, table, geometry, extent, bufferSize, attributes }) => {
62
+ return `SELECT
63
+ case size
64
+ WHEN 1 THEN
65
+ ST_AsMVTGeom(ST_Transform(zoomGeom, 3857), TileBBox(${z}, ${x}, ${y}, 3857), ${extent}, ${bufferSize}, false)
66
+ ELSE ST_AsMVTGeom(ST_Transform(${geometry}, 3857), TileBBox(${z}, ${x}, ${y}, 3857), ${extent}, ${bufferSize}, false)
67
+ end AS geom,
48
68
  jsonb_build_object(
49
69
  'count', size,
50
70
  'expansionZoom', expansionZoom${attributes}
51
71
  ) AS attributes
52
- FROM ${table}
53
- `;
72
+ FROM ${table}`;
73
+ };
54
74
  }
55
- getTile(table, geometry, x, y, z, zoomLevel, attributes, radius = 15) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const defaultConfig = {
58
- sourceLayer: "points",
59
- extent: 4096,
60
- bufferSize: 256,
61
- debug: false,
62
- query: [],
63
- getBaseQuery: this.defaultGetBaseQuery,
64
- getTileQuery: this.defaultGetTileQuery,
65
- };
66
- const query = (0, clusterbuster_1.createQueryForTile)(Object.assign(Object.assign({}, defaultConfig), { z,
67
- x,
68
- y, maxZoomLevel: zoomLevel, table,
69
- geometry,
70
- radius,
71
- attributes }));
72
- try {
73
- const result = yield this.connector.getConnection().query(query, {
74
- type: sequelize_1.QueryTypes.SELECT,
75
- });
76
- return result[0].mvt;
77
- }
78
- catch (error) {
79
- this.logger.error(error, `Error while getting tile: ${query}`);
80
- throw new golemio_errors_1.GeneralError("Error while getting tile", this.constructor.name, error);
81
- }
75
+ async getTile(table, geometry, x, y, z, zoomLevel, attributes, radius = 15, clusterPoint) {
76
+ const defaultConfig = {
77
+ sourceLayer: "points",
78
+ extent: 4096,
79
+ bufferSize: 256,
80
+ debug: false,
81
+ query: [],
82
+ getBaseQuery: this.getBaseQuery(clusterPoint ?? geometry),
83
+ getTileQuery: this.getTileQuery,
84
+ };
85
+ const query = (0, clusterbuster_1.createQueryForTile)({
86
+ ...defaultConfig,
87
+ z,
88
+ x,
89
+ y,
90
+ maxZoomLevel: zoomLevel,
91
+ table,
92
+ geometry: geometry,
93
+ radius,
94
+ attributes,
95
+ getLevelClusterQuery: this.getLevelClusterQuery,
96
+ getLevelGroupQuery: this.getLevelGroupQuery,
82
97
  });
98
+ try {
99
+ const result = await this.connector.getConnection().query(query, {
100
+ type: sequelize_1.QueryTypes.SELECT,
101
+ });
102
+ return result[0].mvt;
103
+ }
104
+ catch (error) {
105
+ this.logger.error(error, `Error while getting tile: ${query}`);
106
+ throw new golemio_errors_1.GeneralError("Error while getting tile", this.constructor.name, error);
107
+ }
83
108
  }
84
109
  };
85
110
  exports.MvtClusterService = MvtClusterService = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"MvtClusterService.js","sourceRoot":"","sources":["../../../src/output-gateway/services/MvtClusterService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAwE;AACxE,0DAAqH;AACrH,wEAAqE;AAErE,mEAAiE;AACjE,6EAAwE;AAIjE,IAAM,iBAAiB,+BAAvB,MAAM,iBAAiB;IAC1B,YACyC,SAAqC,EAChD,MAAuB;QADJ,cAAS,GAAT,SAAS,CAAoB;QACxC,WAAM,GAAN,MAAM,CAAS;QA8C7C,wBAAmB,GAAiB,CAAC,EACzC,CAAC,EACD,CAAC,EACD,CAAC,EACD,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,KAAK,GACS,EAAE,EAAE,CAAC;;YAEf,QAAQ;;;YAGR,YAAY,GAAG,CAAC,oBAAoB,UAAU;eAC3C,KAAK;;qCAEiB,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,QAAQ;cACxD,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;KAC7D,CAAC;QAEM,wBAAmB,GAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAc,EAAE,EAAE,CAAC;;yBAErG,QAAQ,cAAc,CAAC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,CAAC,MAAM;aAC1B,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;SACxB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,6BAA6B,KAAK,EAAE,CAAC,CAAC;YAC/D,MAAM,IAAI,6BAAY,CAAC,0BAA0B,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACpF;IACL,CAAC;CA4DJ,CAAA;4BA9GY,iBAAiB;IAD7B,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,iBAAiB,CAAC,CAAA;IACnC,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;;GAHpB,iBAAiB,CA8G7B"}
@@ -66,7 +66,7 @@ paths:
66
66
  required: true
67
67
  schema:
68
68
  type: string
69
- example: point
69
+ example: location
70
70
  - name: attributes
71
71
  in: query
72
72
  description: List of attribute columns to include in the tile features.
@@ -79,7 +79,7 @@ paths:
79
79
  - name: maxZoom
80
80
  in: query
81
81
  description: Maximum zoom level at which data from this table should be rendered.
82
- required: false
82
+ required: true
83
83
  schema:
84
84
  type: number
85
85
  example: 12
@@ -89,7 +89,15 @@ paths:
89
89
  required: false
90
90
  schema:
91
91
  type: number
92
+ default: 15
92
93
  example: 15
94
+ - name: clusterPoint
95
+ in: query
96
+ description: Name of the column that will be used for clustering, use only if it differs from geometry. (e.g. calculating clustering for polygons can take longer and result in bigger clusters.)
97
+ required: false
98
+ schema:
99
+ type: string
100
+ example: point
93
101
  responses:
94
102
  200:
95
103
  description: OK
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/mvt-maps",
3
- "version": "0.0.1",
3
+ "version": "0.0.2-rc.1856556618",
4
4
  "description": "Golemio MVT Maps Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,9 +34,9 @@
34
34
  "@apideck/portman": "^1.26.5",
35
35
  "@commitlint/cli": "^19.3.0",
36
36
  "@commitlint/config-conventional": "^11.0.0",
37
- "@golemio/cli": "1.6.1",
38
- "@golemio/core": "1.13.4-dev.1428623255",
39
- "@golemio/db-common": "1.1.6-dev.1825018482",
37
+ "@golemio/cli": "1.10.0",
38
+ "@golemio/core": "1.20.7",
39
+ "@golemio/db-common": "1.2.0",
40
40
  "@golemio/eslint-config": "1.1.2",
41
41
  "@types/chai": "4.2.3",
42
42
  "@types/chai-as-promised": "7.1.2",
@@ -69,7 +69,7 @@
69
69
  "typescript-transform-paths": "^3.4.6"
70
70
  },
71
71
  "dependencies": {
72
- "@golemio/clusterbuster": "0.0.0-development-diversion.1-dev.1825112551"
72
+ "@golemio/clusterbuster": "2.9.1-diversion.1"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "@golemio/core": ">=1.20.5"