04_surfaceAnalystService.html 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_surfaceAnalystService"></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, surfaceAnalystService, surfaceAnalystParameters,
  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 mapService = new ol.supermap.MapService(baseUrl);
  19. var extent = [-2640403.63, 1873792.1, 3247669.39, 5921501.4];
  20. var projection = new ol.proj.Projection({
  21. code:'',
  22. extent: extent,
  23. units: 'm'
  24. });
  25. mapService.getMapInfo(function (serviceResult) {
  26. var mapJSONObj = serviceResult.result;
  27. map = new ol.Map({
  28. target: 'map',
  29. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  30. .extend([new ol.supermap.control.Logo()]),
  31. view: new ol.View({
  32. center: [531762, 3580330],
  33. zoom: 2,
  34. projection: projection,
  35. multiWorld: true
  36. })
  37. });
  38. options = ol.source.TileSuperMapRest.optionsFromMapJSON(baseUrl, mapJSONObj);
  39. var layer = new ol.layer.Tile({
  40. source: new ol.source.TileSuperMapRest(options)
  41. });
  42. map.addLayer(layer);
  43. surfaceAnalystProcess();
  44. });
  45. function surfaceAnalystProcess() {
  46. //创建表面分析服务参数
  47. var region = new ol.geom.Polygon([[
  48. [0, 4010338],
  49. [1063524, 4010338],
  50. [1063524, 3150322],
  51. [0, 3150322]
  52. ]]);
  53. surfaceAnalystParameters = new SuperMap.DatasetSurfaceAnalystParameters({
  54. extractParameter: new SuperMap.SurfaceAnalystParametersSetting({
  55. datumValue: 0,
  56. interval: 2,
  57. resampleTolerance: 0,
  58. smoothMethod: SuperMap.SmoothMethod.BSPLINE,
  59. smoothness: 3,
  60. clipRegion: region
  61. }),
  62. dataset: "SamplesP@Interpolation",
  63. resolution: 9000,
  64. zValueFieldName: "AVG_TMP"
  65. });
  66. //创建表面分析服务实例
  67. surfaceAnalystService = new ol.supermap.SpatialAnalystService(serviceUrl);
  68. surfaceAnalystService.surfaceAnalysis(surfaceAnalystParameters, function (surfaceAnalystServiceResult) {
  69. var result = surfaceAnalystServiceResult.result;
  70. if (result && result.recordset && result.recordset.features) {
  71. var resultLayer = new ol.layer.Vector({
  72. source: new ol.source.Vector({
  73. features: (new ol.format.GeoJSON()).readFeatures(result.recordset.features)
  74. }),
  75. style: new ol.style.Style({
  76. stroke: new ol.style.Stroke({
  77. color: 'rgba(100, 100, 225, 10)',
  78. width: 1.5
  79. }),
  80. fill: new ol.style.Fill({
  81. color: 'rgba(0, 0, 255, 0.1)'
  82. })
  83. })
  84. });
  85. map.addLayer(resultLayer);
  86. }
  87. });
  88. }
  89. </script>
  90. </body>
  91. </html>