04_terrainCurvatureCalculationService.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_terrainCurvatureCalculation"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. <script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  11. </head>
  12. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  13. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, terrainCurvatureCalculationService, terrainCurvatureCalculationParameters,
  17. terrainCurvatureCalculationResult,
  18. themeService, themeGridRange, themeParameters, themeLayer,
  19. baseUrl = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图/zxyTileImage.png?z={z}&x={x}&y={y}",
  20. dataUrl = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图",
  21. serviceUrl = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst",
  22. attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  23. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  24. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
  25. map = new mapboxgl.Map({
  26. container: 'map',
  27. style: {
  28. "version": 8,
  29. "sources": {
  30. "raster-tiles": {
  31. "attribution": attribution,
  32. "type": "raster",
  33. "tiles": [baseUrl],
  34. "tileSize": 256
  35. }
  36. },
  37. "layers": [{
  38. "id": "simple-tiles",
  39. "type": "raster",
  40. "source": "raster-tiles",
  41. }]
  42. },
  43. center: [116.85, 39.79],
  44. zoom: 7
  45. });
  46. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  47. map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
  48. map.on("load", function () {
  49. terrainCurvatureCalculationProcess();
  50. });
  51. function terrainCurvatureCalculationProcess() {
  52. //创建地形曲率计算服务实例
  53. terrainCurvatureCalculationService = new mapboxgl.supermap.SpatialAnalystService(serviceUrl);
  54. //创建地形曲率计算参数实例
  55. terrainCurvatureCalculationParameters = new SuperMap.TerrainCurvatureCalculationParameters({
  56. dataset: "JingjinTerrain@Jingjin",
  57. zFactor: 1.0,
  58. averageCurvatureName: "CurvatureA",
  59. deleteExistResultDataset: true
  60. });
  61. //向iServer发起地形曲率计算请求
  62. terrainCurvatureCalculationService.terrainCurvatureCalculate(terrainCurvatureCalculationParameters, function (serviceResult) {
  63. terrainCurvatureCalculationResult = serviceResult.result;
  64. //用栅格专题图展示分析结果
  65. showAnalysisResult_ThemeGridRange();
  66. });
  67. }
  68. function showAnalysisResult_ThemeGridRange() {
  69. themeService = new mapboxgl.supermap.ThemeService(dataUrl);
  70. var themeGridRangeIteme1 = new SuperMap.ThemeGridRangeItem({
  71. start: -9000000,
  72. end: -1000,
  73. color: new SuperMap.ServerColor(0, 0, 255)
  74. }),
  75. themeGridRangeIteme2 = new SuperMap.ThemeGridRangeItem({
  76. start: -1000,
  77. end: -1,
  78. color: new SuperMap.ServerColor(0, 0, 125)
  79. }),
  80. themeGridRangeIteme3 = new SuperMap.ThemeGridRangeItem({
  81. start: -1,
  82. end: 1,
  83. color: new SuperMap.ServerColor(0, 125, 125)
  84. }),
  85. themeGridRangeIteme4 = new SuperMap.ThemeGridRangeItem({
  86. start: 1,
  87. end: 1000,
  88. color: new SuperMap.ServerColor(0, 125, 0)
  89. }),
  90. themeGridRangeIteme5 = new SuperMap.ThemeGridRangeItem({
  91. start: 1000,
  92. end: 20000000,
  93. color: new SuperMap.ServerColor(0, 255, 0)
  94. });
  95. themeGridRange = new SuperMap.ThemeGridRange({
  96. reverseColor: false,
  97. rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
  98. //栅格分段专题图子项数组
  99. items: [themeGridRangeIteme1,
  100. themeGridRangeIteme2,
  101. themeGridRangeIteme3,
  102. themeGridRangeIteme4,
  103. themeGridRangeIteme5
  104. ]
  105. });
  106. themeParameters = new SuperMap.ThemeParameters({
  107. //制作专题图的数据集(地形曲率计算的结果数据集)
  108. datasetNames: [terrainCurvatureCalculationResult.averageCurvatureResult.dataset.split('@')[0]],
  109. dataSourceNames: ["Jingjin"],
  110. joinItems: null,
  111. themes: [themeGridRange]
  112. });
  113. themeService.getThemeInfo(themeParameters, function (serviceResult1) {
  114. var result = serviceResult1.result;
  115. if (result && result.newResourceID) {
  116. map.addLayer({
  117. "id": "themeLayer",
  118. "type": "raster",
  119. "source": {
  120. "type": "raster",
  121. "tiles": [baseUrl + "&transparent=true&cacheEnabled=false&layersID=" + result.newResourceID],
  122. "tileSize": 256
  123. },
  124. "minzoom": 0,
  125. "maxzoom": 22
  126. });
  127. }
  128. })
  129. }
  130. </script>
  131. </body>
  132. </html>