智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import defined from "../Core/defined.js";
  2. /**
  3. * Return the `PropertyTextureProperty` from the given `StructuralMetadata`
  4. * that matches the given description.
  5. *
  6. * If the given structural metadata is `undefined`, then `undefined` is returned.
  7. *
  8. * Otherwise, this method will check all the property textures in the given
  9. * structural metadata.
  10. *
  11. * If it finds a property texture that has a class with an `_id` that matches
  12. * the given name, and that contains a property for the given property name, then
  13. * this property is returned.
  14. *
  15. * Otherwise, `undefined` is returned
  16. *
  17. * @param {StructuralMetadata} structuralMetadata The structural metadata
  18. * @param {string} className The name of the metadata class
  19. * @param {string} propertyName The name of the metadata property
  20. * @returns {PropertyTextureProperty|undefined}
  21. * @private
  22. */
  23. function getMetadataProperty(structuralMetadata, className, propertyName) {
  24. if (!defined(structuralMetadata)) {
  25. return undefined;
  26. }
  27. const propertyTextures = structuralMetadata.propertyTextures;
  28. for (const propertyTexture of propertyTextures) {
  29. const metadataClass = propertyTexture.class;
  30. if (metadataClass.id === className) {
  31. const properties = propertyTexture.properties;
  32. const property = properties[propertyName];
  33. if (defined(property)) {
  34. return property;
  35. }
  36. }
  37. }
  38. // Note: This could check for property attributes in a similar
  39. // way. But since picking arbitrary property attributes via the
  40. // frame buffer is not supported yet, returning "undefined" here
  41. // causes the picking to bail out early and safely when no
  42. // property texture was found.
  43. // See https://github.com/CesiumGS/cesium/issues/12225
  44. return undefined;
  45. }
  46. export default getMetadataProperty;