@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
  function styleInject(css, ref) {
3
3
  if ( ref === void 0 ) ref = {};
4
4
  var insertAt = ref.insertAt;
@@ -15338,6 +15338,37 @@ const array = (args) => {
15338
15338
  }
15339
15339
  return value;
15340
15340
  };
15341
+ function typeOfValue(value) {
15342
+ if (value === null)
15343
+ return 'null';
15344
+ switch (typeof value) {
15345
+ case 'string':
15346
+ return 'string';
15347
+ case 'number':
15348
+ return 'number';
15349
+ case 'boolean':
15350
+ return 'boolean';
15351
+ case 'object':
15352
+ if (Array.isArray(value)) {
15353
+ let arrayType = 'value';
15354
+ if (value.every((item) => typeof item === 'number')) {
15355
+ arrayType = 'number';
15356
+ }
15357
+ else if (value.every((item) => typeof item === 'string')) {
15358
+ arrayType = 'string';
15359
+ }
15360
+ else if (value.every((item) => typeof item === 'boolean')) {
15361
+ arrayType = 'boolean';
15362
+ }
15363
+ return `array<${arrayType}, ${value.length}>`;
15364
+ }
15365
+ else {
15366
+ return 'object';
15367
+ }
15368
+ default:
15369
+ return 'undefined';
15370
+ }
15371
+ }
15341
15372
  const typeExpressions = {
15342
15373
  array: evaluateArgs(array),
15343
15374
  boolean: evaluateArgs(fallback((arg) => (typeof arg === 'boolean' ? arg : undefined))),
@@ -15350,7 +15381,7 @@ const typeExpressions = {
15350
15381
  'to-boolean': evaluateArgs(fallback(Boolean)),
15351
15382
  'to-number': evaluateArgs(fallback(Number)),
15352
15383
  'to-string': evaluateArgs(fallback(String)),
15353
- typeof: evaluateArgs(([arg]) => typeof arg),
15384
+ typeof: evaluateArgs(([arg]) => typeOfValue(arg)),
15354
15385
  };
15355
15386
 
15356
15387
  const mathExpressions = {
@@ -15448,35 +15479,33 @@ const stringExpressions = {
15448
15479
  function not([expr]) {
15449
15480
  return !expr;
15450
15481
  }
15451
- const checkCompareValues = ([a, b]) => {
15452
- if (typeof a !== typeof b) {
15453
- throw new Error('Values have different types.');
15454
- }
15455
- };
15456
15482
  function notEqual([a, b]) {
15457
- checkCompareValues([a, b]);
15458
15483
  return a !== b;
15459
15484
  }
15460
15485
  function lessThan([left, right]) {
15461
- checkCompareValues([left, right]);
15462
15486
  return left < right;
15463
15487
  }
15464
15488
  function lessThanOrEqual([left, right]) {
15465
- checkCompareValues([left, right]);
15466
15489
  return left <= right;
15467
15490
  }
15468
15491
  function equal([left, right]) {
15469
- checkCompareValues([left, right]);
15470
15492
  return left === right;
15471
15493
  }
15472
15494
  function greaterThan([left, right]) {
15473
- checkCompareValues([left, right]);
15474
15495
  return left > right;
15475
15496
  }
15476
15497
  function greaterThanOrEqual([left, right]) {
15477
- checkCompareValues([left, right]);
15478
15498
  return left >= right;
15479
15499
  }
15500
+ const coalesce = (args) => {
15501
+ for (let i = 0; i < args.length; i++) {
15502
+ const arg = args[i]();
15503
+ if (arg !== null && arg !== undefined) {
15504
+ return arg;
15505
+ }
15506
+ }
15507
+ return null;
15508
+ };
15480
15509
  const all = (args) => {
15481
15510
  for (let i = 0; i < args.length; i++) {
15482
15511
  const arg = args[i]();
@@ -15533,6 +15562,7 @@ const decisionExpressions = {
15533
15562
  '==': evaluateArgs(equal),
15534
15563
  '>': evaluateArgs(greaterThan),
15535
15564
  '>=': evaluateArgs(greaterThanOrEqual),
15565
+ coalesce,
15536
15566
  all,
15537
15567
  any,
15538
15568
  case: caseFunc,
@@ -21984,44 +22014,44 @@ function fetchIdentifyItem(options) {
21984
22014
  return CancelablePromise.resolve(undefined);
21985
22015
  }
21986
22016
  function featureLayerIdentify(options) {
21987
- const { geom, signal, cache } = options;
21988
- let geom_ = [];
22017
+ const { geom, signal, cache, layers } = options;
22018
+ const wkt = typeof geom === 'string' ? geom : convertGeomToWKT(geom);
22019
+ if (!wkt) {
22020
+ throw new Error('Not valid geometry format to make intersection');
22021
+ }
22022
+ const data = {
22023
+ geom: wkt,
22024
+ srs: 3857,
22025
+ layers,
22026
+ };
22027
+ return options.connector.post('feature_layer.identify', {
22028
+ data,
22029
+ signal,
22030
+ cache,
22031
+ });
22032
+ }
22033
+ function convertGeomToWKT(geom) {
22034
+ const coordinates = getPolygonCoordinates(geom);
22035
+ if (!coordinates)
22036
+ return null;
22037
+ const polygonStr = coordinates.map(([lng, lat]) => {
22038
+ const [x, y] = degrees2meters(lng, lat);
22039
+ return `${x} ${y}`;
22040
+ });
22041
+ return `POLYGON((${polygonStr.join(',')}))`;
22042
+ }
22043
+ function getPolygonCoordinates(geom) {
22044
+ var _a;
21989
22045
  if (Array.isArray(geom)) {
21990
- geom_ = geom;
22046
+ return geom;
21991
22047
  }
21992
- else {
21993
- const polygon = geom.type === 'Feature'
21994
- ? geom.geometry
21995
- : geom.type === 'Polygon'
21996
- ? geom
21997
- : false;
21998
- if (polygon) {
21999
- geom_ = polygon.coordinates[0];
22000
- }
22001
- }
22002
- if (geom_) {
22003
- // create wkt string
22004
- const polygonStr = [];
22005
- for (const [lng, lat] of geom_) {
22006
- const [x, y] = degrees2meters(lng, lat);
22007
- polygonStr.push(x + ' ' + y);
22008
- }
22009
- const wkt = `POLYGON((${polygonStr.join(', ')}))`;
22010
- const layers = options.layers;
22011
- const data = {
22012
- geom: wkt,
22013
- srs: 3857,
22014
- layers,
22015
- };
22016
- return options.connector.post('feature_layer.identify', {
22017
- data,
22018
- signal,
22019
- cache,
22020
- });
22048
+ if (geom.type === 'Feature') {
22049
+ return (_a = geom.geometry) === null || _a === void 0 ? void 0 : _a.coordinates[0];
22021
22050
  }
22022
- else {
22023
- throw new Error('Not valid geometry format to make intersection');
22051
+ if (geom.type === 'Polygon') {
22052
+ return geom.coordinates[0];
22024
22053
  }
22054
+ return null;
22025
22055
  }
22026
22056
  function sendIdentifyRequest(ev, options) {
22027
22057
  deprecatedMapClick(ev);