Skip to content

Commit

Permalink
[Backport 2023.02.xx] #9368: adding support 3D tiles resources in cat…
Browse files Browse the repository at this point in the history
…alog for CSW (#9599)

* #9368: adding support 3D tiles resources in catalog for CSW (#9443)

* #9368: adding support 3D tiles resources in catalog for CSW
* #9368: enable reading metadata from csw for 3d tiles
* #9368: resolve comment of removing unneeded code in localConfig
* #9368: resovle comment: provide more generic test data for testing 3d tiles in csw in test file
* #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/

* #9368: resolve test report comments (#9465)

description: remove not needed span indicator for 3d layer in catalog sidebar+ remove all relevant translates
  • Loading branch information
mahmoudadel54 authored Oct 16, 2023
1 parent b81c200 commit 32eb916
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 19 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
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 32eb916

Please sign in to comment.