@esri/hub-common 9.36.0 → 9.37.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
- import { IItem, IUser, IGroup, IGeometry } from "@esri/arcgis-rest-types";
1
+ import { IItem, IUser, IGroup, IPolygon, ISpatialReference, IGeometry } from "@esri/arcgis-rest-types";
2
2
  import { IPortal, ISearchResult } from "@esri/arcgis-rest-portal";
3
3
  import { UserSession } from "@esri/arcgis-rest-auth";
4
4
  import { IRequestOptions } from "@esri/arcgis-rest-request";
@@ -144,6 +144,15 @@ export declare type Visibility = "private" | "org" | "public";
144
144
  */
145
145
  export declare type AccessControl = "view" | "edit" | "admin";
146
146
  export declare type GeographyProvenance = "item" | "none" | "automatic";
147
+ /**
148
+ * properties to be used with the ArcGIS API geometry class constructors
149
+ */
150
+ export interface IGeometryProperties extends IGeometry {
151
+ type: string;
152
+ }
153
+ export interface IPolygonProperties extends IPolygon, IGeometryProperties {
154
+ type: "polygon";
155
+ }
147
156
  /**
148
157
  * Location of a Hub resource
149
158
  *
@@ -152,8 +161,9 @@ export declare type GeographyProvenance = "item" | "none" | "automatic";
152
161
  */
153
162
  export interface IHubGeography {
154
163
  center?: [number, number];
155
- geometry?: IGeometry;
164
+ geometry?: IPolygonProperties;
156
165
  provenance?: GeographyProvenance;
166
+ spatialReference?: ISpatialReference;
157
167
  }
158
168
  export declare type SearchableType = IItem | IGroup | IUser;
159
169
  export declare type SearchFunction = (...args: any[]) => Promise<ISearchResult<SearchableType>>;
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.35.0 - Tue May 24 2022 13:04:14 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v9.36.0 - Thu May 26 2022 14:42:32 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -6388,6 +6388,15 @@
6388
6388
  return request(cleanUrl(options.url), options);
6389
6389
  }
6390
6390
 
6391
+ /**
6392
+ * Turns an bounding box coordinate array into an extent object
6393
+ * @param bBox bounding box coordinate array
6394
+ * @returns extent object
6395
+ */
6396
+ var bBoxToExtent = function (bBox) {
6397
+ var _a = bBox[0], xmin = _a[0], ymin = _a[1], _b = bBox[1], xmax = _b[0], ymax = _b[1];
6398
+ return createExtent(xmin, ymin, xmax, ymax);
6399
+ };
6391
6400
  function createExtent(xmin, ymin, xmax, ymax, wkid) {
6392
6401
  if (wkid === void 0) { wkid = 4326; }
6393
6402
  return {
@@ -6402,13 +6411,13 @@
6402
6411
  };
6403
6412
  }
6404
6413
  /**
6405
- * Turns an extent into a bbox
6406
- * @param envelope extent
6414
+ * Turns an extent object into a bounding box coordinate array
6415
+ * @param extent extent
6407
6416
  */
6408
- function extentToBBox(envelope) {
6417
+ function extentToBBox(extent) {
6409
6418
  return [
6410
- [envelope.xmin, envelope.ymin],
6411
- [envelope.xmax, envelope.ymax],
6419
+ [extent.xmin, extent.ymin],
6420
+ [extent.xmax, extent.ymax],
6412
6421
  ];
6413
6422
  }
6414
6423
  var GLOBAL_EXTENT = {
@@ -6510,25 +6519,44 @@
6510
6519
  return (!!extent &&
6511
6520
  [isExtentCoordinateArray, isExtentJSON].some(function (test) { return test(extent); }));
6512
6521
  }
6522
+ /* istanbul ignore next DEPRECATED, remove at next breaking change */
6513
6523
  var bBoxToPolygon = function (bBox) {
6514
- var _a = bBox[0], xmin = _a[0], ymin = _a[1], _b = bBox[1], xmax = _b[0], ymax = _b[1];
6524
+ /* tslint:disable no-console */
6525
+ console.warn("DEPRECATED: use extentToPolygon(bBoxToExtent(bBox)) instead");
6526
+ return extentToPolygon(bBoxToExtent(bBox));
6527
+ };
6528
+ /**
6529
+ * Convert an extent object into a polygon object
6530
+ * @param extent
6531
+ * @returns
6532
+ */
6533
+ var extentToPolygon = function (extent) {
6534
+ var xmin = extent.xmin, ymin = extent.ymin, xmax = extent.xmax, ymax = extent.ymax, spatialReference = extent.spatialReference;
6515
6535
  var rings = [
6516
6536
  [
6517
- [xmin, ymin],
6518
- [xmax, ymin],
6519
- [xmax, ymax],
6520
6537
  [xmin, ymax],
6538
+ [xmax, ymax],
6539
+ [xmax, ymin],
6521
6540
  [xmin, ymin],
6541
+ [xmin, ymax],
6522
6542
  ],
6523
6543
  ];
6524
- var wkid = 4326;
6525
6544
  return {
6526
6545
  rings: rings,
6527
- spatialReference: {
6528
- wkid: wkid,
6529
- },
6546
+ spatialReference: spatialReference,
6530
6547
  };
6531
6548
  };
6549
+ /**
6550
+ * Get the center of an extent as a point
6551
+ * @param extent
6552
+ * @returns
6553
+ */
6554
+ var getExtentCenter = function (extent) {
6555
+ var xmin = extent.xmin, ymin = extent.ymin, xmax = extent.xmax, ymax = extent.ymax, spatialReference = extent.spatialReference;
6556
+ var x = (xmax - xmin) / 2 + xmin;
6557
+ var y = (ymax - ymin) / 2 + ymin;
6558
+ return { x: x, y: y, spatialReference: spatialReference };
6559
+ };
6532
6560
 
6533
6561
  // private helper functions
6534
6562
  function collectionToFamily(collection) {
@@ -6582,30 +6610,26 @@
6582
6610
  * @returns
6583
6611
  * @private
6584
6612
  */
6585
- // TODO: this needs to be able to handle "automatic"
6586
6613
  var getContentBoundary = function (item) {
6587
6614
  var _a;
6588
- var extent = item.extent;
6589
- var isValidItemExtent = isBBox(extent);
6615
+ var bBox = item.extent;
6616
+ var isValidItemExtent = isBBox(bBox);
6590
6617
  // user specified provenance is stored in item.properties
6591
6618
  var provenance = ((_a = item.properties) === null || _a === void 0 ? void 0 : _a.boundary) ||
6592
6619
  // but we default to item if the item has an extent
6593
6620
  (isValidItemExtent ? "item" : undefined);
6594
- var geometry;
6595
- switch (provenance) {
6596
- case "item":
6597
- geometry = isValidItemExtent ? bBoxToPolygon(extent) : null;
6598
- break;
6599
- case "none":
6600
- geometry = null;
6601
- break;
6602
- // TODO: handle other provenances
6603
- }
6604
- // TODO: derive and return center
6605
- return {
6621
+ var boundary = {
6622
+ geometry: null,
6606
6623
  provenance: provenance,
6607
- geometry: geometry,
6608
6624
  };
6625
+ if (provenance === "item" && isValidItemExtent) {
6626
+ var extent = bBoxToExtent(bBox);
6627
+ var center = getExtentCenter(extent);
6628
+ boundary.center = [center.x, center.y];
6629
+ boundary.geometry = __assign(__assign({}, extentToPolygon(extent)), { type: "polygon" });
6630
+ boundary.spatialReference = boundary.geometry.spatialReference;
6631
+ }
6632
+ return boundary;
6609
6633
  };
6610
6634
  /**
6611
6635
  * Determine if we are in an enterprise environment
@@ -7785,14 +7809,14 @@
7785
7809
  },
7786
7810
  get extent() {
7787
7811
  return determineExtent(item, extent, layer);
7788
- },
7812
+ },
7789
7813
  // would require us to do client-side projection of server/layer extent
7790
7814
  get boundary() {
7791
- // TODO: need to be able to handle automatic w/ additional enrichment
7792
- // that could for example fetch the concave hull from the Hub API or resources
7793
- return boundary || getContentBoundary(item);
7794
- },
7795
- get summary() {
7815
+ // NOTE: the boundary from the Hub API will be undefined if item.properties.boundary === 'none'
7816
+ return (boundary === null || boundary === void 0 ? void 0 : boundary.provenance) === "automatic"
7817
+ ? boundary
7818
+ : getContentBoundary(item);
7819
+ }, get summary() {
7796
7820
  return (searchDescription ||
7797
7821
  // TODO: this should use the logic for the Hub API's searchDescription
7798
7822
  // see: https://github.com/ArcGIS/hub-indexer/blob/b352cfded8221a967ac80447879d493db6476d7a/packages/duke/compose/dataset.js#L238-L250
@@ -18592,6 +18616,7 @@
18592
18616
  exports.arrayToObject = arrayToObject;
18593
18617
  exports.atob = abab.atob;
18594
18618
  exports.autoAddUsers = autoAddUsers;
18619
+ exports.bBoxToExtent = bBoxToExtent;
18595
18620
  exports.bBoxToPolygon = bBoxToPolygon;
18596
18621
  exports.batch = batch;
18597
18622
  exports.btoa = abab.btoa;
@@ -18656,6 +18681,7 @@
18656
18681
  exports.expandUserFilter = expandUserFilter;
18657
18682
  exports.extend = extend;
18658
18683
  exports.extentToBBox = extentToBBox;
18684
+ exports.extentToPolygon = extentToPolygon;
18659
18685
  exports.failSafe = failSafe;
18660
18686
  exports.failSafeUpdate = failSafeUpdate;
18661
18687
  exports.fetchAllPages = fetchAllPages;
@@ -18682,6 +18708,7 @@
18682
18708
  exports.getDomainsForSite = getDomainsForSite;
18683
18709
  exports.getExportItemTypeKeyword = getExportItemTypeKeyword;
18684
18710
  exports.getExportLayerTypeKeyword = getExportLayerTypeKeyword;
18711
+ exports.getExtentCenter = getExtentCenter;
18685
18712
  exports.getFamily = getFamily;
18686
18713
  exports.getGeographicOrgExtent = getGeographicOrgExtent;
18687
18714
  exports.getGroupThumbnailUrl = getGroupThumbnailUrl;