@mwater/visualization 5.6.0 → 5.6.1
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.
- package/lib/ColorComponent.js +2 -2
- package/lib/TranslationsTabComponent.d.ts +34 -0
- package/lib/TranslationsTabComponent.js +256 -0
- package/lib/dashboards/DashboardComponent.js +1 -1
- package/lib/dashboards/ServerDashboardDataSource.d.ts +0 -1
- package/lib/dashboards/ServerDashboardDataSource.js +0 -15
- package/lib/dashboards/SettingsModalComponent.js +9 -233
- package/lib/datagrids/DatagridComponent.js +5 -0
- package/lib/datagrids/DatagridViewComponent.js +30 -4
- package/lib/maps/BufferLayer.d.ts +0 -13
- package/lib/maps/BufferLayer.js +12 -237
- package/lib/maps/BufferLayerDesignerComponent.d.ts +1 -1
- package/lib/maps/BufferLayerDesignerComponent.js +0 -5
- package/lib/maps/ChoroplethLayer.d.ts +1 -16
- package/lib/maps/ChoroplethLayer.js +13 -358
- package/lib/maps/ClusterLayer.d.ts +0 -9
- package/lib/maps/ClusterLayer.js +0 -250
- package/lib/maps/DirectMapDataSource.js +1 -38
- package/lib/maps/GridLayer.d.ts +0 -15
- package/lib/maps/GridLayer.js +0 -212
- package/lib/maps/Layer.d.ts +1 -26
- package/lib/maps/Layer.js +0 -13
- package/lib/maps/MapComponent.d.ts +19 -35
- package/lib/maps/MapComponent.js +135 -76
- package/lib/maps/MapControlComponent.d.ts +4 -5
- package/lib/maps/MapControlComponent.js +5 -12
- package/lib/maps/MapDesign.d.ts +8 -0
- package/lib/maps/MapDesignerComponent.d.ts +2 -0
- package/lib/maps/MapDesignerComponent.js +7 -2
- package/lib/maps/MapLayerDataSource.d.ts +0 -4
- package/lib/maps/MapLayerViewDesignerComponent.d.ts +3 -1
- package/lib/maps/MapLayerViewDesignerComponent.js +5 -1
- package/lib/maps/MapLayersDesignerComponent.d.ts +2 -0
- package/lib/maps/MapLayersDesignerComponent.js +2 -1
- package/lib/maps/MapTranslationsTab.d.ts +15 -0
- package/lib/maps/MapTranslationsTab.js +47 -0
- package/lib/maps/MapUtils.d.ts +11 -0
- package/lib/maps/MapUtils.js +47 -0
- package/lib/maps/MapViewComponent.d.ts +1 -1
- package/lib/maps/MapViewComponent.js +1 -8
- package/lib/maps/MarkersLayer.d.ts +1 -14
- package/lib/maps/MarkersLayer.js +71 -252
- package/lib/maps/MarkersLayerDesign.d.ts +4 -0
- package/lib/maps/MarkersLayerDesignerComponent.d.ts +20 -16
- package/lib/maps/MarkersLayerDesignerComponent.js +77 -23
- package/lib/maps/ServerMapDataSource.d.ts +0 -1
- package/lib/maps/ServerMapDataSource.js +0 -15
- package/lib/maps/SwitchableTileUrlLayer.d.ts +0 -2
- package/lib/maps/SwitchableTileUrlLayer.js +0 -9
- package/lib/maps/TileUrlLayer.d.ts +0 -1
- package/lib/maps/TileUrlLayer.js +0 -5
- package/lib/maps/VectorMapViewComponent.js +12 -1
- package/lib/maps/vectorMaps.d.ts +5 -6
- package/lib/maps/vectorMaps.js +13 -9
- package/lib/widgets/MapWidget.js +2 -1
- package/package.json +2 -2
- package/src/ColorComponent.tsx +2 -2
- package/src/TranslationsTabComponent.tsx +429 -0
- package/src/dashboards/DashboardComponent.tsx +1 -1
- package/src/dashboards/ServerDashboardDataSource.ts +0 -19
- package/src/dashboards/SettingsModalComponent.tsx +27 -383
- package/src/datagrids/DatagridComponent.tsx +6 -0
- package/src/datagrids/DatagridViewComponent.tsx +41 -5
- package/src/maps/BufferLayer.ts +16 -262
- package/src/maps/BufferLayerDesignerComponent.tsx +0 -6
- package/src/maps/ChoroplethLayer.ts +16 -393
- package/src/maps/ClusterLayer.ts +0 -274
- package/src/maps/DirectMapDataSource.ts +2 -49
- package/src/maps/GridLayer.ts +0 -224
- package/src/maps/Layer.ts +1 -35
- package/src/maps/MapComponent.tsx +448 -0
- package/src/maps/MapControlComponent.tsx +41 -0
- package/src/maps/MapDesign.ts +6 -0
- package/src/maps/MapDesignerComponent.tsx +18 -1
- package/src/maps/MapLayerDataSource.ts +0 -5
- package/src/maps/MapLayerViewDesignerComponent.ts +9 -2
- package/src/maps/MapLayersDesignerComponent.ts +4 -1
- package/src/maps/MapTranslationsTab.tsx +53 -0
- package/src/maps/MapUtils.ts +48 -0
- package/src/maps/MapViewComponent.tsx +2 -8
- package/src/maps/MarkersLayer.ts +79 -270
- package/src/maps/MarkersLayerDesign.ts +6 -0
- package/src/maps/MarkersLayerDesignerComponent.tsx +114 -38
- package/src/maps/ServerMapDataSource.ts +0 -19
- package/src/maps/SwitchableTileUrlLayer.tsx +0 -11
- package/src/maps/TileUrlLayer.tsx +0 -6
- package/src/maps/VectorMapViewComponent.tsx +13 -2
- package/src/maps/vectorMaps.tsx +12 -9
- package/src/widgets/MapWidget.tsx +2 -0
- package/src/maps/MapComponent.ts +0 -311
- package/src/maps/MapControlComponent.ts +0 -46
- package/src/maps/RasterMapViewComponent.ts +0 -345
|
@@ -35,7 +35,6 @@ const LayerFactory_1 = __importDefault(require("./LayerFactory"));
|
|
|
35
35
|
const MapBoundsCalculator_1 = __importDefault(require("./MapBoundsCalculator"));
|
|
36
36
|
const DirectWidgetDataSource_1 = __importDefault(require("../widgets/DirectWidgetDataSource"));
|
|
37
37
|
const compressJson_1 = __importDefault(require("../compressJson"));
|
|
38
|
-
const querystring_1 = __importDefault(require("querystring"));
|
|
39
38
|
const QuickfilterUtils = __importStar(require("../quickfilter/QuickfilterUtils"));
|
|
40
39
|
const react_1 = require("react");
|
|
41
40
|
const useStableCallback_1 = require("@mwater/react-library/lib/useStableCallback");
|
|
@@ -175,26 +174,7 @@ class DirectLayerDataSource {
|
|
|
175
174
|
if (layer.getLayerDefinitionType() === "TileUrl") {
|
|
176
175
|
return layer.getTileUrl(design, filters);
|
|
177
176
|
}
|
|
178
|
-
|
|
179
|
-
const jsonqlCss = layer.getJsonQLCss(design, this.options.schema, filters);
|
|
180
|
-
return this.createUrl("png", jsonqlCss);
|
|
181
|
-
}
|
|
182
|
-
// Get the url for the interactivity tiles with the specified filters applied
|
|
183
|
-
// Called with (design, filters) where design is the design of the layer and filters are filters to apply. Returns URL
|
|
184
|
-
getUtfGridUrl(design, filters) {
|
|
185
|
-
// Create layer
|
|
186
|
-
const layer = LayerFactory_1.default.createLayer(this.options.layerView.type);
|
|
187
|
-
// Handle special cases
|
|
188
|
-
if (this.options.layerView.type === "MWaterServer") {
|
|
189
|
-
return this.createLegacyUrl(design, "grid.json", filters);
|
|
190
|
-
}
|
|
191
|
-
// If layer has tiles url directly available
|
|
192
|
-
if (layer.getLayerDefinitionType() === "TileUrl") {
|
|
193
|
-
return layer.getUtfGridUrl(design, filters);
|
|
194
|
-
}
|
|
195
|
-
// Get JsonQLCss
|
|
196
|
-
const jsonqlCss = layer.getJsonQLCss(design, this.options.schema, filters);
|
|
197
|
-
return this.createUrl("grid.json", jsonqlCss);
|
|
177
|
+
throw new Error("Layer type not supported: " + this.options.layerView.type);
|
|
198
178
|
}
|
|
199
179
|
// Gets widget data source for a popup widget
|
|
200
180
|
getPopupWidgetDataSource(design, widgetId) {
|
|
@@ -213,23 +193,6 @@ class DirectLayerDataSource {
|
|
|
213
193
|
});
|
|
214
194
|
}
|
|
215
195
|
// Create query string
|
|
216
|
-
createUrl(extension, jsonqlCss) {
|
|
217
|
-
const query = {
|
|
218
|
-
type: "jsonql",
|
|
219
|
-
design: (0, compressJson_1.default)(jsonqlCss)
|
|
220
|
-
};
|
|
221
|
-
if (this.options.client) {
|
|
222
|
-
query.client = this.options.client;
|
|
223
|
-
}
|
|
224
|
-
// Make URL change when cache expired
|
|
225
|
-
const cacheExpiry = this.options.dataSource.getCacheExpiry();
|
|
226
|
-
if (cacheExpiry) {
|
|
227
|
-
query.cacheExpiry = cacheExpiry;
|
|
228
|
-
}
|
|
229
|
-
let url = `${this.options.apiUrl}maps/tiles/{z}/{x}/{y}.${extension}?` + querystring_1.default.stringify(query);
|
|
230
|
-
return url;
|
|
231
|
-
}
|
|
232
|
-
// Create query string
|
|
233
196
|
createLegacyUrl(design, extension, filters) {
|
|
234
197
|
let where;
|
|
235
198
|
let url = `${this.options.apiUrl}maps/tiles/{z}/{x}/{y}.${extension}?type=${design.type}&radius=1000`;
|
package/lib/maps/GridLayer.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import Layer, { LegendOptions, VectorTileDef } from "./Layer";
|
|
3
3
|
import { Schema, DataSource } from "@mwater/expressions";
|
|
4
|
-
import { LayerDefinition } from "./maps";
|
|
5
4
|
import { JsonQLFilter } from "../index";
|
|
6
5
|
import GridLayerDesign from "./GridLayerDesign";
|
|
7
6
|
import { JsonQLQuery } from "@mwater/jsonql";
|
|
@@ -11,20 +10,6 @@ export default class GridLayer extends Layer<GridLayerDesign> {
|
|
|
11
10
|
getLayerDefinitionType(): "VectorTile";
|
|
12
11
|
getVectorTile(design: GridLayerDesign, sourceId: string, schema: Schema, filters: JsonQLFilter[], opacity: number): VectorTileDef;
|
|
13
12
|
createJsonQL(design: GridLayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLQuery;
|
|
14
|
-
/** Gets the layer definition as JsonQL + CSS in format:
|
|
15
|
-
* {
|
|
16
|
-
* layers: array of { id: layer id, jsonql: jsonql that includes "the_webmercator_geom" as a column }
|
|
17
|
-
* css: carto css
|
|
18
|
-
* interactivity: (optional) { layer: id of layer, fields: array of field names }
|
|
19
|
-
* }
|
|
20
|
-
* arguments:
|
|
21
|
-
* design: design of layer
|
|
22
|
-
* schema: schema to use
|
|
23
|
-
* filters: array of filters to apply
|
|
24
|
-
*/
|
|
25
|
-
getJsonQLCss(design: GridLayerDesign, schema: Schema, filters: JsonQLFilter[]): LayerDefinition;
|
|
26
|
-
createMapnikJsonQL(design: GridLayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLQuery;
|
|
27
|
-
createCss(design: GridLayerDesign, schema: Schema, filters: JsonQLFilter[]): string;
|
|
28
13
|
getMinZoom(design: GridLayerDesign): number | undefined;
|
|
29
14
|
getMaxZoom(design: GridLayerDesign): number;
|
|
30
15
|
/** Get the legend to be optionally displayed on the map. Returns
|
package/lib/maps/GridLayer.js
CHANGED
|
@@ -219,218 +219,6 @@ class GridLayer extends Layer_1.default {
|
|
|
219
219
|
};
|
|
220
220
|
return query;
|
|
221
221
|
}
|
|
222
|
-
/** Gets the layer definition as JsonQL + CSS in format:
|
|
223
|
-
* {
|
|
224
|
-
* layers: array of { id: layer id, jsonql: jsonql that includes "the_webmercator_geom" as a column }
|
|
225
|
-
* css: carto css
|
|
226
|
-
* interactivity: (optional) { layer: id of layer, fields: array of field names }
|
|
227
|
-
* }
|
|
228
|
-
* arguments:
|
|
229
|
-
* design: design of layer
|
|
230
|
-
* schema: schema to use
|
|
231
|
-
* filters: array of filters to apply
|
|
232
|
-
*/
|
|
233
|
-
getJsonQLCss(design, schema, filters) {
|
|
234
|
-
// Create design
|
|
235
|
-
const layerDef = {
|
|
236
|
-
layers: [{ id: "layer0", jsonql: this.createMapnikJsonQL(design, schema, filters) }],
|
|
237
|
-
css: this.createCss(design, schema, filters),
|
|
238
|
-
interactivity: {
|
|
239
|
-
layer: "layer0",
|
|
240
|
-
fields: ["id", "name"]
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
return layerDef;
|
|
244
|
-
}
|
|
245
|
-
createMapnikJsonQL(design, schema, filters) {
|
|
246
|
-
const axisBuilder = new AxisBuilder_1.default({ schema });
|
|
247
|
-
const exprCompiler = new expressions_1.ExprCompiler(schema);
|
|
248
|
-
/* Compile to a query like this:
|
|
249
|
-
select mwater_hex_make(grid.q, grid.r, !pixel_width!*SIZE) as the_geom_webmercator, data.color as color from
|
|
250
|
-
mwater_hex_grid(!bbox!, !pixel_width!*SIZE) as grid
|
|
251
|
-
left outer join
|
|
252
|
-
(select qr.q as q, qr.r as r, COLOREXPR as color from TABLE as innerquery
|
|
253
|
-
inner join mwater_hex_xy_to_qr(st_xmin(innerquery.LOCATIONEXPR), st_ymin(innerquery.LOCATIONEXPR), !pixel_width!*10) as qr
|
|
254
|
-
on true
|
|
255
|
-
where innerquery.LOCATIONEXPR && ST_Expand(!bbox!, SIZE)
|
|
256
|
-
group by 1, 2) as data
|
|
257
|
-
on data.q = grid.q and data.r = grid.r
|
|
258
|
-
*/
|
|
259
|
-
const compiledGeometryExpr = exprCompiler.compileExpr({ expr: design.geometryExpr, tableAlias: "innerquery" });
|
|
260
|
-
const colorExpr = axisBuilder.compileAxis({ axis: design.colorAxis, tableAlias: "innerquery" });
|
|
261
|
-
let compiledSizeExpr;
|
|
262
|
-
if (design.shape == "hex") {
|
|
263
|
-
// Hex needs distance from center to points
|
|
264
|
-
compiledSizeExpr =
|
|
265
|
-
design.sizeUnits == "pixels"
|
|
266
|
-
? { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_width!" }, design.size / 1.73205] }
|
|
267
|
-
: { type: "literal", value: design.size / 1.73205 };
|
|
268
|
-
}
|
|
269
|
-
else if (design.shape == "square") {
|
|
270
|
-
// Square needs distance from center to center
|
|
271
|
-
compiledSizeExpr =
|
|
272
|
-
design.sizeUnits == "pixels"
|
|
273
|
-
? { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_width!" }, design.size] }
|
|
274
|
-
: { type: "literal", value: design.size };
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
throw new Error("Unknown shape");
|
|
278
|
-
}
|
|
279
|
-
// Create inner query
|
|
280
|
-
const innerQuery = {
|
|
281
|
-
type: "query",
|
|
282
|
-
selects: [
|
|
283
|
-
{ type: "select", expr: { type: "field", tableAlias: "qr", column: "q" }, alias: "q" },
|
|
284
|
-
{ type: "select", expr: { type: "field", tableAlias: "qr", column: "r" }, alias: "r" },
|
|
285
|
-
{ type: "select", expr: colorExpr, alias: "color" }
|
|
286
|
-
],
|
|
287
|
-
from: {
|
|
288
|
-
type: "join",
|
|
289
|
-
kind: "inner",
|
|
290
|
-
left: { type: "table", table: design.table, alias: "innerquery" },
|
|
291
|
-
right: {
|
|
292
|
-
type: "subexpr",
|
|
293
|
-
expr: {
|
|
294
|
-
type: "op",
|
|
295
|
-
op: `mwater_${design.shape}_xy_to_qr`,
|
|
296
|
-
exprs: [
|
|
297
|
-
{ type: "op", op: "ST_XMin", exprs: [compiledGeometryExpr] },
|
|
298
|
-
{ type: "op", op: "ST_YMin", exprs: [compiledGeometryExpr] },
|
|
299
|
-
compiledSizeExpr
|
|
300
|
-
]
|
|
301
|
-
},
|
|
302
|
-
alias: "qr"
|
|
303
|
-
},
|
|
304
|
-
on: { type: "literal", value: true }
|
|
305
|
-
},
|
|
306
|
-
groupBy: [1, 2]
|
|
307
|
-
};
|
|
308
|
-
// Filter by bounding box
|
|
309
|
-
let whereClauses = [
|
|
310
|
-
{
|
|
311
|
-
type: "op",
|
|
312
|
-
op: "&&",
|
|
313
|
-
exprs: [
|
|
314
|
-
compiledGeometryExpr,
|
|
315
|
-
{ type: "op", op: "ST_Expand", exprs: [{ type: "token", token: "!bbox!" }, compiledSizeExpr] }
|
|
316
|
-
]
|
|
317
|
-
}
|
|
318
|
-
];
|
|
319
|
-
// Then add filters
|
|
320
|
-
if (design.filter) {
|
|
321
|
-
whereClauses.push(exprCompiler.compileExpr({ expr: design.filter, tableAlias: "innerquery" }));
|
|
322
|
-
}
|
|
323
|
-
// Then add extra filters passed in, if relevant
|
|
324
|
-
const relevantFilters = lodash_1.default.where(filters, { table: design.table });
|
|
325
|
-
for (let filter of relevantFilters) {
|
|
326
|
-
whereClauses.push((0, expressions_1.injectTableAlias)(filter.jsonql, "innerquery"));
|
|
327
|
-
}
|
|
328
|
-
whereClauses = lodash_1.default.compact(whereClauses);
|
|
329
|
-
if (whereClauses.length > 0) {
|
|
330
|
-
innerQuery.where = { type: "op", op: "and", exprs: whereClauses };
|
|
331
|
-
}
|
|
332
|
-
// Now create outer query
|
|
333
|
-
const query = {
|
|
334
|
-
type: "query",
|
|
335
|
-
selects: [
|
|
336
|
-
{
|
|
337
|
-
type: "select",
|
|
338
|
-
expr: {
|
|
339
|
-
type: "op",
|
|
340
|
-
op: `mwater_${design.shape}_make`,
|
|
341
|
-
exprs: [
|
|
342
|
-
{ type: "field", tableAlias: "grid", column: "q" },
|
|
343
|
-
{ type: "field", tableAlias: "grid", column: "r" },
|
|
344
|
-
compiledSizeExpr
|
|
345
|
-
]
|
|
346
|
-
},
|
|
347
|
-
alias: "the_geom_webmercator"
|
|
348
|
-
},
|
|
349
|
-
{ type: "select", expr: { type: "field", tableAlias: "data", column: "color" }, alias: "color" }
|
|
350
|
-
],
|
|
351
|
-
from: {
|
|
352
|
-
type: "join",
|
|
353
|
-
kind: "left",
|
|
354
|
-
left: {
|
|
355
|
-
type: "subexpr",
|
|
356
|
-
expr: {
|
|
357
|
-
type: "op",
|
|
358
|
-
op: `mwater_${design.shape}_grid`,
|
|
359
|
-
exprs: [{ type: "token", token: "!bbox!" }, compiledSizeExpr]
|
|
360
|
-
},
|
|
361
|
-
alias: "grid"
|
|
362
|
-
},
|
|
363
|
-
right: { type: "subquery", query: innerQuery, alias: "data" },
|
|
364
|
-
// on data.q = grid.q and data.r = grid.r
|
|
365
|
-
on: {
|
|
366
|
-
type: "op",
|
|
367
|
-
op: "and",
|
|
368
|
-
exprs: [
|
|
369
|
-
{
|
|
370
|
-
type: "op",
|
|
371
|
-
op: "=",
|
|
372
|
-
exprs: [
|
|
373
|
-
{ type: "field", tableAlias: "data", column: "q" },
|
|
374
|
-
{ type: "field", tableAlias: "grid", column: "q" }
|
|
375
|
-
]
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
type: "op",
|
|
379
|
-
op: "=",
|
|
380
|
-
exprs: [
|
|
381
|
-
{ type: "field", tableAlias: "data", column: "r" },
|
|
382
|
-
{ type: "field", tableAlias: "grid", column: "r" }
|
|
383
|
-
]
|
|
384
|
-
}
|
|
385
|
-
]
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
return query;
|
|
390
|
-
}
|
|
391
|
-
createCss(design, schema, filters) {
|
|
392
|
-
let css = `
|
|
393
|
-
#layer0 {
|
|
394
|
-
polygon-opacity: ` +
|
|
395
|
-
design.fillOpacity +
|
|
396
|
-
`;
|
|
397
|
-
` +
|
|
398
|
-
(design.borderStyle == "color"
|
|
399
|
-
? `line-opacity: ` + (1 - (1 - design.fillOpacity) / 2) + `; `
|
|
400
|
-
: `line-width: 0;`) +
|
|
401
|
-
`
|
|
402
|
-
polygon-fill: transparent;
|
|
403
|
-
}
|
|
404
|
-
\
|
|
405
|
-
`;
|
|
406
|
-
if (!design.colorAxis) {
|
|
407
|
-
throw new Error("Color axis not set");
|
|
408
|
-
}
|
|
409
|
-
// If color axes, add color conditions
|
|
410
|
-
if (design.colorAxis.colorMap) {
|
|
411
|
-
for (let item of design.colorAxis.colorMap) {
|
|
412
|
-
// If invisible
|
|
413
|
-
if (design.colorAxis.excludedValues && lodash_1.default.any(design.colorAxis.excludedValues, (ev) => ev === item.value)) {
|
|
414
|
-
css += `#layer0 [color=${JSON.stringify(item.value)}] {
|
|
415
|
-
line-color: transparent;
|
|
416
|
-
line-opacity: 0;
|
|
417
|
-
polygon-opacity: 0;
|
|
418
|
-
polygon-fill: transparent;
|
|
419
|
-
}\n`;
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
css +=
|
|
423
|
-
`#layer0 [color=${JSON.stringify(item.value)}] {
|
|
424
|
-
` +
|
|
425
|
-
(design.borderStyle == "color" ? `line-color: ${item.color};` : "") +
|
|
426
|
-
`
|
|
427
|
-
polygon-fill: ${item.color};
|
|
428
|
-
}\n`;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return css;
|
|
433
|
-
}
|
|
434
222
|
// TODO
|
|
435
223
|
// /**
|
|
436
224
|
// * Called when the interactivity grid is clicked.
|
package/lib/maps/Layer.d.ts
CHANGED
|
@@ -5,22 +5,6 @@ import { ReactNode } from "react";
|
|
|
5
5
|
import { JsonQLQuery } from "@mwater/jsonql";
|
|
6
6
|
import { LayerSpecification } from "maplibre-gl";
|
|
7
7
|
import { MapLayerDataSource } from "./MapLayerDataSource";
|
|
8
|
-
export interface JsonQLCssLayerDefinition {
|
|
9
|
-
layers: Array<{
|
|
10
|
-
/** Layer id */
|
|
11
|
-
id: string;
|
|
12
|
-
/** jsonql that includes "the_webmercator_geom" as a column */
|
|
13
|
-
jsonql: JsonQLQuery;
|
|
14
|
-
}>;
|
|
15
|
-
/** carto css */
|
|
16
|
-
css: string;
|
|
17
|
-
interactivity?: {
|
|
18
|
-
/** id of layer */
|
|
19
|
-
layer: string;
|
|
20
|
-
/** array of field names */
|
|
21
|
-
fields: string[];
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
8
|
export interface OnGridClickOptions<LayerDesign> {
|
|
25
9
|
/** design of layer */
|
|
26
10
|
design: LayerDesign;
|
|
@@ -91,16 +75,7 @@ export interface VectorTileCTE {
|
|
|
91
75
|
/** Defines a layer for a map which has all the logic for rendering the specific data to be viewed */
|
|
92
76
|
export default class Layer<LayerDesign> {
|
|
93
77
|
/** Gets the type of layer definition */
|
|
94
|
-
getLayerDefinitionType(): "
|
|
95
|
-
/** Gets the layer definition as JsonQL + CSS for type "JsonQLCss"
|
|
96
|
-
arguments:
|
|
97
|
-
design: design of layer
|
|
98
|
-
schema: schema to use
|
|
99
|
-
filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to put in table alias
|
|
100
|
-
*/
|
|
101
|
-
getJsonQLCss(design: LayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLCssLayerDefinition;
|
|
102
|
-
/** Gets the utf grid url for definition type "TileUrl" */
|
|
103
|
-
getUtfGridUrl(design: LayerDesign, filters: JsonQLFilter[]): string | null;
|
|
78
|
+
getLayerDefinitionType(): "TileUrl" | "VectorTile";
|
|
104
79
|
/** Gets the layer definition for "VectorTile" type
|
|
105
80
|
* @param sourceId id of the source. Should be prefixed to sublayers with a colon (prefix:id)
|
|
106
81
|
* @param opacity opacity of the layer, which MapBox does not allow to be implemented for a whole layer (https://github.com/mapbox/mapbox-gl-js/issues/4090)
|
package/lib/maps/Layer.js
CHANGED
|
@@ -11,19 +11,6 @@ const bbox_1 = __importDefault(require("@turf/bbox"));
|
|
|
11
11
|
class Layer {
|
|
12
12
|
/** Gets the type of layer definition */
|
|
13
13
|
getLayerDefinitionType() {
|
|
14
|
-
return "JsonQLCss";
|
|
15
|
-
}
|
|
16
|
-
/** Gets the layer definition as JsonQL + CSS for type "JsonQLCss"
|
|
17
|
-
arguments:
|
|
18
|
-
design: design of layer
|
|
19
|
-
schema: schema to use
|
|
20
|
-
filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to put in table alias
|
|
21
|
-
*/
|
|
22
|
-
getJsonQLCss(design, schema, filters) {
|
|
23
|
-
throw new Error("Not implemented");
|
|
24
|
-
}
|
|
25
|
-
/** Gets the utf grid url for definition type "TileUrl" */
|
|
26
|
-
getUtfGridUrl(design, filters) {
|
|
27
14
|
throw new Error("Not implemented");
|
|
28
15
|
}
|
|
29
16
|
/** Gets the layer definition for "VectorTile" type
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
-
import AutoSizeComponent from "@mwater/react-library/lib/AutoSizeComponent";
|
|
3
2
|
import UndoStack from "../UndoStack";
|
|
4
3
|
import { DataSource, Schema } from "@mwater/expressions";
|
|
5
4
|
import { MapDataSource } from "./MapDataSource";
|
|
6
5
|
import { MapDesign } from "./MapDesign";
|
|
7
|
-
import { JsonQLFilter } from "
|
|
6
|
+
import { JsonQLFilter } from "..";
|
|
8
7
|
export interface MapComponentProps {
|
|
9
8
|
schema: Schema;
|
|
10
9
|
dataSource: DataSource;
|
|
@@ -27,6 +26,8 @@ export interface MapComponentProps {
|
|
|
27
26
|
quickfiltersValues?: any[];
|
|
28
27
|
/** True to hide title bar and related controls */
|
|
29
28
|
hideTitleBar?: boolean;
|
|
29
|
+
/** Locale to prefer if available */
|
|
30
|
+
preferredLocale?: string;
|
|
30
31
|
}
|
|
31
32
|
interface MapComponentState {
|
|
32
33
|
undoStack: UndoStack;
|
|
@@ -36,55 +37,38 @@ interface MapComponentState {
|
|
|
36
37
|
quickfiltersValues: any[] | null;
|
|
37
38
|
/** True to hide quickfilters */
|
|
38
39
|
hideQuickfilters: boolean;
|
|
40
|
+
/** Locale to use for display. Ignored if in edit mode */
|
|
41
|
+
locale: string;
|
|
42
|
+
/** Locale being previewed while in edit mode. Non-null when previewing a translation. */
|
|
43
|
+
previewLocale: string | null;
|
|
39
44
|
}
|
|
40
45
|
/** Map with designer on right */
|
|
41
46
|
export default class MapComponent extends React.Component<MapComponentProps, MapComponentState> {
|
|
42
|
-
static contextType: React.Context<string>;
|
|
43
47
|
constructor(props: MapComponentProps);
|
|
44
48
|
componentDidUpdate(prevProps: MapComponentProps): void;
|
|
45
49
|
handleUndo: () => void;
|
|
46
50
|
handleRedo: () => void;
|
|
47
51
|
handleShowQuickfilters: () => void;
|
|
48
52
|
handleZoomLockClick: () => void;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
}, HTMLElement>;
|
|
53
|
+
/** Handle locale selection from dropdown */
|
|
54
|
+
handleLocaleSelect: (locale: string) => void;
|
|
55
|
+
/** Render the language selector dropdown */
|
|
56
|
+
renderLanguageDropdown(): React.JSX.Element;
|
|
57
|
+
renderActionLinks(): React.JSX.Element;
|
|
58
|
+
renderHeader(): React.JSX.Element;
|
|
57
59
|
handleDesignChange: (design: any) => void;
|
|
58
60
|
getDesign(): MapDesign;
|
|
59
61
|
handleToggleDesignPanel: () => void;
|
|
60
62
|
getQuickfilterValues: () => any[];
|
|
61
|
-
renderView(): React.
|
|
63
|
+
renderView(): React.JSX.Element;
|
|
62
64
|
getCompiledFilters(): {
|
|
63
65
|
table: string;
|
|
64
66
|
jsonql: import("@mwater/jsonql").JsonQLExpr;
|
|
65
67
|
}[];
|
|
66
|
-
renderQuickfilter(): React.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}, HTMLElement>;
|
|
72
|
-
renderDesigner(): React.DetailedReactHTMLElement<{
|
|
73
|
-
style: {
|
|
74
|
-
gridArea: "designer";
|
|
75
|
-
borderLeft: string;
|
|
76
|
-
overflowY: "scroll";
|
|
77
|
-
};
|
|
78
|
-
}, HTMLElement>;
|
|
79
|
-
render(): React.DetailedReactHTMLElement<{
|
|
80
|
-
style: {
|
|
81
|
-
width: string;
|
|
82
|
-
height: string;
|
|
83
|
-
display: "grid";
|
|
84
|
-
gridTemplateColumns: string;
|
|
85
|
-
gridTemplateRows: string;
|
|
86
|
-
gridTemplateAreas: "\"header designer\" \"quickfilters designer\" \"view designer\"";
|
|
87
|
-
};
|
|
88
|
-
}, HTMLElement>;
|
|
68
|
+
renderQuickfilter(): React.JSX.Element;
|
|
69
|
+
/** Translate function to use for display based on current locale */
|
|
70
|
+
translate: (input: string) => string;
|
|
71
|
+
renderDesigner(): React.JSX.Element;
|
|
72
|
+
render(): React.JSX.Element;
|
|
89
73
|
}
|
|
90
74
|
export {};
|