@nextgis/ngw-leaflet 1.13.0 → 1.13.2

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.13.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.13.2; author: NextGIS */
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -18116,31 +18116,31 @@ var Cache = /** @class */ (function () {
18116
18116
  /**
18117
18117
  * Thrown when...
18118
18118
  */
18119
- var NgwError = /** @class */ (function (_super) {
18120
- __extends(NgwError, _super);
18121
- function NgwError(er) {
18119
+ var NetworkError = /** @class */ (function (_super) {
18120
+ __extends(NetworkError, _super);
18121
+ function NetworkError(url) {
18122
18122
  var _this = _super.call(this) || this;
18123
- _this.name = 'NgwError';
18124
- Object.assign(_this, er);
18125
- Object.setPrototypeOf(_this, NgwError.prototype);
18123
+ _this.name = 'NetworkError';
18124
+ Object.setPrototypeOf(_this, NetworkError.prototype);
18125
+ _this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
18126
18126
  return _this;
18127
18127
  }
18128
- return NgwError;
18128
+ return NetworkError;
18129
18129
  }(Error));
18130
18130
 
18131
18131
  /**
18132
18132
  * Thrown when...
18133
18133
  */
18134
- var NetworkError = /** @class */ (function (_super) {
18135
- __extends(NetworkError, _super);
18136
- function NetworkError(url) {
18134
+ var NgwError = /** @class */ (function (_super) {
18135
+ __extends(NgwError, _super);
18136
+ function NgwError(er) {
18137
18137
  var _this = _super.call(this) || this;
18138
- _this.name = 'NetworkError';
18139
- Object.setPrototypeOf(_this, NetworkError.prototype);
18140
- _this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
18138
+ _this.name = 'NgwError';
18139
+ Object.assign(_this, er);
18140
+ Object.setPrototypeOf(_this, NgwError.prototype);
18141
18141
  return _this;
18142
18142
  }
18143
- return NetworkError;
18143
+ return NgwError;
18144
18144
  }(Error));
18145
18145
 
18146
18146
  function isObject(val) {
@@ -18254,11 +18254,6 @@ var loadData;
18254
18254
  xhr.abort();
18255
18255
  });
18256
18256
  }
18257
- if (options.signal) {
18258
- options.signal.addEventListener('abort', function () {
18259
- xhr.abort();
18260
- });
18261
- }
18262
18257
  xhr.send(data);
18263
18258
  };
18264
18259
  }
@@ -19060,7 +19055,7 @@ var NgwConnector = /** @class */ (function () {
19060
19055
  NgwConnector.prototype._loadData = function (url, options) {
19061
19056
  var _this = this;
19062
19057
  options.responseType = options.responseType || 'json';
19063
- return new CancelablePromise(function (resolve, reject, onCancel) {
19058
+ var request = new CancelablePromise(function (resolve, reject, onCancel) {
19064
19059
  if (_this.user) {
19065
19060
  options = options || {};
19066
19061
  // options.withCredentials = true;
@@ -19080,6 +19075,13 @@ var NgwConnector = /** @class */ (function () {
19080
19075
  }
19081
19076
  }
19082
19077
  });
19078
+ if (options.signal &&
19079
+ typeof options.signal.addEventListener === 'function') {
19080
+ options.signal.addEventListener('abort', function () {
19081
+ request.cancel();
19082
+ });
19083
+ }
19084
+ return request;
19083
19085
  };
19084
19086
  NgwConnector.prototype._handleHttpError = function (er) {
19085
19087
  if (er) {
@@ -19189,12 +19191,12 @@ function fetchNgwLayerItemExtent(_a) {
19189
19191
  function fetchNgwExtent(options) {
19190
19192
  return options.connector.getResource(options.resourceId).then(function (resource) {
19191
19193
  if (resource) {
19192
- return fetchNgwResourceExtent(resource, options.connector);
19194
+ return fetchNgwResourceExtent(resource, options.connector, options);
19193
19195
  }
19194
19196
  });
19195
19197
  }
19196
19198
  /** @deprecated use {@link fetchNgwExtent} instead */
19197
- function fetchNgwResourceExtent(item, connector) {
19199
+ function fetchNgwResourceExtent(item, connector, options) {
19198
19200
  if (item.webmap) {
19199
19201
  return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
19200
19202
  }
@@ -19203,15 +19205,12 @@ function fetchNgwResourceExtent(item, connector) {
19203
19205
  if (resource.cls && resource.cls.indexOf('style') !== -1) {
19204
19206
  return connector.getResource(resource.parent.id).then(function (res) {
19205
19207
  if (res) {
19206
- return fetchNgwLayerExtent({
19207
- resourceId: res.resource.id,
19208
- connector: connector,
19209
- });
19208
+ return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: res.resource.id, connector: connector }));
19210
19209
  }
19211
19210
  });
19212
19211
  }
19213
19212
  else {
19214
- return fetchNgwLayerExtent({ resourceId: resource.id, connector: connector });
19213
+ return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: resource.id, connector: connector }));
19215
19214
  }
19216
19215
  }
19217
19216
  }
@@ -19382,7 +19381,7 @@ function createWktFromCoordArray(coord) {
19382
19381
  }
19383
19382
  function fetchNgwLayerItemsRequest(options) {
19384
19383
  var params = __assign({}, FEATURE_REQUEST_PARAMS);
19385
- var limit = options.limit, offset = options.offset, orderBy = options.orderBy, paramList = options.paramList, connector = options.connector, intersects = options.intersects, resourceId = options.resourceId;
19384
+ var limit = options.limit, cache = options.cache, signal = options.signal, offset = options.offset, orderBy = options.orderBy, paramList = options.paramList, connector = options.connector, intersects = options.intersects, resourceId = options.resourceId;
19386
19385
  if (limit) {
19387
19386
  if (limit !== Number.POSITIVE_INFINITY) {
19388
19387
  params.limit = limit;
@@ -19412,11 +19411,10 @@ function fetchNgwLayerItemsRequest(options) {
19412
19411
  params.paramList = paramList;
19413
19412
  }
19414
19413
  var reqParams = __assign({ id: resourceId }, params);
19415
- return connector.get('feature_layer.feature.collection', { cache: options.cache }, reqParams);
19414
+ return connector.get('feature_layer.feature.collection', { cache: cache, signal: signal }, reqParams);
19416
19415
  }
19417
19416
 
19418
19417
  function prepareNgwFieldsToPropertiesFilter(fields) {
19419
- console.log(fields);
19420
19418
  var f;
19421
19419
  var _loop_1 = function () {
19422
19420
  var field = fields[f];
@@ -21425,7 +21423,7 @@ var NgwResource = /** @class */ (function () {
21425
21423
  });
21426
21424
  });
21427
21425
  };
21428
- NgwResource.prototype.getBounds = function () {
21426
+ NgwResource.prototype.getBounds = function (options) {
21429
21427
  return __awaiter(this, void 0, void 0, function () {
21430
21428
  var _a;
21431
21429
  return __generator(this, function (_b) {
@@ -21436,7 +21434,7 @@ var NgwResource = /** @class */ (function () {
21436
21434
  }
21437
21435
  if (!this.item) return [3 /*break*/, 2];
21438
21436
  _a = this;
21439
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector)];
21437
+ return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
21440
21438
  case 1:
21441
21439
  _a._extent = _b.sent();
21442
21440
  return [2 /*return*/, this._extent];
@@ -22078,7 +22076,7 @@ function createParamsFromFeatures(features, resourceId, multiple) {
22078
22076
  return featureParams;
22079
22077
  }
22080
22078
  function fetchIdentifyGeoJson(options) {
22081
- var connector = options.connector, identify = options.identify;
22079
+ var connector = options.connector, identify = options.identify, requestOptions = options.requestOptions;
22082
22080
  for (var l in identify) {
22083
22081
  var id = Number(l);
22084
22082
  if (!isNaN(id)) {
@@ -22094,7 +22092,7 @@ function fetchIdentifyGeoJson(options) {
22094
22092
  }
22095
22093
  var params = getIdentifyItems(identify);
22096
22094
  if (params && params.length) {
22097
- return fetchNgwLayerFeature(__assign({ connector: connector }, params[0]));
22095
+ return fetchNgwLayerFeature(__assign(__assign(__assign({}, requestOptions), { connector: connector }), params[0]));
22098
22096
  }
22099
22097
  return CancelablePromise.resolve(undefined);
22100
22098
  }
@@ -22107,21 +22105,25 @@ function fetchIdentifyItem(options) {
22107
22105
  return CancelablePromise.resolve(undefined);
22108
22106
  }
22109
22107
  function featureLayerIdentify(options) {
22110
- var g = options.geom;
22111
- var geom = [];
22112
- if (Array.isArray(g)) {
22113
- geom = g;
22108
+ var geom = options.geom, signal = options.signal, cache = options.cache;
22109
+ var geom_ = [];
22110
+ if (Array.isArray(geom)) {
22111
+ geom_ = geom;
22114
22112
  }
22115
22113
  else {
22116
- var polygon = g.type === 'Feature' ? g.geometry : g.type === 'Polygon' ? g : false;
22114
+ var polygon = geom.type === 'Feature'
22115
+ ? geom.geometry
22116
+ : geom.type === 'Polygon'
22117
+ ? geom
22118
+ : false;
22117
22119
  if (polygon) {
22118
- geom = polygon.coordinates[0];
22120
+ geom_ = polygon.coordinates[0];
22119
22121
  }
22120
22122
  }
22121
- if (geom) {
22123
+ if (geom_) {
22122
22124
  // create wkt string
22123
22125
  var polygonStr = [];
22124
- for (var _i = 0, geom_1 = geom; _i < geom_1.length; _i++) {
22126
+ for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
22125
22127
  var _a = geom_1[_i], lng = _a[0], lat = _a[1];
22126
22128
  var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
22127
22129
  polygonStr.push(x + ' ' + y);
@@ -22133,18 +22135,22 @@ function featureLayerIdentify(options) {
22133
22135
  srs: 3857,
22134
22136
  layers: layers,
22135
22137
  };
22136
- return options.connector.post('feature_layer.identify', { data: data });
22138
+ return options.connector.post('feature_layer.identify', {
22139
+ data: data,
22140
+ signal: signal,
22141
+ cache: cache,
22142
+ });
22137
22143
  }
22138
22144
  else {
22139
22145
  throw new Error('Not valid geometry format to make intersection');
22140
22146
  }
22141
22147
  }
22142
22148
  function sendIdentifyRequest(ev, options) {
22143
- var _a;
22144
22149
  deprecatedMapClick(ev);
22145
- var _b = ev.lngLat, lng = _b[0], lat = _b[1];
22146
- var geom = (_a = options.geom) !== null && _a !== void 0 ? _a : getCirclePolygonCoordinates(lng, lat, options.radius);
22147
- return featureLayerIdentify(__assign(__assign({}, options), { geom: geom }));
22150
+ var _a = ev.lngLat, lng = _a[0], lat = _a[1];
22151
+ var geom = options.geom, radius = options.radius, signal = options.signal, cache = options.cache;
22152
+ var geom_ = geom !== null && geom !== void 0 ? geom : getCirclePolygonCoordinates(lng, lat, radius);
22153
+ return featureLayerIdentify(__assign(__assign({}, options), { geom: geom_, signal: signal, cache: cache }));
22148
22154
  }
22149
22155
  function createIdentifyItem(opt) {
22150
22156
  return new IdentifyItem(opt);