04_mathExpressionAnalysisService.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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_mathExpression"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  13. <script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, mathExpressionAnalysisService, mathExpressionAnalysisParameters, mathExpressionAnalysisResult,
  17. themeService, themeGridRange, themeParameters, themeLayer,
  18. baseUrl = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图",
  19. serviceUrl = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
  20. map = L.map('map', {
  21. crs: L.CRS.EPSG4326,
  22. center: [40.05, 116.85],
  23. maxZoom: 18,
  24. zoom: 6
  25. });
  26. L.supermap.tiledMapLayer(baseUrl, {noWrap: true}).addTo(map).once("load ", function () {
  27. mathExpressionAnalysisProcess();
  28. });
  29. function mathExpressionAnalysisProcess() {
  30. //创建栅格代数运算服务实例
  31. mathExpressionAnalysisService = L.supermap.spatialAnalystService(serviceUrl);
  32. //创建栅格代数运算参数实例
  33. mathExpressionAnalysisParameters = new SuperMap.MathExpressionAnalysisParameters({
  34. //指定数据集,必设
  35. dataset: "JingjinTerrain@Jingjin",
  36. //要执行的栅格运算代数表达式,必设
  37. expression: "[Jingjin.JingjinTerrain] + 600",
  38. //存储结果数据集的数据源,必设
  39. targetDatasource: "Jingjin",
  40. //结果数据集名称,必设
  41. resultGridName: "MathExpressionAnalysis_Result",
  42. deleteExistResultDataset: true
  43. /*//指定数据集中参与栅格代数运算的区域
  44. extractRegion: L.polygon([
  45. [38, 116],
  46. [38, 117],
  47. [42, 117],
  48. [42, 116]
  49. ])*/
  50. });
  51. //向iServer发起栅格代数运算请求
  52. mathExpressionAnalysisService.mathExpressionAnalysis(mathExpressionAnalysisParameters, function (serviceResult) {
  53. mathExpressionAnalysisResult = serviceResult.result;
  54. //用栅格专题图展示分析结果
  55. showAnalysisResult_ThemeGridRange();
  56. });
  57. }
  58. function showAnalysisResult_ThemeGridRange() {
  59. themeService = L.supermap.themeService(baseUrl);
  60. var themeGridRangeIteme1 = new SuperMap.ThemeGridRangeItem({
  61. start: 0,
  62. end: 650,
  63. color: new SuperMap.ServerColor(40, 140, 40)
  64. }),
  65. themeGridRangeIteme2 = new SuperMap.ThemeGridRangeItem({
  66. start: 650,
  67. end: 750,
  68. color: new SuperMap.ServerColor(170, 198, 40)
  69. }),
  70. themeGridRangeIteme3 = new SuperMap.ThemeGridRangeItem({
  71. start: 750,
  72. end: 900,
  73. color: new SuperMap.ServerColor(191, 191, 0)
  74. }),
  75. themeGridRangeIteme4 = new SuperMap.ThemeGridRangeItem({
  76. start: 900,
  77. end: 1350,
  78. color: new SuperMap.ServerColor(191, 95, 0)
  79. }),
  80. themeGridRangeIteme5 = new SuperMap.ThemeGridRangeItem({
  81. start: 1350,
  82. end: 3600,
  83. color: new SuperMap.ServerColor(127, 0, 0)
  84. });
  85. themeGridRange = new SuperMap.ThemeGridRange({
  86. reverseColor: false,
  87. rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
  88. //栅格分段专题图子项数组
  89. items: [themeGridRangeIteme1,
  90. themeGridRangeIteme2,
  91. themeGridRangeIteme3,
  92. themeGridRangeIteme4,
  93. themeGridRangeIteme5
  94. ]
  95. });
  96. themeParameters = new SuperMap.ThemeParameters({
  97. //制作专题图的数据集
  98. datasetNames: [mathExpressionAnalysisResult.dataset.split('@')[0]],
  99. dataSourceNames: ["Jingjin"],
  100. joinItems: null,
  101. themes: [themeGridRange]
  102. });
  103. themeService.getThemeInfo(themeParameters, function (serviceResult1) {
  104. var result = serviceResult1.result;
  105. if (result && result.newResourceID) {
  106. themeLayer = L.supermap.tiledMapLayer(baseUrl, {
  107. noWrap: true,
  108. cacheEnabled: false,
  109. transparent: true,
  110. layersID: result.newResourceID,
  111. opacity: 0.8
  112. }).addTo(map);
  113. }
  114. });
  115. }
  116. </script>
  117. </body>
  118. </html>