You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TerrainFactory.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * @Author : Caven Chen
  3. */
  4. import { Cesium } from '../../namespace'
  5. import TerrainType from './TerrainType'
  6. class TerrainFactory {
  7. /**
  8. *
  9. * @param options
  10. * @returns {Promise<EllipsoidTerrainProvider>}
  11. */
  12. static createEllipsoidTerrain(options) {
  13. return Promise.resolve(new Cesium.EllipsoidTerrainProvider(options))
  14. }
  15. /**
  16. * Create url terrain
  17. * @param options
  18. * @returns {Promise<CesiumTerrainProvider>}
  19. */
  20. static createUrlTerrain(options) {
  21. return Cesium.CesiumTerrainProvider.fromUrl(options.url, options)
  22. }
  23. /**
  24. * Create google terrain
  25. * @param options
  26. * @returns {Promise<GoogleEarthEnterpriseTerrainProvider>}
  27. */
  28. static createGoogleTerrain(options) {
  29. return Cesium.GoogleEarthEnterpriseTerrainProvider.fromUrl(
  30. options.url,
  31. options
  32. )
  33. }
  34. /**
  35. * Create arcgis terrain
  36. * @param options
  37. * @returns {Promise<ArcGISTiledElevationTerrainProvider>}
  38. */
  39. static createArcgisTerrain(options) {
  40. return Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
  41. options.url,
  42. options
  43. )
  44. }
  45. /**
  46. * Create vr terrain
  47. * @param options
  48. * @returns {Promise<VRTheWorldTerrainProvider>}
  49. */
  50. static createVRTerrain(options) {
  51. return Cesium.VRTheWorldTerrainProvider.fromUrl(options.url, options)
  52. }
  53. /**
  54. * Create Terrain
  55. * @param type
  56. * @param options
  57. * @returns {any}
  58. */
  59. static createTerrain(type, options) {
  60. let promise = undefined
  61. switch (type) {
  62. case TerrainType.NONE:
  63. promise = this.createEllipsoidTerrain(options)
  64. break
  65. case TerrainType.XYZ:
  66. promise = this.createUrlTerrain(options)
  67. break
  68. case TerrainType.GOOGLE:
  69. promise = this.createGoogleTerrain(options)
  70. break
  71. case TerrainType.ARCGIS:
  72. promise = this.createArcgisTerrain(options)
  73. break
  74. case TerrainType.VR:
  75. promise = this.createVRTerrain(options)
  76. break
  77. default:
  78. break
  79. }
  80. return promise
  81. }
  82. }
  83. export default TerrainFactory