04_interpolationAnalystService_Kriging.html 11 KB

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