@nextgis/ngw-leaflet 3.0.1 → 3.1.0

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.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 3.0.1; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 3.1.0; author: NextGIS */
2
2
  import LeafletMapAdapter from '@nextgis/leaflet-map-adapter';
3
3
  import { NgwMap } from '@nextgis/ngw-map';
4
4
  import { Icon } from 'leaflet';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 3.0.1; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 3.1.0; author: NextGIS */
2
2
  var NgwLeaflet = (function () {
3
3
  'use strict';
4
4
 
@@ -15946,7 +15946,7 @@ var NgwLeaflet = (function () {
15946
15946
  return like(a, b, true);
15947
15947
  }
15948
15948
  };
15949
- function isPropertyFilter(filter) {
15949
+ function isPropertyFilter$1(filter) {
15950
15950
  const pf = filter;
15951
15951
  if (pf.length === 3 && typeof pf[0] === "string" && typeof pf[1] === "string") {
15952
15952
  return true;
@@ -15964,7 +15964,7 @@ var NgwLeaflet = (function () {
15964
15964
  function propertiesFilter(properties, filters) {
15965
15965
  const logic = typeof filters[0] === "string" ? filters[0] : "all";
15966
15966
  const filterFunction = (p) => {
15967
- if (isPropertyFilter(p)) {
15967
+ if (isPropertyFilter$1(p)) {
15968
15968
  const [field, operation, value] = p;
15969
15969
  const operationExec = operationsAliases[operation];
15970
15970
  if (operationExec) {
@@ -16163,7 +16163,7 @@ var NgwLeaflet = (function () {
16163
16163
  return a;
16164
16164
  };
16165
16165
  var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
16166
- var __objRest$8 = (source, exclude) => {
16166
+ var __objRest$9 = (source, exclude) => {
16167
16167
  var target = {};
16168
16168
  for (var prop in source)
16169
16169
  if (__hasOwnProp$D.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -16246,7 +16246,7 @@ var NgwLeaflet = (function () {
16246
16246
  return PAINT;
16247
16247
  }
16248
16248
  _createDivIcon(icon) {
16249
- const _a = icon, { html, rotate, className } = _a, toLIconOpt = __objRest$8(_a, ["html", "rotate", "className"]);
16249
+ const _a = icon, { html, rotate, className } = _a, toLIconOpt = __objRest$9(_a, ["html", "rotate", "className"]);
16250
16250
  const element = document.createElement("div");
16251
16251
  if (className) {
16252
16252
  element.className = className;
@@ -17371,7 +17371,7 @@ var NgwLeaflet = (function () {
17371
17371
  return a;
17372
17372
  };
17373
17373
  var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
17374
- var __objRest$7 = (source, exclude) => {
17374
+ var __objRest$8 = (source, exclude) => {
17375
17375
  var target = {};
17376
17376
  for (var prop in source)
17377
17377
  if (__hasOwnProp$A.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -17387,7 +17387,7 @@ var NgwLeaflet = (function () {
17387
17387
  addLayer(options) {
17388
17388
  this.options = Object.assign(this.options, options);
17389
17389
  if (options) {
17390
- const _a = options, { url } = _a, opt = __objRest$7(_a, ["url"]);
17390
+ const _a = options, { url } = _a, opt = __objRest$8(_a, ["url"]);
17391
17391
  if (url) {
17392
17392
  const tileLayerOptions = __spreadValues$z({
17393
17393
  pane: this.pane,
@@ -17480,7 +17480,7 @@ var NgwLeaflet = (function () {
17480
17480
  return a;
17481
17481
  };
17482
17482
  var __spreadProps$l = (a, b) => __defProps$l(a, __getOwnPropDescs$l(b));
17483
- var __objRest$6 = (source, exclude) => {
17483
+ var __objRest$7 = (source, exclude) => {
17484
17484
  var target = {};
17485
17485
  for (var prop in source)
17486
17486
  if (__hasOwnProp$y.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -17495,7 +17495,7 @@ var NgwLeaflet = (function () {
17495
17495
  class WmsAdapter extends BaseAdapter {
17496
17496
  addLayer(options) {
17497
17497
  Object.assign(this.options, options);
17498
- const _a = options, { url } = _a, opt = __objRest$6(_a, ["url"]);
17498
+ const _a = options, { url } = _a, opt = __objRest$7(_a, ["url"]);
17499
17499
  if (url) {
17500
17500
  const layerOptions = __spreadValues$x({
17501
17501
  pane: this.pane,
@@ -18447,7 +18447,7 @@ var NgwLeaflet = (function () {
18447
18447
  }
18448
18448
  return a;
18449
18449
  };
18450
- var __objRest$5 = (source, exclude) => {
18450
+ var __objRest$6 = (source, exclude) => {
18451
18451
  var target = {};
18452
18452
  for (var prop in source)
18453
18453
  if (__hasOwnProp$v.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -18601,7 +18601,7 @@ var NgwLeaflet = (function () {
18601
18601
  cache,
18602
18602
  query,
18603
18603
  json
18604
- } = _a, opt = __objRest$5(_a, [
18604
+ } = _a, opt = __objRest$6(_a, [
18605
18605
  "withCredentials",
18606
18606
  "responseType",
18607
18607
  "cacheProps",
@@ -18711,7 +18711,7 @@ var NgwLeaflet = (function () {
18711
18711
  return a;
18712
18712
  };
18713
18713
  var __spreadProps$k = (a, b) => __defProps$k(a, __getOwnPropDescs$k(b));
18714
- var __objRest$4 = (source, exclude) => {
18714
+ var __objRest$5 = (source, exclude) => {
18715
18715
  var target = {};
18716
18716
  for (var prop in source)
18717
18717
  if (__hasOwnProp$u.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -18790,7 +18790,7 @@ var NgwLeaflet = (function () {
18790
18790
  for (const method of methods) {
18791
18791
  const methodResp = (requestOptions) => {
18792
18792
  var _b;
18793
- const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$4(_a, ["headers"]);
18793
+ const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$5(_a, ["headers"]);
18794
18794
  if ((_b = requestOptions == null ? void 0 : requestOptions.signal) == null ? void 0 : _b.aborted) {
18795
18795
  throw new AbortError();
18796
18796
  }
@@ -18948,7 +18948,7 @@ var NgwLeaflet = (function () {
18948
18948
  return a;
18949
18949
  };
18950
18950
  var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
18951
- var __objRest$3 = (source, exclude) => {
18951
+ var __objRest$4 = (source, exclude) => {
18952
18952
  var target = {};
18953
18953
  for (var prop in source)
18954
18954
  if (__hasOwnProp$t.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -19156,7 +19156,7 @@ var NgwLeaflet = (function () {
19156
19156
  throw new Error("Empty `url` not allowed");
19157
19157
  }
19158
19158
  if (params) {
19159
- const _a = params, restParams = __objRest$3(_a, ["paramList"]);
19159
+ const _a = params, restParams = __objRest$4(_a, ["paramList"]);
19160
19160
  url = template(url, restParams);
19161
19161
  }
19162
19162
  url = encodeURI(fixUrlStr(url));
@@ -20303,7 +20303,7 @@ var NgwLeaflet = (function () {
20303
20303
  const filters_ = filters.filter((x) => Array.isArray(x));
20304
20304
  if (logic === "any") {
20305
20305
  for (const f of filters_) {
20306
- if (isPropertyFilter(f)) {
20306
+ if (isPropertyFilter$1(f)) {
20307
20307
  _queries.push(
20308
20308
  fetchNgwLayerItemsRequest(__spreadProps$g(__spreadValues$o({}, opt), {
20309
20309
  paramList: [..._parentAllParams, ...paramList, createParam(f)]
@@ -20317,7 +20317,7 @@ var NgwLeaflet = (function () {
20317
20317
  const filters2 = [];
20318
20318
  const propertiesFilterList = [];
20319
20319
  for (const f of filters_) {
20320
- if (isPropertyFilter(f)) {
20320
+ if (isPropertyFilter$1(f)) {
20321
20321
  filters2.push(createParam(f));
20322
20322
  } else {
20323
20323
  propertiesFilterList.push(f);
@@ -22134,7 +22134,7 @@ var NgwLeaflet = (function () {
22134
22134
  return a;
22135
22135
  };
22136
22136
  var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
22137
- var __objRest$2 = (source, exclude) => {
22137
+ var __objRest$3 = (source, exclude) => {
22138
22138
  var target = {};
22139
22139
  for (var prop in source)
22140
22140
  if (__hasOwnProp$f.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -22147,7 +22147,7 @@ var NgwLeaflet = (function () {
22147
22147
  return target;
22148
22148
  };
22149
22149
  function updateImageParams(params, resourceId) {
22150
- const _a = params, { bbox, width, height, nd } = _a, rest = __objRest$2(_a, ["bbox", "width", "height", "nd"]);
22150
+ const _a = params, { bbox, width, height, nd } = _a, rest = __objRest$3(_a, ["bbox", "width", "height", "nd"]);
22151
22151
  return __spreadProps$a(__spreadValues$e({}, rest), {
22152
22152
  resource: Array.isArray(resourceId) ? resourceId.join(",") : resourceId,
22153
22153
  extent: bbox,
@@ -22278,7 +22278,7 @@ var NgwLeaflet = (function () {
22278
22278
  }
22279
22279
  return a;
22280
22280
  };
22281
- var __objRest$1 = (source, exclude) => {
22281
+ var __objRest$2 = (source, exclude) => {
22282
22282
  var target = {};
22283
22283
  for (var prop in source)
22284
22284
  if (__hasOwnProp$e.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -22315,7 +22315,7 @@ var NgwLeaflet = (function () {
22315
22315
  function createQmsAdapter(webMapOrOptions, url = URL$1, createOpt = {}) {
22316
22316
  let webMap;
22317
22317
  if ("webMap" in webMapOrOptions) {
22318
- const _a = webMapOrOptions, { webMap: webMap_, url: url_ } = _a, adapterOptions = __objRest$1(_a, ["webMap", "url"]);
22318
+ const _a = webMapOrOptions, { webMap: webMap_, url: url_ } = _a, adapterOptions = __objRest$2(_a, ["webMap", "url"]);
22319
22319
  webMap = webMap_;
22320
22320
  if (url_) {
22321
22321
  url = url_;
@@ -22956,6 +22956,134 @@ var NgwLeaflet = (function () {
22956
22956
  });
22957
22957
  }
22958
22958
 
22959
+ function isPropertyFilter(value) {
22960
+ return Array.isArray(value) && value.length === 3 && typeof value[0] === "string" && typeof value[1] === "string";
22961
+ }
22962
+ function isPropertiesFilterGroup(value) {
22963
+ return Array.isArray(value) && !isPropertyFilter(value);
22964
+ }
22965
+ function toGetExpr(field) {
22966
+ return ["get", field];
22967
+ }
22968
+ function toConditionExpr(filter) {
22969
+ const [fieldRaw, op, value] = filter;
22970
+ const field = String(fieldRaw);
22971
+ const getExpr = toGetExpr(field);
22972
+ switch (op) {
22973
+ case "eq":
22974
+ if (value === null) {
22975
+ return ["is_null", getExpr];
22976
+ }
22977
+ return ["==", getExpr, value];
22978
+ case "ne":
22979
+ if (value === null) {
22980
+ return ["!is_null", getExpr];
22981
+ }
22982
+ return ["!=", getExpr, value];
22983
+ case "gt":
22984
+ if (typeof value !== "number" && typeof value !== "string") {
22985
+ throw new Error(
22986
+ `Operator "gt" requires number or string for "${field}"`
22987
+ );
22988
+ }
22989
+ return [">", getExpr, value];
22990
+ case "lt":
22991
+ if (typeof value !== "number" && typeof value !== "string") {
22992
+ throw new Error(
22993
+ `Operator "lt" requires number or string for "${field}"`
22994
+ );
22995
+ }
22996
+ return ["<", getExpr, value];
22997
+ case "ge":
22998
+ if (typeof value !== "number" && typeof value !== "string") {
22999
+ throw new Error(
23000
+ `Operator "ge" requires number or string for "${field}"`
23001
+ );
23002
+ }
23003
+ return [">=", getExpr, value];
23004
+ case "le":
23005
+ if (typeof value !== "number" && typeof value !== "string") {
23006
+ throw new Error(
23007
+ `Operator "le" requires number or string for "${field}"`
23008
+ );
23009
+ }
23010
+ return ["<=", getExpr, value];
23011
+ case "in":
23012
+ if (!Array.isArray(value) || !value.every((x) => typeof x === "string" || typeof x === "number")) {
23013
+ throw new Error(
23014
+ `Operator "in" requires (string | number)[] for "${field}"`
23015
+ );
23016
+ }
23017
+ if (!value.length) {
23018
+ throw new Error(
23019
+ `Operator "in" requires non-empty array for "${field}"`
23020
+ );
23021
+ }
23022
+ return ["in", getExpr, ...value];
23023
+ case "notin":
23024
+ if (!Array.isArray(value) || !value.every((x) => typeof x === "string" || typeof x === "number")) {
23025
+ throw new Error(
23026
+ `Operator "notin" requires (string | number)[] for "${field}"`
23027
+ );
23028
+ }
23029
+ if (!value.length) {
23030
+ throw new Error(
23031
+ `Operator "notin" requires non-empty array for "${field}"`
23032
+ );
23033
+ }
23034
+ return ["!in", getExpr, ...value];
23035
+ case "like":
23036
+ case "ilike":
23037
+ throw new Error(
23038
+ `Operator "${op}" is not supported by server FilterExpression`
23039
+ );
23040
+ default: {
23041
+ const exhaustive = op;
23042
+ throw new Error(`Unsupported operator: ${exhaustive}`);
23043
+ }
23044
+ }
23045
+ }
23046
+ function toGroupExpr(filters) {
23047
+ let logicalOp = "all";
23048
+ const children = [];
23049
+ for (const item of filters) {
23050
+ if (item === "all" || item === "any") {
23051
+ logicalOp = item;
23052
+ continue;
23053
+ }
23054
+ if (isPropertyFilter(item)) {
23055
+ children.push(toConditionExpr(item));
23056
+ continue;
23057
+ }
23058
+ if (isPropertiesFilterGroup(item)) {
23059
+ children.push(toGroupExpr(item));
23060
+ continue;
23061
+ }
23062
+ throw new Error("Invalid PropertiesFilter node");
23063
+ }
23064
+ return [logicalOp, ...children];
23065
+ }
23066
+ function propertiesFilterToExpression(filters) {
23067
+ if (!(filters == null ? void 0 : filters.length)) {
23068
+ return [];
23069
+ }
23070
+ return toGroupExpr(filters);
23071
+ }
23072
+ function propertiesFilterToExpressionString(filters) {
23073
+ if (!(filters == null ? void 0 : filters.length)) {
23074
+ return void 0;
23075
+ }
23076
+ return JSON.stringify(
23077
+ propertiesFilterToExpression(filters)
23078
+ );
23079
+ }
23080
+
23081
+ function createLayerFilterParam(resourceId, filter) {
23082
+ return {
23083
+ [`filter[${resourceId}]`]: propertiesFilterToExpressionString(filter)
23084
+ };
23085
+ }
23086
+
22959
23087
  var __defProp$h = Object.defineProperty;
22960
23088
  var __defProps$7 = Object.defineProperties;
22961
23089
  var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
@@ -22975,6 +23103,18 @@ var NgwLeaflet = (function () {
22975
23103
  return a;
22976
23104
  };
22977
23105
  var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
23106
+ var __objRest$1 = (source, exclude) => {
23107
+ var target = {};
23108
+ for (var prop in source)
23109
+ if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
23110
+ target[prop] = source[prop];
23111
+ if (source != null && __getOwnPropSymbols$a)
23112
+ for (var prop of __getOwnPropSymbols$a(source)) {
23113
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
23114
+ target[prop] = source[prop];
23115
+ }
23116
+ return target;
23117
+ };
22978
23118
  var __publicField$c = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
22979
23119
  var __async$b = (__this, __arguments, generator) => {
22980
23120
  return new Promise((resolve, reject) => {
@@ -23039,8 +23179,18 @@ var NgwLeaflet = (function () {
23039
23179
  baseUrl: connector.options.baseUrl || ""
23040
23180
  });
23041
23181
  if (opt) {
23042
- const layerAdapterOptions = __spreadProps$7(__spreadValues$9(__spreadValues$9({}, opt), layerOptions.adapterOptions), {
23043
- params: { resource: resourceId },
23182
+ const _a = layerOptions.adapterOptions || {}, { propertiesFilter } = _a, restAdapterOptions = __objRest$1(_a, ["propertiesFilter"]);
23183
+ const filterParams = createLayerFilterParam(
23184
+ resourceId,
23185
+ propertiesFilter
23186
+ );
23187
+ const layerAdapterOptions = __spreadProps$7(__spreadValues$9(__spreadValues$9({}, opt), restAdapterOptions), {
23188
+ params: __spreadValues$9({
23189
+ resource: resourceId
23190
+ }, filterParams),
23191
+ url: adapter === "TILE" && opt.url ? updateUrlParams(opt.url, __spreadValues$9({
23192
+ resource: String(resourceId)
23193
+ }, filterParams)) : opt.url,
23044
23194
  layers: opt.layers || String(resourceId),
23045
23195
  resourceId
23046
23196
  });
@@ -23053,6 +23203,15 @@ var NgwLeaflet = (function () {
23053
23203
  addLayer(addOptions) {
23054
23204
  return super.addLayer(__spreadValues$9(__spreadValues$9({}, this.options), addOptions));
23055
23205
  }
23206
+ propertiesFilter(filters) {
23207
+ return __async$b(this, null, function* () {
23208
+ var _a;
23209
+ const opt = this.options;
23210
+ const params = __spreadValues$9(__spreadValues$9({}, opt.params || {}), createLayerFilterParam(this.resourceId, filters));
23211
+ opt.params = params;
23212
+ (_a = this.updateLayer) == null ? void 0 : _a.call(this, { params });
23213
+ });
23214
+ }
23056
23215
  getIdentificationIds() {
23057
23216
  return __async$b(this, null, function* () {
23058
23217
  if (this.item) {
@@ -23548,7 +23707,8 @@ var NgwLeaflet = (function () {
23548
23707
  component: "pyramid"
23549
23708
  }
23550
23709
  });
23551
- if (settings && settings.company_logo && settings.company_logo.enabled) {
23710
+ const company_logo = settings && "company_logo" in settings ? settings.company_logo : void 0;
23711
+ if (company_logo && company_logo.enabled) {
23552
23712
  const anchor = document.createElement("a");
23553
23713
  anchor.style.position = "absolute";
23554
23714
  anchor.style.bottom = "0";
@@ -23583,10 +23743,10 @@ var NgwLeaflet = (function () {
23583
23743
  } else {
23584
23744
  return;
23585
23745
  }
23586
- if (settings.company_logo.link !== null && settings.company_logo.link.trim() !== "") {
23587
- anchor.href = settings.company_logo.link;
23746
+ if (company_logo.link !== null && company_logo.link.trim() !== "") {
23747
+ anchor.href = company_logo.link;
23588
23748
  anchor.target = "_blank";
23589
- if (settings.company_logo.link.search(/:\/\/nextgis/) !== -1) {
23749
+ if (company_logo.link.search(/:\/\/nextgis/) !== -1) {
23590
23750
  img.alt = "Get your own Web GIS at nextgis.com";
23591
23751
  }
23592
23752
  }
@@ -26123,7 +26283,7 @@ var NgwLeaflet = (function () {
26123
26283
  addNgwLayer(options) {
26124
26284
  return __async$1(this, null, function* () {
26125
26285
  yield this.onMapLoad();
26126
- const { keyname, resourceId } = options;
26286
+ const { keyname, resourceId, filters } = options;
26127
26287
  if (keyname || resourceId !== void 0) {
26128
26288
  deprecatedWarn(
26129
26289
  "set `resource` options instead of `keyname` or `resourceId`"
@@ -26137,12 +26297,15 @@ var NgwLeaflet = (function () {
26137
26297
  }
26138
26298
  if (defined(this.options.baseUrl)) {
26139
26299
  try {
26300
+ options.adapterOptions = options.adapterOptions || {};
26140
26301
  if (defined(this.options.setViewDelay)) {
26141
- options.adapterOptions = options.adapterOptions || {};
26142
26302
  if (!defined(options.adapterOptions.setViewDelay)) {
26143
26303
  options.adapterOptions.setViewDelay = this.options.setViewDelay;
26144
26304
  }
26145
26305
  }
26306
+ if (defined(filters)) {
26307
+ options.adapterOptions.propertiesFilter = filters;
26308
+ }
26146
26309
  const adapter = createNgwLayerAdapter(options, this, this.connector);
26147
26310
  const adapterOpts = __spreadValues$1(__spreadValues$1({
26148
26311
  visibility: true