analysis_surfaceAnalyst.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_surfaceAnalyst"></title>
  9. <style type="text/css">
  10. body {
  11. margin: 0;
  12. overflow: hidden;
  13. background: #fff;
  14. width: 100%;
  15. height: 100%
  16. }
  17. #map {
  18. position: absolute;
  19. width: 100%;
  20. height: 100%;
  21. }
  22. #toolbar {
  23. position: absolute;
  24. top: 50px;
  25. right: 10px;
  26. text-align: center;
  27. z-index: 100;
  28. border-radius: 4px;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div id="toolbar" class="panel panel-primary">
  34. <div class='panel-heading'>
  35. <h5 class='panel-title text-center' data-i18n="resources.text_surfaceAnalyst"></h5></div>
  36. <div class='panel-body content'>
  37. <input type="button" class="btn btn-default" data-i18n="[value]resources.text_contourLine"
  38. onclick="surfaceAnalystProcess()"/>&nbsp; &nbsp;
  39. <input type="button" class="btn btn-default" data-i18n="[value]resources.text_remove" onclick="removeData()"/>
  40. </div>
  41. </div>
  42. <div id="map"></div>
  43. <script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
  44. <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
  45. <script>
  46. var map, local, baseLayer, resultLayer, Spatialanalyst_sample,
  47. points = new SuperMap.Geometry.LinearRing([
  48. new SuperMap.Geometry.Point(0, 4010338),
  49. new SuperMap.Geometry.Point(1063524, 4010338),
  50. new SuperMap.Geometry.Point(1063524, 3150322),
  51. new SuperMap.Geometry.Point(0, 3150322)
  52. ]),
  53. region = new SuperMap.Geometry.Polygon([points]),
  54. host = window.isLocal ? window.server : "https://iserver.supermap.io",
  55. url = host + "/iserver/services/map-temperature/rest/maps/全国温度变化图",
  56. url2 = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
  57. init();
  58. function init() {
  59. map = new SuperMap.Map("map", {
  60. controls: [
  61. new SuperMap.Control.ScaleLine(),
  62. new SuperMap.Control.Zoom(),
  63. new SuperMap.Control.Navigation({
  64. dragPanOptions: {
  65. enableKinetic: true
  66. }
  67. })], units: "m"
  68. });
  69. map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
  70. map.allOverlays = true;
  71. baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("全国温度变化图", url, {
  72. transparent: true,
  73. cacheEnabled: true
  74. }, {maxResolution: "auto"});
  75. baseLayer.events.on({"layerInitialized": addLayer});
  76. resultLayer = new SuperMap.Layer.Vector("等值线");
  77. }
  78. function addLayer() {
  79. map.addLayers([baseLayer, resultLayer]);
  80. map.setCenter(new SuperMap.LonLat(531762, 3580330), 2);
  81. }
  82. function surfaceAnalystProcess() {
  83. widgets.alert.clearAlert();
  84. resultLayer.removeAllFeatures();
  85. var surfaceAnalystService = new SuperMap.REST.SurfaceAnalystService(url2),
  86. surfaceAnalystParameters = new SuperMap.REST.SurfaceAnalystParametersSetting({
  87. datumValue: 0,
  88. interval: 2,
  89. resampleTolerance: 0,
  90. smoothMethod: SuperMap.REST.SmoothMethod.BSPLINE,
  91. smoothness: 3,
  92. clipRegion: region
  93. }),
  94. params = new SuperMap.REST.DatasetSurfaceAnalystParameters({
  95. extractParameter: surfaceAnalystParameters,
  96. dataset: "SamplesP@Interpolation",
  97. resolution: 9000,
  98. zValueFieldName: "AVG_TMP"
  99. });
  100. surfaceAnalystService.events.on({
  101. "processCompleted": surfaceAnalystCompleted,
  102. "processFailed": surfaceAnalystFailed
  103. });
  104. surfaceAnalystService.processAsync(params);
  105. }
  106. function surfaceAnalystCompleted(args) {
  107. var features = args.result.recordset.features;
  108. for (var len = features.length, i = 0; i < len; i++) {
  109. style = {
  110. strokeColor: "#304DBE",
  111. fillOpacity: 0
  112. }
  113. features[i].style = style;
  114. }
  115. resultLayer.addFeatures(args.result.recordset.features);
  116. }
  117. function surfaceAnalystFailed(args) {
  118. widgets.alert.showAlert(args.error.errorMsg, false);
  119. }
  120. function removeData() {
  121. widgets.alert.clearAlert();
  122. resultLayer.removeAllFeatures();
  123. }
  124. </script>
  125. </body>
  126. </html>