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

Standardize method names for 3DTiles metadata #10473

Merged
merged 3 commits into from
Jun 23, 2022
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
10 changes: 5 additions & 5 deletions Apps/Sandcastle/gallery/3D Tiles Batch Table Hierarchy.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@
}
console.log(`Class: ${feature.getExactClassName()}`);
console.log("Properties:");
const propertyNames = feature.getPropertyNames();
const length = propertyNames.length;
const propertyIds = feature.getPropertyIds();
const length = propertyIds.length;
for (let i = 0; i < length; ++i) {
const name = propertyNames[i];
const value = feature.getProperty(name);
console.log(` ${name}: ${value}`);
const propertyId = propertyIds[i];
const value = feature.getProperty(propertyId);
console.log(` ${propertyId}: ${value}`);
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

Expand Down
10 changes: 4 additions & 6 deletions Apps/Sandcastle/gallery/3D Tiles Formats.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,11 @@
handler.setInputAction(function (movement) {
const feature = inspectorViewModel.feature;
if (Cesium.defined(feature)) {
const propertyNames = feature.getPropertyNames();
const length = propertyNames.length;
const propertyIds = feature.getPropertyIds();
const length = propertyIds.length;
for (let i = 0; i < length; ++i) {
const propertyName = propertyNames[i];
console.log(
`${propertyName}: ${feature.getProperty(propertyName)}`
);
const propertyId = propertyIds[i];
console.log(`${propertyId}: ${feature.getProperty(propertyId)}`);
}
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Expand Down
10 changes: 4 additions & 6 deletions Apps/Sandcastle/gallery/3D Tiles Interactivity.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,11 @@

function printProperties(movement, feature) {
console.log("Properties:");
const propertyNames = feature.getPropertyNames();
const length = propertyNames.length;
const propertyIds = feature.getPropertyIds();
const length = propertyIds.length;
for (let i = 0; i < length; ++i) {
const propertyName = propertyNames[i];
console.log(
` ${propertyName}: ${feature.getProperty(propertyName)}`
);
const propertyId = propertyIds[i];
console.log(` ${propertyId}: ${feature.getProperty(propertyId)}`);
}

// Evaluate feature description
Expand Down
16 changes: 8 additions & 8 deletions Apps/Sandcastle/gallery/3D Tiles Next CDB Yemen.html
Original file line number Diff line number Diff line change
Expand Up @@ -331,22 +331,22 @@
"<tr><th>Property Name</th><th>ID</th><th>Type</th><th>Value</th></tr><tbody>";
const metadataClass =
feature.content.batchTable._propertyTable.class;
const propertyNames = feature.getPropertyNames();
const length = propertyNames.length;
const propertyIds = feature.getPropertyIds();
const length = propertyIds.length;
for (let i = 0; i < length; ++i) {
const propertyName = propertyNames[i];
const propertyId = propertyIds[i];

// Skip these properties, since they are always empty.
if (
propertyName === "APID" ||
propertyName === "FACC" ||
propertyName === "RWID"
propertyId === "APID" ||
propertyId === "FACC" ||
propertyId === "RWID"
) {
continue;
}

const propertyValue = feature.getProperty(propertyName);
const property = metadataClass.properties[propertyName];
const propertyValue = feature.getProperty(propertyId);
const property = metadataClass.properties[propertyId];

const propertyType = Cesium.defaultValue(
property.componentType,
Expand Down
10 changes: 5 additions & 5 deletions Apps/Sandcastle/gallery/3D Tiles Next S2 Globe.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@
tableHtmlScratch =
"<table><thead><tr><th><tt>Property</tt></th><th><tt>Value</tt></th></tr></thead><tbody>";

const propertyNames = feature.getPropertyNames();
const length = propertyNames.length;
const propertyIds = feature.getPropertyIds();
const length = propertyIds.length;
for (let i = 0; i < length; ++i) {
const propertyName = propertyNames[i];
const propertyValue = feature.getProperty(propertyName);
tableHtmlScratch += `<tr><td><tt>${propertyName}</tt></td><td><tt>${propertyValue}</tt></td></tr>`;
const propertyId = propertyIds[i];
const propertyValue = feature.getProperty(propertyId);
tableHtmlScratch += `<tr><td><tt>${propertyId}</tt></td><td><tt>${propertyValue}</tt></td></tr>`;
}
tableHtmlScratch += "</tbody></table>";
metadataOverlay.innerHTML = tableHtmlScratch;
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
- Warn if `Cesium3DTile` content.uri property is empty, and load empty tile. [#7263](https://github.com/CesiumGS/cesium/issues/7263)
- Updated text highlighting for code examples in documentation. [10051](https://github.com/CesiumGS/cesium/issues/10051)

##### Deprecated :hourglass_flowing_sand:

- The `.getPropertyNames` methods of `Cesium3DTileFeature`, `Cesium3DTilePointFeature`, and `ModelFeature` have been deprecated and will be removed in 1.98. Use the `.getPropertyIds` methods instead.

### 1.94.3 - 2022-06-10

- Fixed a crash with vector tilesets with lines when clamping to terrain or 3D tiles. [#10447](https://github.com/CesiumGS/cesium/pull/10447)
Expand Down
11 changes: 4 additions & 7 deletions Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,24 +364,21 @@ Cesium3DTileBatchTable.prototype.hasPropertyBySemantic = function () {
return false;
};

Cesium3DTileBatchTable.prototype.getPropertyNames = function (
batchId,
results
) {
Cesium3DTileBatchTable.prototype.getPropertyIds = function (batchId, results) {
//>>includeStart('debug', pragmas.debug);
checkBatchId(batchId, this.featuresLength);
//>>includeEnd('debug');

results = defined(results) ? results : [];
results.length = 0;

const scratchPropertyNames = Object.keys(this._properties);
results.push.apply(results, scratchPropertyNames);
const scratchPropertyIds = Object.keys(this._properties);
results.push.apply(results, scratchPropertyIds);

if (defined(this._batchTableHierarchy)) {
results.push.apply(
results,
this._batchTableHierarchy.getPropertyIds(batchId, scratchPropertyNames)
this._batchTableHierarchy.getPropertyIds(batchId, scratchPropertyIds)
);
}

Expand Down
38 changes: 29 additions & 9 deletions Source/Scene/Cesium3DTileFeature.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Color from "../Core/Color.js";
import defined from "../Core/defined.js";
import deprecationWarning from "../Core/deprecationWarning.js";

/**
* A feature of a {@link Cesium3DTileset}.
Expand Down Expand Up @@ -27,11 +28,11 @@ import defined from "../Core/defined.js";
* handler.setInputAction(function(movement) {
* const feature = scene.pick(movement.endPosition);
* if (feature instanceof Cesium.Cesium3DTileFeature) {
* const propertyNames = feature.getPropertyNames();
* const length = propertyNames.length;
* const propertyIds = feature.getPropertyIds();
* const length = propertyIds.length;
* for (let i = 0; i < length; ++i) {
* const propertyName = propertyNames[i];
* console.log(`{propertyName}: ${feature.getProperty(propertyName)}`);
* const propertyId = propertyIds[i];
* console.log(`{propertyId}: ${feature.getProperty(propertyId)}`);
* }
* }
* }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
Expand Down Expand Up @@ -200,11 +201,30 @@ Cesium3DTileFeature.prototype.hasProperty = function (name) {
*
* @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_batch_table_hierarchy}
*
* @deprecated
*
* @param {String[]} [results] An array into which to store the results.
* @returns {String[]} The names of the feature's properties.
*/
Cesium3DTileFeature.prototype.getPropertyNames = function (results) {
return this._content.batchTable.getPropertyNames(this._batchId, results);
deprecationWarning(
"Cesium3DTileFeature.getPropertyNames",
"Cesium3DTileFeature.getPropertyNames was deprecated in CesiumJS 1.95 and will be removed in 1.98. Use Cesium3DTileFeature.getPropertyIds instead"
);
return this._content.batchTable.getPropertyIds(this._batchId, results);
};

/**
* Returns an array of property IDs for the feature. This includes properties from this feature's
* class and inherited classes when using a batch table hierarchy.
*
* @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_batch_table_hierarchy}
*
* @param {String[]} [results] An array into which to store the results.
* @returns {String[]} The IDs of the feature's properties.
*/
Cesium3DTileFeature.prototype.getPropertyIds = function (results) {
return this._content.batchTable.getPropertyIds(this._batchId, results);
};

/**
Expand All @@ -218,11 +238,11 @@ Cesium3DTileFeature.prototype.getPropertyNames = function (results) {
*
* @example
* // Display all the properties for a feature in the console log.
* const propertyNames = feature.getPropertyNames();
* const length = propertyNames.length;
* const propertyIds = feature.getPropertyIds();
* const length = propertyIds.length;
* for (let i = 0; i < length; ++i) {
* const propertyName = propertyNames[i];
* console.log(`{propertyName}: ${feature.getProperty(propertyName)}`);
* const propertyId = propertyIds[i];
* console.log(`{propertyId}: ${feature.getProperty(propertyId)}`);
* }
*/
Cesium3DTileFeature.prototype.getProperty = function (name) {
Expand Down
38 changes: 29 additions & 9 deletions Source/Scene/Cesium3DTilePointFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Cartographic from "../Core/Cartographic.js";
import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import deprecationWarning from "../Core/deprecationWarning.js";
import Cesium3DTileFeature from "./Cesium3DTileFeature.js";
import createBillboardPointCallback from "./createBillboardPointCallback.js";

Expand Down Expand Up @@ -32,11 +33,11 @@ import createBillboardPointCallback from "./createBillboardPointCallback.js";
* handler.setInputAction(function(movement) {
* const feature = scene.pick(movement.endPosition);
* if (feature instanceof Cesium.Cesium3DTilePointFeature) {
* const propertyNames = feature.getPropertyNames();
* const length = propertyNames.length;
* const propertyIds = feature.getPropertyIds();
* const length = propertyIds.length;
* for (let i = 0; i < length; ++i) {
* const propertyName = propertyNames[i];
* console.log(`{propertyName}: ${feature.getProperty(propertyName)}`);
* const propertyId = propertyIds[i];
* console.log(`{propertyId}: ${feature.getProperty(propertyId)}`);
* }
* }
* }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
Expand Down Expand Up @@ -732,11 +733,30 @@ Cesium3DTilePointFeature.prototype.hasProperty = function (name) {
*
* @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_batch_table_hierarchy}
*
* @deprecated
*
* @param {String[]} [results] An array into which to store the results.
* @returns {String[]} The names of the feature's properties.
*/
Cesium3DTilePointFeature.prototype.getPropertyNames = function (results) {
return this._content.batchTable.getPropertyNames(this._batchId, results);
deprecationWarning(
"Cesium3DTilePointFeature.getPropertyNames",
"Cesium3DTilePointFeature.getPropertyNames is deprecated in CesiumJS 1.95, and will be removed in 1.98. Use Cesium3DTilePointFeature.getPropertyIds instead"
);
return this._content.batchTable.getPropertyIds(this._batchId, results);
};

/**
* Returns an array of property IDs for the feature. This includes properties from this feature's
* class and inherited classes when using a batch table hierarchy.
*
* @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_batch_table_hierarchy}
*
* @param {String[]} [results] An array into which to store the results.
* @returns {String[]} The IDs of the feature's properties.
*/
Cesium3DTilePointFeature.prototype.getPropertyIds = function (results) {
return this._content.batchTable.getPropertyIds(this._batchId, results);
};

/**
Expand All @@ -750,11 +770,11 @@ Cesium3DTilePointFeature.prototype.getPropertyNames = function (results) {
*
* @example
* // Display all the properties for a feature in the console log.
* const propertyNames = feature.getPropertyNames();
* const length = propertyNames.length;
* const propertyIds = feature.getPropertyIds();
* const length = propertyIds.length;
* for (let i = 0; i < length; ++i) {
* const propertyName = propertyNames[i];
* console.log(`{propertyName} : ${feature.getProperty(propertyName)}`);
* const propertyId = propertyIds[i];
* console.log(`{propertyId} : ${feature.getProperty(propertyId)}`);
* }
*/
Cesium3DTilePointFeature.prototype.getProperty = function (name) {
Expand Down
27 changes: 22 additions & 5 deletions Source/Scene/ModelExperimental/ModelFeature.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Color from "../../Core/Color.js";
import defined from "../../Core/defined.js";
import deprecationWarning from "../../Core/deprecationWarning.js";

/**
* A feature of a {@link ModelExperimental}.
Expand Down Expand Up @@ -154,11 +155,11 @@ ModelFeature.prototype.hasProperty = function (name) {
*
* @example
* // Display all the properties for a feature in the console log.
* const propertyNames = feature.getPropertyNames();
* const length = propertyNames.length;
* const propertyIds = feature.getPropertyIds();
* const length = propertyIds.length;
* for (let i = 0; i < length; ++i) {
* const propertyName = propertyNames[i];
* console.log(propertyName + ': ' + feature.getProperty(propertyName));
* const propertyId = propertyIds[i];
* console.log(propertyId + ': ' + feature.getProperty(propertyId));
* }
*/
ModelFeature.prototype.getProperty = function (name) {
Expand Down Expand Up @@ -195,11 +196,27 @@ ModelFeature.prototype.getPropertyInherited = function (name) {
/**
* Returns an array of property names for the feature.
*
* @deprecated
*
* @param {String[]} [results] An array into which to store the results.
* @returns {String[]} The names of the feature's properties.
*/
ModelFeature.prototype.getPropertyNames = function (results) {
return this._featureTable.getPropertyNames(results);
deprecationWarning(
"ModelFeature.getPropertyNames",
"ModelFeature.getPropertyNames is deprecated in CesiumJS 1.95, and will be removed in 1.98. Use ModelFeature.getPropertyIds instead"
);
return this._featureTable.getPropertyIds(results);
};

/**
* Returns an array of property IDs for the feature.
*
* @param {String[]} [results] An array into which to store the results.
* @returns {String[]} The IDs of the feature's properties.
*/
ModelFeature.prototype.getPropertyIds = function (results) {
return this._featureTable.getPropertyIds(results);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/ModelExperimental/ModelFeatureTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ ModelFeatureTable.prototype.getPropertyBySemantic = function (
return this._propertyTable.getPropertyBySemantic(featureId, semantic);
};

ModelFeatureTable.prototype.getPropertyNames = function (results) {
ModelFeatureTable.prototype.getPropertyIds = function (results) {
return this._propertyTable.getPropertyIds(results);
};

Expand Down
Loading