forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
geosolutions-it#9830: Support for IFC as a further 3D model
Description: - Hide opacity from display tab for ifc model - Write unit tests - Update copyright year for the new created files
- Loading branch information
1 parent
2cbbd73
commit 311be12
Showing
9 changed files
with
220 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/** | ||
* Copyright 2024, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import expect from 'expect'; | ||
import { | ||
textSearch, | ||
getLayerFromRecord, | ||
getCatalogRecords, | ||
validate | ||
} from '../Model'; | ||
|
||
|
||
describe('Test IFC Model catalog API', () => { | ||
it('should return a single record for ifcModel.ifc', (done) => { | ||
textSearch('base/web/client/test-resources/ifcModels/ifcModel.ifc') | ||
.then((response) => { | ||
expect(response.records.length).toBe(1); | ||
expect(response.records[0].title).toBe('ifcModels'); | ||
done(); | ||
}); | ||
}); | ||
it('should always return a single record even if title not match the filter', (done) => { | ||
textSearch('base/web/client/test-resources/ifcModels/ifcModel.ifc', undefined, undefined, 'filter') | ||
.then((response) => { | ||
expect(response.records.length).toBe(1); | ||
done(); | ||
}); | ||
}); | ||
it('should return a single record if title match the filter', (done) => { | ||
textSearch('base/web/client/test-resources/ifcModels/ifcModel.ifc', undefined, undefined, 'service') | ||
.then((response) => { | ||
expect(response.records.length).toBe(1); | ||
expect(response.records[0].title).toBe('ifcModels'); | ||
done(); | ||
}); | ||
}); | ||
it('should return a single record with title equal to the last path fragment', (done) => { | ||
textSearch('base/web/client/test-resources/ifcModels/ifcModel.ifc') | ||
.then((response) => { | ||
expect(response.records.length).toBe(1); | ||
expect(response.records[0].title).toBe('ifcModels'); | ||
done(); | ||
}); | ||
}); | ||
it('should return a single record with title from info service if available', (done) => { | ||
textSearch('base/web/client/test-resources/ifcModels/ifcModel.ifc', undefined, undefined, '', { options: { service: { title: 'ifc model title' } } }) | ||
.then((response) => { | ||
expect(response.records.length).toBe(1); | ||
expect(response.records[0].title).toBe('ifc model title'); | ||
done(); | ||
}); | ||
}); | ||
it('should map the tileset record to a catalog record', () => { | ||
const records = getCatalogRecords({ records: [{ | ||
title: 'Title', | ||
url: 'base/web/client/test-resources/ifcModels/ifcModel.ifc', | ||
type: 'model', | ||
version: '1.0' | ||
}] }); | ||
expect(records.length).toBe(1); | ||
const { | ||
serviceType, | ||
isValid, | ||
description, | ||
title, | ||
identifier, | ||
url | ||
} = records[0]; | ||
|
||
expect(serviceType).toBe('model'); | ||
expect(isValid).toBe(true); | ||
expect(description).toBe('v. 1.0'); | ||
expect(title).toBe('Title'); | ||
expect(identifier).toBe('base/web/client/test-resources/ifcModels/ifcModel.ifc'); | ||
expect(url).toBe('base/web/client/test-resources/ifcModels/ifcModel.ifc'); | ||
}); | ||
|
||
it('should extract the layer config from a catalog record', () => { | ||
const catalogRecord = { | ||
serviceType: 'model', | ||
isValid: true, | ||
description: 'v. 1.0', | ||
title: 'Title', | ||
identifier: 'base/web/client/test-resources/ifcModels/ifcModel.ifc', | ||
url: 'base/web/client/test-resources/ifcModels/ifcModel.ifc', | ||
thumbnail: null, | ||
bbox: { | ||
crs: 'EPSG:4326', | ||
bounds: { | ||
minx: 0, | ||
miny: 0, | ||
maxx: 0, | ||
maxy: 0 | ||
} | ||
}, | ||
references: [] | ||
}; | ||
const layer = getLayerFromRecord(catalogRecord); | ||
expect(layer).toEqual({ | ||
type: 'model', | ||
url: 'base/web/client/test-resources/ifcModels/ifcModel.ifc', | ||
title: 'Title', | ||
visibility: true, | ||
bbox: { | ||
crs: 'EPSG:4326', | ||
bounds: { | ||
minx: 0, | ||
miny: 0, | ||
maxx: 0, | ||
maxy: 0 | ||
} | ||
}, | ||
center: [0, 0, 0] | ||
}); | ||
}); | ||
it('should validate if the service url ends with .ifc', (done) => { | ||
const service = { title: 'IFC Model', url: 'https://service.org/ifcModel.ifc' }; | ||
validate(service) | ||
.toPromise() | ||
.then((response) => { | ||
expect(response).toBeTruthy(true); | ||
done(); | ||
}) | ||
.catch(e => { | ||
done(e); | ||
}); | ||
}); | ||
it('should throw an error on validation if service does not ends with .ifc', (done) => { | ||
const service = { title: 'IFC Model', url: 'http://service.org/ifcmodel' }; | ||
try { | ||
validate(service); | ||
} catch (e) { | ||
expect(e.message).toBe('catalog.config.notValidURLTemplate'); | ||
done(); | ||
} | ||
}); | ||
}); |
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
2 changes: 1 addition & 1 deletion
2
web/client/components/TOC/fragments/settings/ModelTransformation.jsx
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
2 changes: 1 addition & 1 deletion
2
web/client/components/TOC/fragments/settings/__tests__/ModelTransformation-test.jsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2024, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import expect from 'expect'; | ||
import model from '../model'; | ||
|
||
describe('mapinfo 3D tiles utils', () => { | ||
it('should create a request with empty features', () => { | ||
const layer = { | ||
title: 'Title' | ||
}; | ||
const request = model.buildRequest(layer); | ||
expect(request).toEqual({ | ||
request: { | ||
features: [], | ||
outputFormat: 'application/json', | ||
lat: undefined, | ||
lng: undefined | ||
}, | ||
metadata: { | ||
title: layer.title, fields: [], resolution: undefined, buffer: 2, units: undefined, rowViewer: undefined, viewer: undefined, layerId: undefined | ||
}, | ||
url: 'client' | ||
}); | ||
}); | ||
it('should create a request with features retrieved from the intersected ones', () => { | ||
const layer = { | ||
id: 'layer-id', | ||
title: 'Title' | ||
}; | ||
const point = { | ||
intersectedFeatures: [{ id: 'layer-id', features: [{ type: 'Feature', properties: { key: 'value' }, geometry: null }] }], latlng: { lat: 1, lng: 1 } | ||
}; | ||
const request = model.buildRequest(layer, { point }); | ||
expect(request).toEqual({ | ||
request: { | ||
features: [{ type: 'Feature', properties: { key: 'value' }, geometry: null }], | ||
outputFormat: 'application/json', | ||
lat: 1, | ||
lng: 1 | ||
}, | ||
metadata: { | ||
title: layer.title, fields: [], resolution: undefined, buffer: 2, units: undefined, rowViewer: undefined, viewer: undefined, layerId: 'layer-id' | ||
}, | ||
url: 'client' | ||
}); | ||
}); | ||
it('should return the response object from getIdentifyFlow', (done) => { | ||
model.getIdentifyFlow(undefined, undefined, { features: [] }) | ||
.toPromise() | ||
.then((response) => { | ||
expect(response).toEqual({ | ||
data: { | ||
features: [] | ||
} | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); |
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