04_interpolationAnalystService_Density.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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_interpolationAnalystByDen"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. <script type="text/javascript" src="../../dist/ol/include-ol.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="width: 100%;height:100%"></div>
  14. <script type="text/javascript">
  15. var map, options, interpolationAnalystResult,
  16. baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/map-temperature/rest/maps/全国温度变化图",
  17. serviceUrl = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
  18. var extent = [-2640403.63, 1873792.1, 3247669.39, 5921501.4];
  19. var projection = new ol.proj.Projection({
  20. code:'',
  21. extent: extent,
  22. units: 'm'
  23. });
  24. new ol.supermap.MapService(baseUrl).getMapInfo(function (serviceResult) {
  25. var mapJSONObj = serviceResult.result;
  26. map = new ol.Map({
  27. target: 'map',
  28. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  29. .extend([new ol.supermap.control.Logo()]),
  30. view: new ol.View({
  31. center: [531762, 3580330],
  32. zoom: 1,
  33. projection: projection,
  34. multiWorld: true
  35. })
  36. });
  37. options = ol.source.TileSuperMapRest.optionsFromMapJSON(baseUrl, mapJSONObj);
  38. options.layersID = "[0,1,2]";
  39. var layer = new ol.layer.Tile({
  40. source: new ol.source.TileSuperMapRest(options)
  41. });
  42. map.addLayer(layer);
  43. interpolationAnalystProcess();
  44. });
  45. function interpolationAnalystProcess() {
  46. //创建点密度插值分析参数实例
  47. var interpolationAnalystParameters = new SuperMap.InterpolationDensityAnalystParameters({
  48. //用于做插值分析的数据源中数据集的名称
  49. dataset: "SamplesP@Interpolation",
  50. //插值分析结果数据集的名称
  51. outputDatasetName: "Density_Result",
  52. //插值分析结果数据源的名称
  53. outputDatasourceName: "Interpolation",
  54. //结果栅格数据集存储的像素格式
  55. pixelFormat: SuperMap.PixelFormat.DOUBLE,
  56. //插值结果栅格数据集的分辨率
  57. resolution: 9000,
  58. // 存储用于进行插值分析的字段名称
  59. zValueFieldName: "AVG_TMP",
  60. //结果栅格数据集的范围(生效)
  61. bounds: [-2640403.63, 1873792.1, 3247669.39, 5921501.4]
  62. });
  63. new ol.supermap.SpatialAnalystService(serviceUrl).interpolationAnalysis(interpolationAnalystParameters, function (serviceResult) {
  64. interpolationAnalystResult = serviceResult.result;
  65. //用栅格专题图展示分析结果
  66. showAnalysisResult_ThemeGridRange();
  67. });
  68. //构造栅格专题图
  69. function showAnalysisResult_ThemeGridRange() {
  70. var color1 = new SuperMap.ServerColor(170, 240, 233),
  71. color2 = new SuperMap.ServerColor(176, 244, 188),
  72. color3 = new SuperMap.ServerColor(218, 251, 178),
  73. color4 = new SuperMap.ServerColor(220, 236, 145),
  74. color5 = new SuperMap.ServerColor(96, 198, 66),
  75. color6 = new SuperMap.ServerColor(20, 142, 53),
  76. color7 = new SuperMap.ServerColor(85, 144, 55),
  77. color8 = new SuperMap.ServerColor(171, 168, 38),
  78. color9 = new SuperMap.ServerColor(235, 165, 9),
  79. color10 = new SuperMap.ServerColor(203, 89, 2),
  80. color11 = new SuperMap.ServerColor(157, 25, 1),
  81. color12 = new SuperMap.ServerColor(118, 15, 3),
  82. color13 = new SuperMap.ServerColor(112, 32, 7),
  83. color14 = new SuperMap.ServerColor(106, 45, 12),
  84. color15 = new SuperMap.ServerColor(129, 80, 50),
  85. color16 = new SuperMap.ServerColor(160, 154, 146),
  86. color17 = new SuperMap.ServerColor(107, 47, 14),
  87. color18 = new SuperMap.ServerColor(125, 75, 44),
  88. color19 = new SuperMap.ServerColor(146, 110, 88),
  89. color20 = new SuperMap.ServerColor(166, 153, 146);
  90. var themeGridRangeItem1 = new SuperMap.ThemeGridRangeItem({
  91. start: -5,
  92. end: -3.4,
  93. color: color1
  94. }),
  95. themeGridRangeItem2 = new SuperMap.ThemeGridRangeItem({
  96. start: -3.4,
  97. end: -1.8,
  98. color: color2
  99. }),
  100. themeGridRangeItem3 = new SuperMap.ThemeGridRangeItem({
  101. start: -1.8,
  102. end: -0.2,
  103. color: color3
  104. }),
  105. themeGridRangeItem4 = new SuperMap.ThemeGridRangeItem({
  106. start: -0.2,
  107. end: 1.4,
  108. color: color4
  109. }),
  110. themeGridRangeItem5 = new SuperMap.ThemeGridRangeItem({
  111. start: 1.4,
  112. end: 3,
  113. color: color5
  114. }),
  115. themeGridRangeItem6 = new SuperMap.ThemeGridRangeItem({
  116. start: 3,
  117. end: 4.6,
  118. color: color6
  119. }),
  120. themeGridRangeItem7 = new SuperMap.ThemeGridRangeItem({
  121. start: 4.6,
  122. end: 6.2,
  123. color: color7
  124. }),
  125. themeGridRangeItem8 = new SuperMap.ThemeGridRangeItem({
  126. start: 6.2,
  127. end: 7.8,
  128. color: color8
  129. }),
  130. themeGridRangeItem9 = new SuperMap.ThemeGridRangeItem({
  131. start: 7.8,
  132. end: 9.4,
  133. color: color9
  134. }),
  135. themeGridRangeItem10 = new SuperMap.ThemeGridRangeItem({
  136. start: 9.4,
  137. end: 11,
  138. color: color10
  139. }),
  140. themeGridRangeItem11 = new SuperMap.ThemeGridRangeItem({
  141. start: 11,
  142. end: 12.6,
  143. color: color11
  144. }),
  145. themeGridRangeItem12 = new SuperMap.ThemeGridRangeItem({
  146. start: 12.6,
  147. end: 14.2,
  148. color: color12
  149. }),
  150. themeGridRangeItem13 = new SuperMap.ThemeGridRangeItem({
  151. start: 14.2,
  152. end: 35.8,
  153. color: color13
  154. }),
  155. themeGridRangeItem14 = new SuperMap.ThemeGridRangeItem({
  156. start: 35.8,
  157. end: 57.4,
  158. color: color14
  159. }),
  160. themeGridRangeItem15 = new SuperMap.ThemeGridRangeItem({
  161. start: 57.4,
  162. end: 79,
  163. color: color15
  164. }),
  165. themeGridRangeItem16 = new SuperMap.ThemeGridRangeItem({
  166. start: 79,
  167. end: 90.6,
  168. color: color16
  169. }),
  170. themeGridRangeItem17 = new SuperMap.ThemeGridRangeItem({
  171. start: 90.6,
  172. end: 112.2,
  173. color: color17
  174. }),
  175. themeGridRangeItem18 = new SuperMap.ThemeGridRangeItem({
  176. start: 112.2,
  177. end: 123.8,
  178. color: color18
  179. }),
  180. themeGridRangeItem19 = new SuperMap.ThemeGridRangeItem({
  181. start: 123.8,
  182. end: 125.4,
  183. color: color19
  184. }),
  185. themeGridRangeItem20 = new SuperMap.ThemeGridRangeItem({
  186. start: 125.4,
  187. end: 135,
  188. color: color20
  189. });
  190. var themeGridRange = new SuperMap.ThemeGridRange({
  191. reverseColor: false,
  192. rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
  193. //栅格分段专题图子项数组
  194. items: [themeGridRangeItem1, themeGridRangeItem2,
  195. themeGridRangeItem3, themeGridRangeItem4,
  196. themeGridRangeItem5, themeGridRangeItem6,
  197. themeGridRangeItem7, themeGridRangeItem8,
  198. themeGridRangeItem9, themeGridRangeItem10,
  199. themeGridRangeItem11, themeGridRangeItem12,
  200. themeGridRangeItem13, themeGridRangeItem14,
  201. themeGridRangeItem15, themeGridRangeItem16,
  202. themeGridRangeItem17, themeGridRangeItem18,
  203. themeGridRangeItem19, themeGridRangeItem20
  204. ]
  205. });
  206. var themeParameters = new SuperMap.ThemeParameters({
  207. //制作专题图的数据集
  208. datasetNames: [interpolationAnalystResult.dataset.split('@')[0]],
  209. dataSourceNames: ["Interpolation"],
  210. joinItems: null,
  211. themes: [themeGridRange]
  212. });
  213. new ol.supermap.ThemeService(baseUrl).getThemeInfo(themeParameters, function (serviceResult) {
  214. var result = serviceResult.result;
  215. if (result && result.newResourceID) {
  216. var themeLayer = new ol.layer.Tile({
  217. source: new ol.source.TileSuperMapRest({
  218. url: baseUrl,
  219. noWrap: true,
  220. cacheEnabled: false,
  221. layersID: result.newResourceID,
  222. tileGrid: new ol.tilegrid.TileGrid({
  223. extent: extent,
  224. resolutions: options.tileGrid.getResolutions()
  225. }),
  226. transparent: true
  227. })
  228. });
  229. map.addLayer(themeLayer);
  230. }
  231. });
  232. }
  233. }
  234. </script>
  235. </body>
  236. </html>