From c5539f458060e990ee5f89fad4016ce74c5c5dfc Mon Sep 17 00:00:00 2001 From: Tom Wayson Date: Mon, 25 Sep 2023 14:55:52 -0700 Subject: [PATCH] fix(hub-common): content location should be of type extent, not polygon (#1228) affects: @esri/hub-common also relax IHubLocation.geometries to accept POJOs --- packages/common/src/content/_internal/computeProps.ts | 8 ++------ packages/common/src/core/types/IHubLocation.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/common/src/content/_internal/computeProps.ts b/packages/common/src/content/_internal/computeProps.ts index 13d57a41b27..b36d3ba6b59 100644 --- a/packages/common/src/content/_internal/computeProps.ts +++ b/packages/common/src/content/_internal/computeProps.ts @@ -25,13 +25,9 @@ export const getExtentObject = (itemExtent: number[][]): IExtent => { export function deriveLocationFromItemExtent(itemExtent?: number[][]) { const location: IHubLocation = { type: "custom" }; - const geometry: any = getExtentObject(itemExtent); // TODO: this needs to be fixed -tom + const geometry: any = getExtentObject(itemExtent); if (geometry) { - const convertedExtent = { - ...extentToPolygon(geometry), - type: "polygon", - } as unknown as Geometry; - location.geometries = [convertedExtent]; + location.geometries = [geometry]; location.spatialReference = geometry.spatialReference; location.extent = itemExtent; } diff --git a/packages/common/src/core/types/IHubLocation.ts b/packages/common/src/core/types/IHubLocation.ts index 2c82db47ae3..ed99cfb9ce5 100644 --- a/packages/common/src/core/types/IHubLocation.ts +++ b/packages/common/src/core/types/IHubLocation.ts @@ -17,8 +17,14 @@ export interface IHubLocation { // the extent of the location extent?: number[][]; - // An esri geometry: __esri.Geometry - geometries?: __esri.Geometry[]; + // array of geometries representing the location + // NOTE: we use partial here b/c __esri.Geometry + // is the type for instances and includes methods, etc + // but we want to be able to pass around POJOs as well as instances + // instead, we might want to use __esri.GeometryProperties or + // a discriminated union of the point, line, polygon, and extent _property_ types + // but for now it is a non-breaking change to relax __esri.Geometry w/ a partial + geometries?: Array>; // DEPRECATED: the following will be removed at next breaking version provenance?: "none" | "custom" | "existing";