Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2023.02.xx] #9368: adding support 3D tiles resources in catalog for CSW #9599

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading