@nextgis/ngw-map 1.18.11 → 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-map; version: 1.18.11; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.18.12; author: NextGIS */
2
2
  import { EventEmitter } from 'events';
3
3
  import CancelablePromise from '@nextgis/cancelable-promise';
4
4
  import { deepmerge, deprecatedWarn, defined, isObject, getIdentifyRadius } from '@nextgis/utils';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.18.11; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.18.12; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -8850,45 +8850,45 @@ var NgwMap = (function (exports) {
8850
8850
  return CancelablePromise.resolve(undefined);
8851
8851
  }
8852
8852
  function featureLayerIdentify(options) {
8853
- var geom = options.geom, signal = options.signal, cache = options.cache;
8854
- var geom_ = [];
8853
+ var geom = options.geom, signal = options.signal, cache = options.cache, layers = options.layers;
8854
+ var wkt = typeof geom === 'string' ? geom : convertGeomToWKT(geom);
8855
+ if (!wkt) {
8856
+ throw new Error('Not valid geometry format to make intersection');
8857
+ }
8858
+ var data = {
8859
+ geom: wkt,
8860
+ srs: 3857,
8861
+ layers: layers,
8862
+ };
8863
+ return options.connector.post('feature_layer.identify', {
8864
+ data: data,
8865
+ signal: signal,
8866
+ cache: cache,
8867
+ });
8868
+ }
8869
+ function convertGeomToWKT(geom) {
8870
+ var coordinates = getPolygonCoordinates(geom);
8871
+ if (!coordinates)
8872
+ return null;
8873
+ var polygonStr = coordinates.map(function (_a) {
8874
+ var lng = _a[0], lat = _a[1];
8875
+ var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
8876
+ return "".concat(x, " ").concat(y);
8877
+ });
8878
+ return "POLYGON((".concat(polygonStr.join(','), "))");
8879
+ }
8880
+ function getPolygonCoordinates(geom) {
8881
+ var _a;
8855
8882
  if (Array.isArray(geom)) {
8856
- geom_ = geom;
8883
+ return geom;
8857
8884
  }
8858
- else {
8859
- var polygon = geom.type === 'Feature'
8860
- ? geom.geometry
8861
- : geom.type === 'Polygon'
8862
- ? geom
8863
- : false;
8864
- if (polygon) {
8865
- geom_ = polygon.coordinates[0];
8866
- }
8867
- }
8868
- if (geom_) {
8869
- // create wkt string
8870
- var polygonStr = [];
8871
- for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
8872
- var _a = geom_1[_i], lng = _a[0], lat = _a[1];
8873
- var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
8874
- polygonStr.push(x + ' ' + y);
8875
- }
8876
- var wkt = "POLYGON((".concat(polygonStr.join(', '), "))");
8877
- var layers = options.layers;
8878
- var data = {
8879
- geom: wkt,
8880
- srs: 3857,
8881
- layers: layers,
8882
- };
8883
- return options.connector.post('feature_layer.identify', {
8884
- data: data,
8885
- signal: signal,
8886
- cache: cache,
8887
- });
8885
+ if (geom.type === 'Feature') {
8886
+ return (_a = geom.geometry) === null || _a === void 0 ? void 0 : _a.coordinates[0];
8888
8887
  }
8889
- else {
8890
- throw new Error('Not valid geometry format to make intersection');
8888
+ if (geom.type === 'Polygon') {
8889
+ return geom.coordinates[0];
8891
8890
  }
8891
+ return null;
8892
8892
  }
8893
8893
  function sendIdentifyRequest(ev, options) {
8894
8894
  deprecatedMapClick(ev);