Source: formats/geotiff/GeoTiffMetadata.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 GeoTiffMetadata
  30. */
  31. define([
  32. ],
  33. function () {
  34. "use strict";
  35. /**
  36. * Provides GeoTIFF metadata.
  37. * @alias GeoTiffMetadata
  38. * @constructor
  39. * @classdesc Contains all of the TIFF and GeoTIFF metadata for a geotiff file.
  40. */
  41. var GeoTiffMetadata = function () {
  42. // Documented in defineProperties below.
  43. this._bitsPerSample = null;
  44. // Documented in defineProperties below.
  45. this._colorMap = null;
  46. // Documented in defineProperties below.
  47. this._compression = null;
  48. // Documented in defineProperties below.
  49. this._extraSamples = null;
  50. // Documented in defineProperties below.
  51. this._imageDescription = null;
  52. // Documented in defineProperties below.
  53. this._imageLength = null;
  54. // Documented in defineProperties below.
  55. this._imageWidth = null;
  56. // Documented in defineProperties below.
  57. this._maxSampleValue = null;
  58. // Documented in defineProperties below.
  59. this._minSampleValue = null;
  60. // Documented in defineProperties below.
  61. this._orientation = 0;
  62. // Documented in defineProperties below.
  63. this._photometricInterpretation = null;
  64. // Documented in defineProperties below.
  65. this._planarConfiguration = null;
  66. // Documented in defineProperties below.
  67. this._resolutionUnit = null;
  68. // Documented in defineProperties below.
  69. this._rowsPerStrip = null;
  70. // Documented in defineProperties below.
  71. this._samplesPerPixel = null;
  72. // Documented in defineProperties below.
  73. this._sampleFormat = null;
  74. // Documented in defineProperties below.
  75. this._software = null;
  76. // Documented in defineProperties below.
  77. this._stripByteCounts = null;
  78. // Documented in defineProperties below.
  79. this._stripOffsets = null;
  80. // Documented in defineProperties below.
  81. this._tileByteCounts = null;
  82. // Documented in defineProperties below.
  83. this._tileOffsets = null;
  84. // Documented in defineProperties below.
  85. this._tileLength = null;
  86. // Documented in defineProperties below.
  87. this._tileWidth = null;
  88. // Documented in defineProperties below.
  89. this._xResolution = null;
  90. // Documented in defineProperties below.
  91. this._yResolution = null;
  92. // Documented in defineProperties below.
  93. this._geoAsciiParams = null;
  94. // Documented in defineProperties below.
  95. this._geoDoubleParams = null;
  96. // Documented in defineProperties below.
  97. this._geoKeyDirectory = null;
  98. // Documented in defineProperties below.
  99. this._modelPixelScale = null;
  100. // Documented in defineProperties below.
  101. this._modelTiepoint = null;
  102. // Documented in defineProperties below.
  103. this._modelTransformation = null;
  104. // Documented in defineProperties below.
  105. this._noData = null;
  106. // Documented in defineProperties below.
  107. this._metaData = null;
  108. // Documented in defineProperties below.
  109. this._bbox = null;
  110. // Documented in defineProperties below.
  111. this._gtModelTypeGeoKey = null;
  112. // Documented in defineProperties below.
  113. this._gtRasterTypeGeoKey = null;
  114. // Documented in defineProperties below.
  115. this._gtCitationGeoKey = null;
  116. // Documented in defineProperties below.
  117. this._geographicTypeGeoKey = null;
  118. // Documented in defineProperties below.
  119. this._geogCitationGeoKey = null;
  120. // Documented in defineProperties below.
  121. this._geogAngularUnitsGeoKey = null;
  122. // Documented in defineProperties below.
  123. this._geogAngularUnitSizeGeoKey = null;
  124. // Documented in defineProperties below.
  125. this._geogSemiMajorAxisGeoKey = null;
  126. // Documented in defineProperties below.
  127. this._geogInvFlatteningGeoKey = null;
  128. // Documented in defineProperties below.
  129. this._projectedCSType = null;
  130. // Documented in defineProperties below.
  131. this._projLinearUnits = null;
  132. };
  133. Object.defineProperties(GeoTiffMetadata.prototype, {
  134. /**
  135. * Contains the number of bits per component.
  136. * @memberof GeoTiffMetadata.prototype
  137. * @type {Number[]}
  138. */
  139. bitsPerSample: {
  140. get: function () {
  141. return this._bitsPerSample;
  142. },
  143. set: function(value){
  144. this._bitsPerSample = value;
  145. }
  146. },
  147. /**
  148. * Defines a Red-Green-Blue color map (often called a lookup table) for palette color images.
  149. * In a palette-color image, a pixel value is used to index into an RGB-lookup table.
  150. * @memberof GeoTiffMetadata.prototype
  151. * @type {Number[]}
  152. */
  153. colorMap: {
  154. get: function () {
  155. return this._colorMap;
  156. },
  157. set: function(value){
  158. this._colorMap = value;
  159. }
  160. },
  161. /**
  162. * Contains the compression type of geotiff data.
  163. * @memberof GeoTiffMetadata.prototype
  164. * @type {Number}
  165. */
  166. compression: {
  167. get: function () {
  168. return this._compression;
  169. },
  170. set: function(value){
  171. this._compression = value;
  172. }
  173. },
  174. /**
  175. * Contains the description of extra components.
  176. * @memberof GeoTiffMetadata.prototype
  177. * @type {Number[]}
  178. */
  179. extraSamples: {
  180. get: function () {
  181. return this._extraSamples;
  182. },
  183. set: function(value){
  184. this._extraSamples = value;
  185. }
  186. },
  187. /**
  188. * Contains the image description.
  189. * @memberof GeoTiffMetadata.prototype
  190. * @type {String}
  191. */
  192. imageDescription: {
  193. get: function () {
  194. return this._imageDescription;
  195. },
  196. set: function(value){
  197. this._imageDescription = value;
  198. }
  199. },
  200. /**
  201. * Contains the number of rows in the image.
  202. * @memberof GeoTiffMetadata.prototype
  203. * @type {Number}
  204. */
  205. imageLength: {
  206. get: function () {
  207. return this._imageLength;
  208. },
  209. set: function(value){
  210. this._imageLength = value;
  211. }
  212. },
  213. /**
  214. * Contains the number of columns in the image.
  215. * @memberof GeoTiffMetadata.prototype
  216. * @type {Number}
  217. */
  218. imageWidth: {
  219. get: function () {
  220. return this._imageWidth;
  221. },
  222. set: function(value){
  223. this._imageWidth = value;
  224. }
  225. },
  226. /**
  227. * Contains the maximum component value used.
  228. * @memberof GeoTiffMetadata.prototype
  229. * @type {Number}
  230. */
  231. maxSampleValue: {
  232. get: function () {
  233. return this._maxSampleValue;
  234. },
  235. set: function(value){
  236. this._maxSampleValue = value;
  237. }
  238. },
  239. /**
  240. * Contains the minimum component value used.
  241. * @memberof GeoTiffMetadata.prototype
  242. * @type {Number}
  243. */
  244. minSampleValue: {
  245. get: function () {
  246. return this._minSampleValue;
  247. },
  248. set: function(value){
  249. this._minSampleValue = value;
  250. }
  251. },
  252. /**
  253. * Contains the orientation of the image with respect to the rows and columns.
  254. * @memberof GeoTiffMetadata.prototype
  255. * @type {Number}
  256. */
  257. orientation: {
  258. get: function () {
  259. return this._orientation;
  260. },
  261. set: function(value){
  262. this._orientation = value;
  263. }
  264. },
  265. /**
  266. * Contains the photometric interpretation type of the geotiff file.
  267. * @memberof GeoTiffMetadata.prototype
  268. * @type {Number}
  269. */
  270. photometricInterpretation: {
  271. get: function () {
  272. return this._photometricInterpretation;
  273. },
  274. set: function(value){
  275. this._photometricInterpretation = value;
  276. }
  277. },
  278. /**
  279. * Contains the planar configuration type of the geotiff file.
  280. * @memberof GeoTiffMetadata.prototype
  281. * @type {Number}
  282. */
  283. planarConfiguration: {
  284. get: function () {
  285. return this._planarConfiguration;
  286. },
  287. set: function(value){
  288. this._planarConfiguration = value;
  289. }
  290. },
  291. /**
  292. * Contains the unit of measurement for XResolution and YResolution. The specified values are:
  293. * <ul>
  294. * <li>1 = No absolute unit of measurement</li>
  295. * <li>2 = Inch</li>
  296. * <li>3 = Centimeter</li>
  297. * </ul>
  298. * @memberof GeoTiffMetadata.prototype
  299. * @type {Number}
  300. */
  301. resolutionUnit: {
  302. get: function () {
  303. return this._resolutionUnit;
  304. },
  305. set: function(value){
  306. this._resolutionUnit = value;
  307. }
  308. },
  309. /**
  310. * Contains the number of rows per strip.
  311. * @memberof GeoTiffMetadata.prototype
  312. * @type {Number}
  313. */
  314. rowsPerStrip: {
  315. get: function () {
  316. return this._rowsPerStrip;
  317. },
  318. set: function(value){
  319. this._rowsPerStrip = value;
  320. }
  321. },
  322. /**
  323. * Contains the number of components per pixel.
  324. * @memberof GeoTiffMetadata.prototype
  325. * @type {Number}
  326. */
  327. samplesPerPixel: {
  328. get: function () {
  329. return this._samplesPerPixel;
  330. },
  331. set: function(value){
  332. this._samplesPerPixel = value;
  333. }
  334. },
  335. /**
  336. * This field specifies how to interpret each data sample in a pixel. Possible values are:
  337. * <ul>
  338. * <li>unsigned integer data</li>
  339. * <li>two's complement signed integer data</li>
  340. * <li>IEEE floating point data</li>
  341. * <li>undefined data format</li>
  342. * </ul>
  343. * @memberof GeoTiffMetadata.prototype
  344. * @type {Number}
  345. */
  346. sampleFormat: {
  347. get: function () {
  348. return this._sampleFormat;
  349. },
  350. set: function(value){
  351. this._sampleFormat = value;
  352. }
  353. },
  354. software: {
  355. get: function () {
  356. return this._software;
  357. },
  358. set: function(value){
  359. this._software = value;
  360. }
  361. },
  362. /**
  363. * Contains the number of bytes in that strip after any compression, for each strip.
  364. * @memberof GeoTiffMetadata.prototype
  365. * @type {Number[]}
  366. */
  367. stripByteCounts: {
  368. get: function () {
  369. return this._stripByteCounts;
  370. },
  371. set: function(value){
  372. this._stripByteCounts = value;
  373. }
  374. },
  375. /**
  376. * Contains the byte offset of that strip, for each strip.
  377. * @memberof GeoTiffMetadata.prototype
  378. * @type {Number[]}
  379. */
  380. stripOffsets: {
  381. get: function () {
  382. return this._stripOffsets;
  383. },
  384. set: function(value){
  385. this._stripOffsets = value;
  386. }
  387. },
  388. tileByteCounts: {
  389. get: function () {
  390. return this._tileByteCounts;
  391. },
  392. set: function(value){
  393. this._tileByteCounts = value;
  394. }
  395. },
  396. /**
  397. * Contains the byte offset of that tile, for each tile.
  398. * @memberof GeoTiffMetadata.prototype
  399. * @type {Number[]}
  400. */
  401. tileOffsets: {
  402. get: function () {
  403. return this._tileOffsets;
  404. },
  405. set: function(value){
  406. this._tileOffsets = value;
  407. }
  408. },
  409. tileLength: {
  410. get: function () {
  411. return this._tileLength;
  412. },
  413. set: function(value){
  414. this._tileLength = value;
  415. }
  416. },
  417. tileWidth: {
  418. get: function () {
  419. return this._tileWidth;
  420. },
  421. set: function(value){
  422. this._tileWidth = value;
  423. }
  424. },
  425. //geotiff
  426. /**
  427. * Contains all of the ASCII valued GeoKeys, referenced by the GeoKeyDirectoryTag.
  428. * @memberof GeoTiffMetadata.prototype
  429. * @type {String[]}
  430. */
  431. geoAsciiParams: {
  432. get: function () {
  433. return this._geoAsciiParams;
  434. },
  435. set: function(value){
  436. this._geoAsciiParams = value;
  437. }
  438. },
  439. /**
  440. * Contains all of the DOUBLE valued GeoKeys, referenced by the GeoKeyDirectoryTag.
  441. * @memberof GeoTiffMetadata.prototype
  442. * @type {Nmber[]}
  443. */
  444. geoDoubleParams: {
  445. get: function () {
  446. return this._geoDoubleParams;
  447. },
  448. set: function(value){
  449. this._geoDoubleParams = value;
  450. }
  451. },
  452. /**
  453. * Contains the values of GeoKeyDirectoryTag.
  454. * @memberof GeoTiffMetadata.prototype
  455. * @type {Nmber[]}
  456. */
  457. geoKeyDirectory: {
  458. get: function () {
  459. return this._geoKeyDirectory;
  460. },
  461. set: function(value){
  462. this._geoKeyDirectory = value;
  463. }
  464. },
  465. /**
  466. * Contains the values of ModelPixelScaleTag. The ModelPixelScaleTag tag may be used to specify the size
  467. * of raster pixel spacing in the model space units, when the raster space can be embedded in the model
  468. * space coordinate system without rotation
  469. * @memberof GeoTiffMetadata.prototype
  470. * @type {Nmber[]}
  471. */
  472. modelPixelScale: {
  473. get: function () {
  474. return this._modelPixelScale;
  475. },
  476. set: function(value){
  477. this._modelPixelScale = value;
  478. }
  479. },
  480. /**
  481. * Stores raster->model tiepoint pairs in the order ModelTiepointTag = (...,I,J,K, X,Y,Z...),
  482. * where (I,J,K) is the point at location (I,J) in raster space with pixel-value K,
  483. * and (X,Y,Z) is a vector in model space.
  484. * @memberof GeoTiffMetadata.prototype
  485. * @type {Nmber[]}
  486. */
  487. modelTiepoint: {
  488. get: function () {
  489. return this._modelTiepoint;
  490. },
  491. set: function(value){
  492. this._modelTiepoint = value;
  493. }
  494. },
  495. /**
  496. * Contains the information that may be used to specify the transformation matrix between the raster space
  497. * (and its dependent pixel-value space) and the model space.
  498. * @memberof GeoTiffMetadata.prototype
  499. * @type {Nmber[]}
  500. */
  501. modelTransformation: {
  502. get: function () {
  503. return this._modelTransformation;
  504. },
  505. set: function(value){
  506. this._modelTransformation = value;
  507. }
  508. },
  509. /**
  510. * Contains the NODATA value.
  511. * @memberof GeoTiffMetadata.prototype
  512. * @type {String}
  513. */
  514. noData: {
  515. get: function () {
  516. return this._noData;
  517. },
  518. set: function(value){
  519. this._noData = value;
  520. }
  521. },
  522. /**
  523. * Contains the METADATA value.
  524. * @memberof GeoTiffMetadata.prototype
  525. * @type {String}
  526. */
  527. metaData: {
  528. get: function () {
  529. return this._metaData;
  530. },
  531. set: function(value){
  532. this._metaData = value;
  533. }
  534. },
  535. /**
  536. * Contains the extent of the geotiff.
  537. * @memberof GeoTiffMetadata.prototype
  538. * @type {Sector}
  539. */
  540. bbox: {
  541. get: function () {
  542. return this._bbox;
  543. },
  544. set: function(value){
  545. this._bbox = value;
  546. }
  547. },
  548. //geokeys
  549. /**
  550. * Contains an ID defining the crs model.
  551. * @memberof GeoTiffMetadata.prototype
  552. * @type {Number}
  553. */
  554. gtModelTypeGeoKey: {
  555. get: function () {
  556. return this._gtModelTypeGeoKey;
  557. },
  558. set: function(value){
  559. this._gtModelTypeGeoKey = value;
  560. }
  561. },
  562. /**
  563. * Contains an ID defining the raster sample type.
  564. * @memberof GeoTiffMetadata.prototype
  565. * @type {Number}
  566. */
  567. gtRasterTypeGeoKey: {
  568. get: function () {
  569. return this._gtRasterTypeGeoKey;
  570. },
  571. set: function(value){
  572. this._gtRasterTypeGeoKey = value;
  573. }
  574. },
  575. /**
  576. * Contains an ASCII reference to the overall configuration of the geotiff file.
  577. * @memberof GeoTiffMetadata.prototype
  578. * @type {String}
  579. */
  580. gtCitationGeoKey: {
  581. get: function () {
  582. return this._gtCitationGeoKey;
  583. },
  584. set: function(value){
  585. this._gtCitationGeoKey = value;
  586. }
  587. },
  588. /**
  589. * Contains a value to specify the code for geographic coordinate system used to map lat-long to a specific
  590. * ellipsoid over the earth
  591. * @memberof GeoTiffMetadata.prototype
  592. * @type {Number}
  593. */
  594. geographicTypeGeoKey: {
  595. get: function () {
  596. return this._geographicTypeGeoKey;
  597. },
  598. set: function(value){
  599. this._geographicTypeGeoKey = value;
  600. }
  601. },
  602. /**
  603. * Contains a value to specify the code for geographic coordinate system used to map lat-long to a specific
  604. * ellipsoid over the earth
  605. * @memberof GeoTiffMetadata.prototype
  606. * @type {String}
  607. */
  608. geogCitationGeoKey: {
  609. get: function () {
  610. return this._geogCitationGeoKey;
  611. },
  612. set: function(value){
  613. this._geogCitationGeoKey = value;
  614. }
  615. },
  616. /**
  617. * Allows the definition of geocentric CS Linear units for used-defined GCS and for ellipsoids
  618. * @memberof GeoTiffMetadata.prototype
  619. * @type {Number}
  620. */
  621. geogAngularUnitsGeoKey: {
  622. get: function () {
  623. return this._geogAngularUnitsGeoKey;
  624. },
  625. set: function(value){
  626. this._geogAngularUnitsGeoKey = value;
  627. }
  628. },
  629. /**
  630. * Allows the definition of user-defined angular geographic units, as measured in radians
  631. * @memberof GeoTiffMetadata.prototype
  632. * @type {Number}
  633. */
  634. geogAngularUnitSizeGeoKey: {
  635. get: function () {
  636. return this._geogAngularUnitSizeGeoKey;
  637. },
  638. set: function(value){
  639. this._geogAngularUnitSizeGeoKey = value;
  640. }
  641. },
  642. /**
  643. * Allows the specification of user-defined Ellipsoidal Semi-Major Axis
  644. * @memberof GeoTiffMetadata.prototype
  645. * @type {Number}
  646. */
  647. geogSemiMajorAxisGeoKey: {
  648. get: function () {
  649. return this._geogSemiMajorAxisGeoKey;
  650. },
  651. set: function(value){
  652. this._geogSemiMajorAxisGeoKey = value;
  653. }
  654. },
  655. /**
  656. * Allows the specification of the inverse of user-defined Ellipsoid's flattening parameter f.
  657. * @memberof GeoTiffMetadata.prototype
  658. * @type {Number}
  659. */
  660. geogInvFlatteningGeoKey: {
  661. get: function () {
  662. return this._geogInvFlatteningGeoKey;
  663. },
  664. set: function(value){
  665. this._geogInvFlatteningGeoKey = value;
  666. }
  667. },
  668. /**
  669. * Contains the EPSG code of the geotiff.
  670. * @memberof GeoTiffMetadata.prototype
  671. * @type {Number}
  672. */
  673. projectedCSType: {
  674. get: function () {
  675. return this._projectedCSType;
  676. },
  677. set: function(value){
  678. this._projectedCSType = value;
  679. }
  680. },
  681. /**
  682. * Contains the linear units of the geotiff.
  683. * @memberof GeoTiffMetadata.prototype
  684. * @type {Number}
  685. */
  686. projLinearUnits: {
  687. get: function () {
  688. return this._projLinearUnits;
  689. },
  690. set: function(value){
  691. this._projLinearUnits = value;
  692. }
  693. },
  694. /**
  695. * Contains the number of pixels per resolution unit in the image width direction.
  696. * @memberof GeoTiffMetadata.prototype
  697. * @type {Number}
  698. */
  699. xResolution: {
  700. get: function () {
  701. return this._xResolution;
  702. },
  703. set: function(value){
  704. this._xResolution = value;
  705. }
  706. },
  707. /**
  708. * Contains the number of pixels per resolution unit in the image length direction.
  709. * @memberof GeoTiffMetadata.prototype
  710. * @type {Number}
  711. */
  712. yResolution: {
  713. get: function () {
  714. return this._yResolution;
  715. },
  716. set: function(value){
  717. this._yResolution = value;
  718. }
  719. }
  720. });
  721. return GeoTiffMetadata;
  722. }
  723. );