Source: ogc/ows/OwsConstraint.js

  1. /*
  2. * Copyright 2003-2006, 2009, 2017, 2020 United States Government, as represented
  3. * by the Administrator of the National Aeronautics and Space Administration.
  4. * All rights reserved.
  5. *
  6. * The NASAWorldWind/WebWorldWind platform is licensed under the Apache License,
  7. * Version 2.0 (the "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License
  9. * at http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software distributed
  12. * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. * CONDITIONS OF ANY KIND, either express or implied. See the License for the
  14. * specific language governing permissions and limitations under the License.
  15. *
  16. * NASAWorldWind/WebWorldWind also contains the following 3rd party Open Source
  17. * software:
  18. *
  19. * ES6-Promise – under MIT License
  20. * libtess.js – SGI Free Software License B
  21. * Proj4 – under MIT License
  22. * JSZip – under MIT License
  23. *
  24. * A complete listing of 3rd Party software notices and licenses included in
  25. * WebWorldWind can be found in the WebWorldWind 3rd-party notices and licenses
  26. * PDF found in code directory.
  27. */
  28. /**
  29. * @exports OwsConstraint
  30. */
  31. define([
  32. '../../error/ArgumentError',
  33. '../../util/Logger'
  34. ],
  35. function (ArgumentError,
  36. Logger) {
  37. "use strict";
  38. /**
  39. * Constructs an OWS Constraint instance from an XML DOM.
  40. * @alias OwsConstraint
  41. * @constructor
  42. * @classdesc Represents an OWS Constraint element of an OGC capabilities document.
  43. * This object holds as properties all the fields specified in the OWS Constraint definition.
  44. * Fields can be accessed as properties named according to their document names converted to camel case.
  45. * For example, "operation".
  46. * @param {Element} element An XML DOM element representing the OWS Constraint element.
  47. * @throws {ArgumentError} If the specified XML DOM element is null or undefined.
  48. */
  49. var OwsConstraint = function (element) {
  50. if (!element) {
  51. throw new ArgumentError(
  52. Logger.logMessage(Logger.LEVEL_SEVERE, "OwsConstraint", "constructor", "missingDomElement"));
  53. }
  54. this.name = element.getAttribute("name");
  55. var children = element.children || element.childNodes;
  56. for (var c = 0; c < children.length; c++) {
  57. var child = children[c];
  58. if (child.localName === "AllowedValues") {
  59. this.allowedValues = this.allowedValues || [];
  60. var childrenValues = child.children || child.childNodes;
  61. for (var cc = 0; cc < childrenValues.length; cc++) {
  62. if (childrenValues[cc].localName === "Value") {
  63. this.allowedValues.push(childrenValues[cc].textContent);
  64. }
  65. }
  66. } else if (child.localName === "AnyValue") {
  67. this.anyValue = true;
  68. } else if (child.localName === "NoValues") {
  69. this.noValues = true;
  70. }
  71. // TODO: ValuesReference
  72. }
  73. };
  74. return OwsConstraint;
  75. });