Skip to content

Commit

Permalink
fix(hub-common): content location should be of type extent, not polyg…
Browse files Browse the repository at this point in the history
…on (#1228)

affects: @esri/hub-common

also relax IHubLocation.geometries to accept POJOs
  • Loading branch information
tomwayson authored Sep 25, 2023
1 parent b292131 commit c5539f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 2 additions & 6 deletions packages/common/src/content/_internal/computeProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 8 additions & 2 deletions packages/common/src/core/types/IHubLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Partial<__esri.Geometry>>;

// DEPRECATED: the following will be removed at next breaking version
provenance?: "none" | "custom" | "existing";
Expand Down

0 comments on commit c5539f4

Please sign in to comment.