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

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