@nextgis/ngw-leaflet 1.18.10 → 1.18.12

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: 1.18.10; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.18.12; author: NextGIS */
2
2
  import 'leaflet/dist/leaflet.css';
3
3
  import { Icon } from 'leaflet';
4
4
  import { NgwMap } from '@nextgis/ngw-map';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 1.18.10; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.18.12; author: NextGIS */
2
2
  var NgwLeaflet = (function () {
3
3
  'use strict';
4
4
 
@@ -15512,6 +15512,37 @@ var NgwLeaflet = (function () {
15512
15512
  }
15513
15513
  return value;
15514
15514
  };
15515
+ function typeOfValue(value) {
15516
+ if (value === null)
15517
+ return 'null';
15518
+ switch (typeof value) {
15519
+ case 'string':
15520
+ return 'string';
15521
+ case 'number':
15522
+ return 'number';
15523
+ case 'boolean':
15524
+ return 'boolean';
15525
+ case 'object':
15526
+ if (Array.isArray(value)) {
15527
+ var arrayType = 'value';
15528
+ if (value.every(function (item) { return typeof item === 'number'; })) {
15529
+ arrayType = 'number';
15530
+ }
15531
+ else if (value.every(function (item) { return typeof item === 'string'; })) {
15532
+ arrayType = 'string';
15533
+ }
15534
+ else if (value.every(function (item) { return typeof item === 'boolean'; })) {
15535
+ arrayType = 'boolean';
15536
+ }
15537
+ return "array<".concat(arrayType, ", ").concat(value.length, ">");
15538
+ }
15539
+ else {
15540
+ return 'object';
15541
+ }
15542
+ default:
15543
+ return 'undefined';
15544
+ }
15545
+ }
15515
15546
  var typeExpressions = {
15516
15547
  array: evaluateArgs(array),
15517
15548
  boolean: evaluateArgs(fallback(function (arg) { return (typeof arg === 'boolean' ? arg : undefined); })),
@@ -15531,7 +15562,7 @@ var NgwLeaflet = (function () {
15531
15562
  'to-string': evaluateArgs(fallback(String)),
15532
15563
  typeof: evaluateArgs(function (_a) {
15533
15564
  var arg = _a[0];
15534
- return typeof arg;
15565
+ return typeOfValue(arg);
15535
15566
  }),
15536
15567
  };
15537
15568
 
@@ -15637,42 +15668,39 @@ var NgwLeaflet = (function () {
15637
15668
  var expr = _a[0];
15638
15669
  return !expr;
15639
15670
  }
15640
- var checkCompareValues = function (_a) {
15641
- var a = _a[0], b = _a[1];
15642
- if (typeof a !== typeof b) {
15643
- throw new Error('Values have different types.');
15644
- }
15645
- };
15646
15671
  function notEqual(_a) {
15647
15672
  var a = _a[0], b = _a[1];
15648
- checkCompareValues([a, b]);
15649
15673
  return a !== b;
15650
15674
  }
15651
15675
  function lessThan(_a) {
15652
15676
  var left = _a[0], right = _a[1];
15653
- checkCompareValues([left, right]);
15654
15677
  return left < right;
15655
15678
  }
15656
15679
  function lessThanOrEqual(_a) {
15657
15680
  var left = _a[0], right = _a[1];
15658
- checkCompareValues([left, right]);
15659
15681
  return left <= right;
15660
15682
  }
15661
15683
  function equal(_a) {
15662
15684
  var left = _a[0], right = _a[1];
15663
- checkCompareValues([left, right]);
15664
15685
  return left === right;
15665
15686
  }
15666
15687
  function greaterThan(_a) {
15667
15688
  var left = _a[0], right = _a[1];
15668
- checkCompareValues([left, right]);
15669
15689
  return left > right;
15670
15690
  }
15671
15691
  function greaterThanOrEqual(_a) {
15672
15692
  var left = _a[0], right = _a[1];
15673
- checkCompareValues([left, right]);
15674
15693
  return left >= right;
15675
15694
  }
15695
+ var coalesce = function (args) {
15696
+ for (var i = 0; i < args.length; i++) {
15697
+ var arg = args[i]();
15698
+ if (arg !== null && arg !== undefined) {
15699
+ return arg;
15700
+ }
15701
+ }
15702
+ return null;
15703
+ };
15676
15704
  var all = function (args) {
15677
15705
  for (var i = 0; i < args.length; i++) {
15678
15706
  var arg = args[i]();
@@ -15729,6 +15757,7 @@ var NgwLeaflet = (function () {
15729
15757
  '==': evaluateArgs(equal),
15730
15758
  '>': evaluateArgs(greaterThan),
15731
15759
  '>=': evaluateArgs(greaterThanOrEqual),
15760
+ coalesce: coalesce,
15732
15761
  all: all,
15733
15762
  any: any,
15734
15763
  case: caseFunc,
@@ -22883,45 +22912,45 @@ var NgwLeaflet = (function () {
22883
22912
  return CancelablePromise.resolve(undefined);
22884
22913
  }
22885
22914
  function featureLayerIdentify(options) {
22886
- var geom = options.geom, signal = options.signal, cache = options.cache;
22887
- var geom_ = [];
22888
- if (Array.isArray(geom)) {
22889
- geom_ = geom;
22915
+ var geom = options.geom, signal = options.signal, cache = options.cache, layers = options.layers;
22916
+ var wkt = typeof geom === 'string' ? geom : convertGeomToWKT(geom);
22917
+ if (!wkt) {
22918
+ throw new Error('Not valid geometry format to make intersection');
22890
22919
  }
22891
- else {
22892
- var polygon = geom.type === 'Feature'
22893
- ? geom.geometry
22894
- : geom.type === 'Polygon'
22895
- ? geom
22896
- : false;
22897
- if (polygon) {
22898
- geom_ = polygon.coordinates[0];
22899
- }
22920
+ var data = {
22921
+ geom: wkt,
22922
+ srs: 3857,
22923
+ layers: layers,
22924
+ };
22925
+ return options.connector.post('feature_layer.identify', {
22926
+ data: data,
22927
+ signal: signal,
22928
+ cache: cache,
22929
+ });
22930
+ }
22931
+ function convertGeomToWKT(geom) {
22932
+ var coordinates = getPolygonCoordinates(geom);
22933
+ if (!coordinates)
22934
+ return null;
22935
+ var polygonStr = coordinates.map(function (_a) {
22936
+ var lng = _a[0], lat = _a[1];
22937
+ var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
22938
+ return "".concat(x, " ").concat(y);
22939
+ });
22940
+ return "POLYGON((".concat(polygonStr.join(','), "))");
22941
+ }
22942
+ function getPolygonCoordinates(geom) {
22943
+ var _a;
22944
+ if (Array.isArray(geom)) {
22945
+ return geom;
22900
22946
  }
22901
- if (geom_) {
22902
- // create wkt string
22903
- var polygonStr = [];
22904
- for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
22905
- var _a = geom_1[_i], lng = _a[0], lat = _a[1];
22906
- var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
22907
- polygonStr.push(x + ' ' + y);
22908
- }
22909
- var wkt = "POLYGON((".concat(polygonStr.join(', '), "))");
22910
- var layers = options.layers;
22911
- var data = {
22912
- geom: wkt,
22913
- srs: 3857,
22914
- layers: layers,
22915
- };
22916
- return options.connector.post('feature_layer.identify', {
22917
- data: data,
22918
- signal: signal,
22919
- cache: cache,
22920
- });
22947
+ if (geom.type === 'Feature') {
22948
+ return (_a = geom.geometry) === null || _a === void 0 ? void 0 : _a.coordinates[0];
22921
22949
  }
22922
- else {
22923
- throw new Error('Not valid geometry format to make intersection');
22950
+ if (geom.type === 'Polygon') {
22951
+ return geom.coordinates[0];
22924
22952
  }
22953
+ return null;
22925
22954
  }
22926
22955
  function sendIdentifyRequest(ev, options) {
22927
22956
  deprecatedMapClick(ev);