-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reveal): Add support for CDM 360 images in reveal (#4894)
* Add support for CDM 360 images in reveal and reveal react components * Update api spec * Make amends * Move type to top of file * Revert changes to what's in master for react-components * Bump version * Bump minor instead of patch as API has changed
- Loading branch information
1 parent
f130c6a
commit 1f9db64
Showing
12 changed files
with
666 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
252 changes: 252 additions & 0 deletions
252
.../image-360-data-providers/descriptor-providers/datamodels/cdm/Cdf360CdmDescriptor.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
/*! | ||
* Copyright 2023 Cognite AS | ||
*/ | ||
|
||
import { CogniteClient, FileInfo } from '@cognite/sdk'; | ||
import { Cdf360CdmDescriptorProvider } from './Cdf360CdmDescriptorProvider'; | ||
import { It, Mock } from 'moq.ts'; | ||
|
||
const mock = { | ||
headers: { | ||
'access-control-allow-credentials': 'false', | ||
'access-control-allow-headers': | ||
'accept,accept-language,content-type,content-language,content-range,origin,authorization,api-key,auth-ticket,cdf-version,cdf-experiments,env,x-cdp-app,x-cdp-clienttag,x-cdp-sdk,x-ms-blob-content-type,x-upload-content-type,x-user-agent', | ||
'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD', | ||
'access-control-allow-origin': '*', | ||
'access-control-expose-headers': 'x-request-id', | ||
'access-control-max-age': '7200', | ||
connection: 'close', | ||
'content-encoding': 'gzip', | ||
'content-length': '6542', | ||
'content-type': 'application/json', | ||
date: 'Thu, 16 Nov 2023 14:46:45 GMT', | ||
server: 'envoy', | ||
'strict-transport-security': 'max-age=31536000', | ||
vary: 'Accept-Encoding', | ||
'x-envoy-upstream-service-time': '143', | ||
'x-request-id': '87518dc6-0c61-9ef0-9588-94f61ab5a450' | ||
}, | ||
status: 200, | ||
data: { | ||
items: { | ||
image_collection: [ | ||
{ | ||
instanceType: 'node', | ||
version: 1, | ||
space: 'test_space', | ||
externalId: 'test_collection', | ||
createdTime: 0, | ||
lastUpdatedTime: 0, | ||
properties: { | ||
cdf_cdm: { | ||
'Cognite360ImageCollection/v1': { | ||
name: 'Test Collection' | ||
} | ||
} | ||
} | ||
} | ||
], | ||
images: [ | ||
{ | ||
instanceType: 'node', | ||
version: 1, | ||
space: 'test_space', | ||
externalId: 'test_image_1', | ||
createdTime: 0, | ||
lastUpdatedTime: 0, | ||
properties: { | ||
cdf_cdm: { | ||
'Cognite360Image/v1': { | ||
top: { | ||
externalId: 'test_image_3_Top', | ||
space: 'test_space' | ||
}, | ||
back: { | ||
externalId: 'test_image_3_Back', | ||
space: 'test_space' | ||
}, | ||
left: { | ||
externalId: 'test_image_3_Left', | ||
space: 'test_space' | ||
}, | ||
front: { | ||
externalId: 'test_image_3_Front', | ||
space: 'test_space' | ||
}, | ||
right: { | ||
externalId: 'test_image_3_Right', | ||
space: 'test_space' | ||
}, | ||
bottom: { | ||
externalId: 'test_image_3_Bottom', | ||
space: 'test_space' | ||
}, | ||
collection360: { | ||
space: 'test_space', | ||
externalId: 'test_collection' | ||
}, | ||
scaleX: 1, | ||
scaleY: 1, | ||
scaleZ: 1, | ||
translationX: 0, | ||
translationY: 0, | ||
translationZ: 0, | ||
eulerRotationX: 0, | ||
eulerRotationY: 0, | ||
eulerRotationZ: 0 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
instanceType: 'node', | ||
version: 1, | ||
space: 'test_space', | ||
externalId: 'test_image_2', | ||
createdTime: 0, | ||
lastUpdatedTime: 0, | ||
properties: { | ||
cdf_cdm: { | ||
'Cognite360Image/v1': { | ||
top: { | ||
externalId: 'test_image_3_Top', | ||
space: 'test_space' | ||
}, | ||
back: { | ||
externalId: 'test_image_3_Back', | ||
space: 'test_space' | ||
}, | ||
left: { | ||
externalId: 'test_image_3_Left', | ||
space: 'test_space' | ||
}, | ||
front: { | ||
externalId: 'test_image_3_Front', | ||
space: 'test_space' | ||
}, | ||
right: { | ||
externalId: 'test_image_3_Right', | ||
space: 'test_space' | ||
}, | ||
bottom: { | ||
externalId: 'test_image_3_Bottom', | ||
space: 'test_space' | ||
}, | ||
collection360: { | ||
space: 'test_space', | ||
externalId: 'test_collection' | ||
}, | ||
scaleX: 1, | ||
scaleY: 1, | ||
scaleZ: 1, | ||
translationX: 1, | ||
translationY: 1, | ||
translationZ: 1, | ||
eulerRotationX: 1, | ||
eulerRotationY: 1, | ||
eulerRotationZ: 1 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
instanceType: 'node', | ||
version: 1, | ||
space: 'test_space', | ||
externalId: 'test_image_3', | ||
createdTime: 0, | ||
lastUpdatedTime: 0, | ||
properties: { | ||
cdf_cdm: { | ||
'Cognite360Image/v1': { | ||
top: { | ||
externalId: 'test_image_3_Top', | ||
space: 'test_space' | ||
}, | ||
back: { | ||
externalId: 'test_image_3_Back', | ||
space: 'test_space' | ||
}, | ||
left: { | ||
externalId: 'test_image_3_Left', | ||
space: 'test_space' | ||
}, | ||
front: { | ||
externalId: 'test_image_3_Front', | ||
space: 'test_space' | ||
}, | ||
right: { | ||
externalId: 'test_image_3_Right', | ||
space: 'test_space' | ||
}, | ||
bottom: { | ||
externalId: 'test_image_3_Bottom', | ||
space: 'test_space' | ||
}, | ||
collection360: { | ||
space: 'test_space', | ||
externalId: 'test_collection' | ||
}, | ||
scaleX: 1, | ||
scaleY: 1, | ||
scaleZ: 1, | ||
translationX: 3, | ||
translationY: 3, | ||
translationZ: 3, | ||
eulerRotationX: 3, | ||
eulerRotationY: 3, | ||
eulerRotationZ: 3 | ||
} | ||
} | ||
} | ||
} | ||
], | ||
stations: [] | ||
} | ||
} | ||
}; | ||
|
||
describe(Cdf360CdmDescriptorProvider.name, () => { | ||
test('MyTest', async () => { | ||
const sdkMock = new Mock<CogniteClient>() | ||
.setup(instance => | ||
instance.post( | ||
It.Is((path: string) => path.includes('query')), | ||
It.IsAny() | ||
) | ||
) | ||
.returns(Promise.resolve(mock)) | ||
.setup(instance => | ||
instance.post( | ||
It.Is((path: string) => path.includes('files')), | ||
It.IsAny() | ||
) | ||
) | ||
.returns( | ||
Promise.resolve({ | ||
data: { | ||
items: mock.data.items.images | ||
.map((_, n) => Array.from(Array(6).keys()).map(_ => ({ id: n, mimeType: 'image/jpeg' }) as FileInfo)) | ||
.flatMap(p => p) | ||
}, | ||
headers: {}, | ||
status: 200 | ||
}) | ||
) | ||
.setup(instance => instance.getBaseUrl()) | ||
.returns('https://example.com'); | ||
|
||
const provider = new Cdf360CdmDescriptorProvider(sdkMock.object()); | ||
|
||
const descriptors = await provider.get360ImageDescriptors( | ||
{ | ||
source: 'cdm', | ||
space: 'christjt-test-system-360', | ||
image360CollectionExternalId: 'c_RC_2' | ||
}, | ||
true | ||
); | ||
|
||
expect(descriptors.length).toBe(3); | ||
}); | ||
}); |
Oops, something went wrong.