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

Add support for Building Scene Layer (BSL) OGC I3S standard #11678

Merged
merged 33 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
808fcaa
- Added support for conversion from sRGB color space profile to linea…
Tamrat-B Dec 5, 2023
0b9869b
Added Support for BSL structure, BSL statistics, generic feature attr…
Tamrat-B Dec 5, 2023
d612e7b
I3S Building Scene Layer Sandcastle app
Tamrat-B Dec 5, 2023
a4da846
I3S BSL app icon
Tamrat-B Dec 5, 2023
f469a21
Added support for conversion from sRGB color space profile to linear …
Tamrat-B Dec 5, 2023
4f92b4a
added additional payload options
Tamrat-B Dec 5, 2023
a2066b0
- Added support for binary attribute data with values stored in objec…
Tamrat-B Dec 5, 2023
562d6e5
- Added support for 3D objects transparency
Tamrat-B Dec 5, 2023
89f6dbe
- Added support for BSL hierarchy of layers
Tamrat-B Dec 5, 2023
394f823
- Added support for the generic feature attribute driven filter
Tamrat-B Dec 5, 2023
1394e4a
Added support for BSL structure per the OGC I3S standard
Tamrat-B Dec 5, 2023
5a34b60
- Added support for symbolization defined in I3S Layer data
Tamrat-B Dec 5, 2023
1054536
Added support for EXT_mesh_features and EXT_structural_metadata glTF …
Tamrat-B Dec 5, 2023
e1d55f7
Added bsl layer tests
Tamrat-B Dec 5, 2023
04f3c51
Added I3S BSL ViewModel tests
Tamrat-B Dec 5, 2023
3e75b94
Added I3S BSL explorer
Tamrat-B Dec 5, 2023
969ac49
Added I3S Explorer tests
Tamrat-B Dec 5, 2023
b4b23a6
Added I3S BSL Explorer layer widget
Tamrat-B Dec 5, 2023
e03286b
Merge branch 'CesiumGS:main' into feature/i3s_bsl_support
Tamrat-B Jan 11, 2024
21b2f4f
updates based on review feedback
Tamrat-B Jan 11, 2024
efc7db5
Added I3S support PR to additions
Tamrat-B Feb 2, 2024
03a9125
removed non necessary options
Tamrat-B Feb 2, 2024
17784df
check before updating visibility
Tamrat-B Feb 2, 2024
c815c03
additional specs changes
Tamrat-B Feb 2, 2024
4bffc64
Merge branch 'main' into feature/i3s_bsl_support
Tamrat-B Feb 2, 2024
9f02cf3
Merge branch 'CesiumGS:main' into feature/i3s_bsl_support
Tamrat-B Feb 28, 2024
9d6dc59
Removed picking result from console output
Tamrat-B Feb 28, 2024
c7570c3
Remove console out if geoid transform is not needed
Tamrat-B Feb 28, 2024
88eae59
Default to model overview if present
Tamrat-B Feb 28, 2024
1aefdc9
update tests to account for model views
Tamrat-B Feb 28, 2024
cf8d1da
Added I3S Building Scene Layer support to March 1 release
Tamrat-B Feb 28, 2024
96aca3e
Handling edge case use cases where there is no Full Model and/or Over…
Tamrat-B Feb 28, 2024
a3ea292
Rename BSL -> BuildingSceneLayer
ggetz Feb 28, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
- Added support for binary attribute data with values stored in objec…
…tIds property

- Added validation for actual and expected binary buffer size
  • Loading branch information
Tamrat-B committed Dec 5, 2023
commit a2066b00cbd5dde69fe588fbb011e16e605166c4
2 changes: 1 addition & 1 deletion packages/engine/Source/Scene/I3SFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Object.defineProperties(I3SFeature.prototype, {

/**
* Loads the content.
* @returns {Promise} A promise that is resolved when the data of the I3S feature is loaded
* @returns {Promise<object>} A promise that is resolved when the data of the I3S feature is loaded
* @private
*/
I3SFeature.prototype.load = async function () {
Expand Down
189 changes: 157 additions & 32 deletions packages/engine/Source/Scene/I3SField.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function I3SField(parent, storageInfo) {
this._storageInfo = storageInfo;
this._parent = parent;
this._dataProvider = parent._dataProvider;
this._loadPromise = undefined;
const uri = `attributes/${storageInfo.key}/0`;

if (defined(this._parent._nodeIndex)) {
Expand Down Expand Up @@ -54,9 +55,16 @@ Object.defineProperties(I3SField.prototype, {
*/
values: {
get: function () {
return defined(this._values) && defined(this._values.attributeValues)
? this._values.attributeValues
: [];
if (defined(this._values)) {
// attribute data can be stored either as values or as object identifiers
if (defined(this._values.attributeValues)) {
return this._values.attributeValues;
}
if (defined(this._values.objectIds)) {
return this._values.objectIds;
}
}
return [];
},
},
/**
Expand Down Expand Up @@ -92,40 +100,50 @@ function getNumericTypeSize(type) {
return 0;
}

function getValueTypeSize(type) {
if (type === "String") {
return 1;
}
return getNumericTypeSize(type);
}

async function load(field) {
const data = await field._dataProvider._loadBinary(field._resource);

// Check if we have a 404
const dataView = new DataView(data);
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
if (dataView.getUint8(0) === "{".charCodeAt(0)) {
const textContent = new TextDecoder();
const str = textContent.decode(data);
if (str.includes("404")) {
console.error(`Failed to load: ${field.resource.url}`);
return;
}
}

field._data = data;
if (!field._validateHeader(dataView)) {
return;
}
const headerSize = field._parseHeader(dataView);
const offset = field._getBodyOffset(headerSize);
if (!field._validateBody(dataView, offset)) {
return;
}
field._parseBody(dataView, offset);
}

/**
* Loads the content.
* @returns {Promise<void>} A promise that is resolved when the field data is loaded
*/
I3SField.prototype.load = function () {
const that = this;
return this._dataProvider._loadBinary(this._resource).then(function (data) {
// Check if we have a 404
const dataView = new DataView(data);
let success = true;
if (dataView.getUint8(0) === "{".charCodeAt(0)) {
const textContent = new TextDecoder();
const str = textContent.decode(data);
if (str.includes("404")) {
success = false;
console.error(`Failed to load: ${that.resource.url}`);
}
}

if (success) {
that._data = data;
let offset = that._parseHeader(dataView);

const valueSize = getNumericTypeSize(
that._storageInfo.attributeValues.valueType
);
if (valueSize > 0) {
// Values will be padded to align the addresses with the data size
offset = Math.ceil(offset / valueSize) * valueSize;
}
if (defined(this._loadPromise)) {
return this._loadPromise;
}

that._parseBody(dataView, offset);
}
});
this._loadPromise = load(this);
return this._loadPromise;
};

/**
Expand Down Expand Up @@ -217,7 +235,9 @@ I3SField.prototype._parseBody = function (dataView, offset) {
itemIndex < this._storageInfo.ordering.length;
itemIndex++
) {
const item = this._storageInfo.ordering[itemIndex];
const orderingValue = this._storageInfo.ordering[itemIndex];
// all strings in the ordering array correspond to the property name, except ObjectIds
const item = orderingValue === "ObjectIds" ? "objectIds" : orderingValue;
const desc = this._storageInfo[item];
if (defined(desc)) {
this._values[item] = [];
Expand Down Expand Up @@ -252,4 +272,109 @@ I3SField.prototype._parseBody = function (dataView, offset) {
}
};

/**
* @private
*/
I3SField.prototype._getBodyOffset = function (headerSize) {
let valueSize = 0;
if (defined(this._storageInfo.attributeValues)) {
valueSize = getNumericTypeSize(this._storageInfo.attributeValues.valueType);
} else if (defined(this._storageInfo.objectIds)) {
valueSize = getNumericTypeSize(this._storageInfo.objectIds.valueType);
}
if (valueSize > 0) {
// Values will be padded to align the addresses with the data size
return Math.ceil(headerSize / valueSize) * valueSize;
}
return headerSize;
};

/**
* @private
*/
I3SField.prototype._validateHeader = function (dataView) {
let headerSize = 0;
for (
let itemIndex = 0;
itemIndex < this._storageInfo.header.length;
itemIndex++
) {
const item = this._storageInfo.header[itemIndex];
headerSize += getValueTypeSize(item.valueType);
}
if (dataView.byteLength < headerSize) {
console.error("Invalid attribute buffer size");
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
console.error(
` (field: ${this.name}, header: ${headerSize}, actual: ${dataView.byteLength})`
);
return false;
}
return true;
};

/**
* @private
*/
I3SField.prototype._validateBody = function (dataView, offset) {
if (!defined(this._header.count)) {
console.error("Invalid attribute buffer");
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
console.error(` (field: ${this.name}, count is missing)`);
return false;
}
let attributeByteCountsOffset;
for (
let itemIndex = 0;
itemIndex < this._storageInfo.ordering.length &&
offset < dataView.byteLength;
itemIndex++
) {
const orderingValue = this._storageInfo.ordering[itemIndex];
// all strings in the ordering array correspond to the property name, except ObjectIds
const item = orderingValue === "ObjectIds" ? "objectIds" : orderingValue;
const desc = this._storageInfo[item];
if (defined(desc)) {
if (desc.valueType !== "String") {
if (item === "attributeByteCounts") {
attributeByteCountsOffset = offset;
}
const valueSize = getNumericTypeSize(desc.valueType);
offset += valueSize * this._header.count;
} else {
if (!defined(attributeByteCountsOffset)) {
console.error("Invalid attribute buffer");
console.error(
` (field: ${this.name}, attributeByteCounts is missing)`
);
return false;
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
}
for (
let index = 0;
index < this._header.count && offset < dataView.byteLength;
++index
) {
const parsedValue = this._parseValue(
dataView,
this._storageInfo.attributeByteCounts.valueType,
attributeByteCountsOffset
);
offset += parsedValue.value;
attributeByteCountsOffset = parsedValue.offset;
}
}
} else {
console.error("Invalid attribute buffer");
console.error(` (field: ${this.name}, ${item} is missing)`);
return false;
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
}
}
if (dataView.byteLength < offset) {
console.error("Invalid attribute buffer size");
console.error(
` (field: ${this.name}, expected: ${offset}, actual: ${dataView.byteLength})`
);
return false;
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
}
return true;
};

export default I3SField;