04_interpolationAnalystService_IDW_dataset.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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_interpolationAnalystByIDW"></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.InterpolationIDWAnalystParameters({
  48. //用于做插值分析的数据源中数据集的名称
  49. dataset: "SamplesP@Interpolation",
  50. //插值分析结果数据集的名称
  51. outputDatasetName: "IDW_result",
  52. //插值分析结果数据源的名称
  53. outputDatasourceName: "Interpolation",
  54. //结果栅格数据集存储的像素格式
  55. pixelFormat: SuperMap.PixelFormat.DOUBLE,
  56. // 属性过滤条件
  57. // filterQueryParameter: {
  58. // attributeFilter: ""
  59. // },
  60. //存储用于进行插值分析的字段名称
  61. zValueFieldName: "AVG_TMP",
  62. resolution: 7923.84989108,
  63. //采取固定点数查找参与运算点的方式
  64. searchMode: "KDTREE_FIXED_COUNT",
  65. //固定点数查找方式下,参与差值运算的点数默认为12。
  66. expectedCount: 12,
  67. bounds: [-2640403.63, 1873792.1, 3247669.39, 5921501.4]
  68. });
  69. new ol.supermap.SpatialAnalystService(serviceUrl).interpolationAnalysis(interpolationAnalystParameters, function (serviceResult) {
  70. interpolationAnalystResult = serviceResult.result;
  71. //用栅格专题图展示分析结果
  72. showAnalysisResult_ThemeGridRange();
  73. });
  74. //构造栅格专题图
  75. function showAnalysisResult_ThemeGridRange() {
  76. var color1 = new SuperMap.ServerColor(170, 240, 233),
  77. color2 = new SuperMap.ServerColor(176, 244, 188),
  78. color3 = new SuperMap.ServerColor(218, 251, 178),
  79. color4 = new SuperMap.ServerColor(220, 236, 145),
  80. color5 = new SuperMap.ServerColor(96, 198, 66),
  81. color6 = new SuperMap.ServerColor(20, 142, 53),
  82. color7 = new SuperMap.ServerColor(85, 144, 55),
  83. color8 = new SuperMap.ServerColor(171, 168, 38),
  84. color9 = new SuperMap.ServerColor(235, 165, 9),
  85. color10 = new SuperMap.ServerColor(203, 89, 2),
  86. color11 = new SuperMap.ServerColor(157, 25, 1),
  87. color12 = new SuperMap.ServerColor(118, 15, 3),
  88. color13 = new SuperMap.ServerColor(112, 32, 7),
  89. color14 = new SuperMap.ServerColor(106, 45, 12),
  90. color15 = new SuperMap.ServerColor(129, 80, 50),
  91. color16 = new SuperMap.ServerColor(160, 154, 146),
  92. color17 = new SuperMap.ServerColor(107, 47, 14),
  93. color18 = new SuperMap.ServerColor(125, 75, 44),
  94. color19 = new SuperMap.ServerColor(146, 110, 88),
  95. color20 = new SuperMap.ServerColor(166, 153, 146);
  96. var themeGridRangeIteme1 = new SuperMap.ThemeGridRangeItem({
  97. start: -5,
  98. end: -3.4,
  99. color: color1
  100. }),
  101. themeGridRangeIteme2 = new SuperMap.ThemeGridRangeItem({
  102. start: -3.4,
  103. end: -1.8,
  104. color: color2
  105. }),
  106. themeGridRangeIteme3 = new SuperMap.ThemeGridRangeItem({
  107. start: -1.8,
  108. end: -0.2,
  109. color: color3
  110. }),
  111. themeGridRangeIteme4 = new SuperMap.ThemeGridRangeItem({
  112. start: -0.2,
  113. end: 1.4,
  114. color: color4
  115. }),
  116. themeGridRangeIteme5 = new SuperMap.ThemeGridRangeItem({
  117. start: 1.4,
  118. end: 3,
  119. color: color5
  120. }),
  121. themeGridRangeIteme6 = new SuperMap.ThemeGridRangeItem({
  122. start: 3,
  123. end: 4.6,
  124. color: color6
  125. }),
  126. themeGridRangeIteme7 = new SuperMap.ThemeGridRangeItem({
  127. start: 4.6,
  128. end: 6.2,
  129. color: color7
  130. }),
  131. themeGridRangeIteme8 = new SuperMap.ThemeGridRangeItem({
  132. start: 6.2,
  133. end: 7.8,
  134. color: color8
  135. }),
  136. themeGridRangeIteme9 = new SuperMap.ThemeGridRangeItem({
  137. start: 7.8,
  138. end: 9.4,
  139. color: color9
  140. }),
  141. themeGridRangeIteme10 = new SuperMap.ThemeGridRangeItem({
  142. start: 9.4,
  143. end: 11,
  144. color: color10
  145. }),
  146. themeGridRangeIteme11 = new SuperMap.ThemeGridRangeItem({
  147. start: 11,
  148. end: 12.6,
  149. color: color11
  150. }),
  151. themeGridRangeIteme12 = new SuperMap.ThemeGridRangeItem({
  152. start: 12.6,
  153. end: 14.2,
  154. color: color12
  155. }),
  156. themeGridRangeIteme13 = new SuperMap.ThemeGridRangeItem({
  157. start: 14.2,
  158. end: 15.8,
  159. color: color13
  160. }),
  161. themeGridRangeIteme14 = new SuperMap.ThemeGridRangeItem({
  162. start: 15.8,
  163. end: 17.4,
  164. color: color14
  165. }),
  166. themeGridRangeIteme15 = new SuperMap.ThemeGridRangeItem({
  167. start: 17.4,
  168. end: 19,
  169. color: color15
  170. }),
  171. themeGridRangeIteme16 = new SuperMap.ThemeGridRangeItem({
  172. start: 19,
  173. end: 20.6,
  174. color: color16
  175. }),
  176. themeGridRangeIteme17 = new SuperMap.ThemeGridRangeItem({
  177. start: 20.6,
  178. end: 22.2,
  179. color: color17
  180. }),
  181. themeGridRangeIteme18 = new SuperMap.ThemeGridRangeItem({
  182. start: 22.2,
  183. end: 23.8,
  184. color: color18
  185. }),
  186. themeGridRangeIteme19 = new SuperMap.ThemeGridRangeItem({
  187. start: 23.8,
  188. end: 25.4,
  189. color: color19
  190. }),
  191. themeGridRangeIteme20 = new SuperMap.ThemeGridRangeItem({
  192. start: 25.4,
  193. end: 27,
  194. color: color20
  195. });
  196. var themeGridRange = new SuperMap.ThemeGridRange({
  197. reverseColor: false,
  198. rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
  199. //栅格分段专题图子项数组
  200. items: [themeGridRangeIteme1, themeGridRangeIteme2,
  201. themeGridRangeIteme3, themeGridRangeIteme4,
  202. themeGridRangeIteme5, themeGridRangeIteme6,
  203. themeGridRangeIteme7, themeGridRangeIteme8,
  204. themeGridRangeIteme9, themeGridRangeIteme10,
  205. themeGridRangeIteme11, themeGridRangeIteme12,
  206. themeGridRangeIteme13, themeGridRangeIteme14,
  207. themeGridRangeIteme15, themeGridRangeIteme16,
  208. themeGridRangeIteme17, themeGridRangeIteme18,
  209. themeGridRangeIteme19, themeGridRangeIteme20
  210. ]
  211. });
  212. var themeParameters = new SuperMap.ThemeParameters({
  213. //制作专题图的数据集
  214. datasetNames: [interpolationAnalystResult.dataset.split('@')[0]],
  215. dataSourceNames: ["Interpolation"],
  216. joinItems: null,
  217. themes: [themeGridRange]
  218. });
  219. new ol.supermap.ThemeService(baseUrl).getThemeInfo(themeParameters, function (serviceResult) {
  220. var result = serviceResult.result;
  221. if (result && result.newResourceID) {
  222. var themeLayer = new ol.layer.Tile({
  223. source: new ol.source.TileSuperMapRest({
  224. url: baseUrl,
  225. noWrap: true,
  226. cacheEnabled: false,
  227. layersID: result.newResourceID,
  228. tileGrid: new ol.tilegrid.TileGrid({
  229. extent: extent,
  230. resolutions: options.tileGrid.getResolutions()
  231. }),
  232. transparent: true
  233. })
  234. });
  235. map.addLayer(themeLayer);
  236. }
  237. });
  238. }
  239. }
  240. </script>
  241. </body>
  242. </html>