Skip to content

Commit

Permalink
geosolutions-it#9368: adding support 3D tiles resources in catalog fo…
Browse files Browse the repository at this point in the history
…r CSW (geosolutions-it#9443)

* geosolutions-it#9368: adding support 3D tiles resources in catalog for CSW
* geosolutions-it#9368: enable reading metadata from csw for 3d tiles
* geosolutions-it#9368: resolve comment of removing unneeded code in localConfig
* geosolutions-it#9368: resovle comment: provide more generic test data for testing 3d tiles in csw in test file
* geosolutions-it#9368: resolve comment about renaming 'getCesiumBoundFromOWS' function to 'transformExtentToObj' and add decription to test file for coordinateUtils
* resolving review changes
Desription:
* resolving review comments
Description: \n 1- Edit in function description in CoordinatesUtils. \n 2- Remove not needed cfg in localConfig
* resolve review comments
Description: \n - edit IT translation. \n - edit transformExtentToObj description/
  • Loading branch information
mahmoudadel54 committed Oct 15, 2023
1 parent b81c200 commit bb895c1
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 24 deletions.
5 changes: 5 additions & 0 deletions web/client/api/ThreeDTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,8 @@ export const getCapabilities = (url) => {
return extractCapabilities(data).then((properties) => ({ tileset: data, ...properties }));
});
};

/**
* constant of 3D tiles 'format'
*/
export const THREE_D_TILES = "3D Tiles";
63 changes: 46 additions & 17 deletions web/client/api/catalog/CSW.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import { head, isString, includes, castArray, sortBy, uniq } from 'lodash';
import { getLayerFromRecord as getLayerFromWMSRecord } from './WMS';
import { getMessageById } from '../../utils/LocaleUtils';
import { transformExtentToObj} from '../../utils/CoordinatesUtils';
import { extractEsriReferences, extractOGCServicesReferences } from '../../utils/CatalogUtils';
import CSW, { getLayerReferenceFromDc } from '../CSW';
import {
validate as commonValidate,
testService as commonTestService,
preprocess as commonPreprocess
} from './common';

import { THREE_D_TILES } from '../ThreeDTiles';
const getBaseCatalogUrl = (url) => {
return url && url.replace(/\/csw$/, "/");
};
Expand Down Expand Up @@ -102,6 +103,27 @@ function getThumbnailFromDc(dc, options) {
}
return thumbURL;
}
function getCatalogRecord3DTiles(record, metadata) {
const dc = record.dc;
let bbox = {
crs: record.boundingBox.crs,
bounds: transformExtentToObj(record.boundingBox.extent)
};
return {
serviceType: '3dtiles',
isValid: true,
description: dc && isString(dc.abstract) && dc.abstract || '',
title: dc && isString(dc.title) && dc.title || '',
identifier: dc && isString(dc.identifier) && dc.identifier || '',
url: dc?.URI?.value || "",
thumbnail: null,
bbox,
format: dc && dc.format || "",
references: [],
catalogType: 'csw',
metadata
};
}

const recordToLayer = (record, options) => {
switch (record.layerType) {
Expand Down Expand Up @@ -210,22 +232,29 @@ export const getCatalogRecords = (records, options, locales) => {
const ogcReferences = layerType && layerType !== 'esri'
? parsedReferences[layerType]
: undefined;
return {
serviceType: 'csw',
layerType,
isValid: !!layerType,
boundingBox: record.boundingBox,
description: dc && isString(dc.abstract) && dc.abstract || '',
layerOptions: options && options.layerOptions || {},
identifier: dc && isString(dc.identifier) && dc.identifier || '',
references: references,
thumbnail: getThumbnailFromDc(dc, options),
title: dc && isString(dc.title) && dc.title || '',
tags: dc && dc.tags || '',
metadata,
capabilities: record.capabilities,
ogcReferences
};
let catRecord;
if (dc && dc.format === THREE_D_TILES) {
catRecord = getCatalogRecord3DTiles(record, metadata);

} else {
catRecord = {
serviceType: 'csw',
layerType,
isValid: !!layerType,
boundingBox: record.boundingBox,
description: dc && isString(dc.abstract) && dc.abstract || '',
layerOptions: options && options.layerOptions || {},
identifier: dc && isString(dc.identifier) && dc.identifier || '',
references: references,
thumbnail: getThumbnailFromDc(dc, options),
title: dc && isString(dc.title) && dc.title || '',
tags: dc && dc.tags || '',
metadata,
capabilities: record.capabilities,
ogcReferences
};
}
return catRecord;
});
}
return null;
Expand Down
30 changes: 29 additions & 1 deletion web/client/api/catalog/__tests__/CSW-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { map, clone } from 'lodash';
import {
getCatalogRecords
} from '../CSW';
import { THREE_D_TILES } from '../../ThreeDTiles';

describe('Test correctness of the CSW catalog APIs', () => {
it('csw empty', () => {
Expand Down Expand Up @@ -302,7 +303,34 @@ describe('Test correctness of the CSW catalog APIs', () => {
}, {});
expect(records.length).toBe(1);
});

it('csw with DC URI 3D Tiles', ()=>{
const records = [{
boundingBox: {
"extent": [
43.718, 11.1, 43.84, 11.348
],
"crs": "EPSG:4326"
},
dc: {
URI: {
TYPE_NAME: "DC_1_1.URI",
description: "access point",
protocol: "https://hostname/ProtocolValue/www-download",
value: "https://hostname/3dtiles/layername/tileset.json"
}, format: THREE_D_TILES, identifier: "test:layername", title: "3D Tiles layer for test"
}
}];
const catalogRecords = getCatalogRecords({records});
expect(catalogRecords.length).toBe(1);
expect(catalogRecords[0].bbox).toEqual({ bounds: {minx: 43.718, miny: 11.1, maxx: 43.84, maxy: 11.348}, crs: 'EPSG:4326' });
expect(catalogRecords[0].url).toEqual("https://hostname/3dtiles/layername/tileset.json");
expect(catalogRecords[0].identifier).toEqual("test:layername");
expect(catalogRecords[0].title).toEqual("3D Tiles layer for test");
expect(catalogRecords[0].serviceType).toEqual("3dtiles");
expect(catalogRecords[0].isValid).toEqual(true);
expect(catalogRecords[0].format).toEqual('3D Tiles');
expect(catalogRecords[0].catalogType).toEqual('csw');
});
it('csw with DC references', () => {
const records = getCatalogRecords({
records: [{
Expand Down
2 changes: 2 additions & 0 deletions web/client/components/catalog/RecordItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ class RecordItem extends React.Component {
caption={
<div>
{!this.props.hideIdentifier && <div className="identifier">{record && record.identifier}</div>}
{record?.serviceType === '3dtiles' && record?.catalogType === 'csw' && <small className="text-info">
<Message msgId="catalog.3dTileLayerIndicator"/></small>}
<div>{!record.isValid && <small className="text-danger"><Message msgId="catalog.missingReference"/></small>}</div>
{!this.props.hideExpand &&
<div
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,8 @@
"allowUnsecureLayers": {
"label": "Nicht sichere Ebenen zulassen",
"tooltip": "Das Hinzufügen einer Ebene zur Karte mit aktivierter Option zwingt die Anwendung, Proxy anzuwenden"
}
},
"3dTileLayerIndicator":"3D -Fliesenschicht"
},
"uploader": {
"filename": "Dateiname",
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,8 @@
"helpTooltip": "This option is used to split content across multiple subdomains",
"addAliasTooltip": "Add alias",
"removeAliasTooltip": "Remove alias"
}
},
"3dTileLayerIndicator":"3D Tile Layer"
},
"uploader": {
"filename": "File Name",
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,8 @@
"allowUnsecureLayers": {
"label": "Permitir capas no seguras",
"tooltip": "Agregar una capa al mapa con esta opción habilitada obliga a la aplicación a aplicar proxy"
}
},
"3dTileLayerIndicator":"Capa de mosaico 3D"
},
"uploader": {
"filename": "Nombre del fichero",
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,8 @@
"allowUnsecureLayers": {
"label": "Autoriser les couches non sécurisées",
"tooltip": "L'ajout d'une couche à la carte avec cette option activée force l'application à appliquer un proxy"
}
},
"3dTileLayerIndicator":"Couche de carreaux 3D"
},
"uploader": {
"filename": "Nom du fichier",
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,8 @@
"allowUnsecureLayers": {
"label": "Consenti livelli non sicuri",
"tooltip": "L'aggiunta di un livello da mappare con questa opzione abilitata, costringe l'applicazione ad applicare il proxy"
}
},
"3dTileLayerIndicator":"Livello 3D tile"
},
"uploader": {
"filename": "File Name",
Expand Down
16 changes: 16 additions & 0 deletions web/client/utils/CoordinatesUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,22 @@ export const makeBboxFromOWS = (lcOWS, ucOWS) => {
return [lc[0], lc[1], uc[0], uc[1]];
};

/**
* helper use to transform the extent array to bound object { minx, miny, maxx, maxy }
* if there is no provided param extent it will return the default bound object of wgs84
* @param {number[]} extent is an array of 4 ordered coordinates [minx, miny, maxx, maxy]
*/
export const transformExtentToObj = (extent) => {
let [minx, miny, maxx, maxy] = extent ? [...extent] : [-180, -90, 180, 90];
return {
minx,
miny,
maxx,
maxy
};

};


/**
* helper use to create a geojson Feature with a Polygon geometry
Expand Down
17 changes: 16 additions & 1 deletion web/client/utils/__tests__/CoordinatesUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
makeNumericEPSG,
getPolygonFromCircle,
checkIfLayerFitsExtentForProjection,
getLonLatFromPoint, convertRadianToDegrees, convertDegreesToRadian
getLonLatFromPoint, convertRadianToDegrees, convertDegreesToRadian, transformExtentToObj
} from '../CoordinatesUtils';

import Proj4js from 'proj4';
Expand Down Expand Up @@ -766,6 +766,21 @@ describe('CoordinatesUtils', () => {
const uc = [2, 4];
expect(makeBboxFromOWS(lc, uc)).toEqual([2, 2, 4, 4]);
});
describe('test transformExtentToObj to return bound obj', ()=>{

it('with provided extent ', ()=>{
const extent = [1, 1, 5, 5];
expect(transformExtentToObj(extent)).toEqual({
minx: 1, miny: 1, maxx: 5, maxy: 5
});
});
it('with no extent passed', ()=>{
const extent = undefined;
expect(transformExtentToObj(extent)).toEqual({
minx: -180, miny: -90, maxx: 180, maxy: 90
});
});
});
it('extractCrsFromURN #1', () => {
const urn = 'urn:ogc:def:crs:EPSG:6.6:4326';
expect(extractCrsFromURN(urn)).toBe('EPSG:4326');
Expand Down

0 comments on commit bb895c1

Please sign in to comment.