04_interpolationAnalystService_KrigingUniversal.html 11 KB

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