Source: formats/geojson/GeoJSONGeometryCollection.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 GeoJSONGeometryCollection
  30. */
  31. define(['../../error/ArgumentError',
  32. './GeoJSONConstants',
  33. '../../util/Logger'
  34. ],
  35. function (ArgumentError,
  36. GeoJSONConstants,
  37. Logger) {
  38. "use strict";
  39. /**
  40. * Constructs a GeoJSON geometry for a GeometryCollection. Applications typically do not call this constructor.
  41. * It is called by {@link GeoJSON} as GeoJSON geometries are read.
  42. * @alias GeoJSONGeometryCollection
  43. * @constructor
  44. * @classdesc Contains the data associated with a GeoJSON GeometryCollection geometry.
  45. * A geometry collection must have a member with the name "geometries".
  46. * The value corresponding to "geometries" is an array. Each element in this array is a GeoJSON
  47. * geometry object. To include information on the coordinate range for features, a GeoJSON object may have a
  48. * member named "bbox".
  49. * @param {Object} geometries An array containing GeoJSONGeometry objects.
  50. * @param {Object} bbox An object containing the value of GeoJSON GeometryCollection bbox member.
  51. * @throws {ArgumentError} If the specified mandatory geometries is null or undefined or if the geometries
  52. * parameter is not an array of GeoJSONGeometry.
  53. */
  54. var GeoJSONGeometryCollection = function (geometries, bbox) {
  55. if (!geometries) {
  56. throw new ArgumentError(
  57. Logger.logMessage(Logger.LEVEL_SEVERE, "GeoJSONGeometryCollection", "constructor",
  58. "missingGeometries"));
  59. }
  60. if (Object.prototype.toString.call(geometries) !== '[object Array]') {
  61. throw new ArgumentError(
  62. Logger.logMessage(Logger.LEVEL_SEVERE, "GeoJSONGeometryCollection", "constructor",
  63. "invalidGeometries"));
  64. }
  65. // Documented in defineProperties below.
  66. this._geometries = geometries;
  67. // Documented in defineProperties below.
  68. this._bbox = bbox;
  69. };
  70. Object.defineProperties(GeoJSONGeometryCollection.prototype, {
  71. /**
  72. * The GeoJSON GeometryCollection geometries as specified to this GeoJSON GeometryCollection's constructor.
  73. * @memberof GeoJSONGeometryCollection.prototype
  74. * @type {Object}
  75. * @readonly
  76. */
  77. geometries: {
  78. get: function () {
  79. return this._geometries;
  80. }
  81. },
  82. /**
  83. * The GeoJSON GeometryCollection bbox member as specified to this GeoJSONGeometryCollection's constructor.
  84. * @memberof GeoJSONGeometryCollection.prototype
  85. * @type {Object}
  86. * @readonly
  87. */
  88. bbox: {
  89. get: function () {
  90. return this._bbox;
  91. }
  92. }
  93. });
  94. return GeoJSONGeometryCollection;
  95. }
  96. );