summaryAttributesJobService.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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_summaryAttributesJobService"></title>
  9. <script type="text/javascript" include="echarts" src="../../dist/ol/include-ol.js"></script>
  10. <style>
  11. .ol-popup {
  12. position: absolute;
  13. top: 10px;
  14. right: 10px;
  15. }
  16. </style>
  17. </head>
  18. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  19. <div id="map" style="width: 100%;height:100%"></div>
  20. <div id="infoControl" style=" position: absolute;top: 80px;left: 10px;text-align: left;"></div>
  21. <div id="popup" class="ol-popup" style='width:350px'>
  22. <div class="panel panel-default">
  23. <div class="panel-heading">
  24. <h3 class="panel-title" data-i18n="resources.title_summaryAttributesJobService"></h3>
  25. </div>
  26. <div class="panel-body">
  27. <div class="input-group">
  28. <span class="input-group-addon"><span data-i18n="resources.text_inputData"></span><span data-i18n="[title]resources.text_requiredField"
  29. style="color: red;"> * </span> </span>
  30. <input id="datasetName" type="text" class="form-control" value="samples_processing_newyorkZone_R" />
  31. </div>
  32. <p></p>
  33. <div class='input-group'>
  34. <span class='input-group-addon' data-i18n="resources.text_groupField"></span>
  35. <input id='groupField' type='text' class='form-control' value='borough' />
  36. </div>
  37. <p></p>
  38. <div class='input-group'>
  39. <span class='input-group-addon' data-i18n="resources.text_attributeField"></span>
  40. <input id='attributeField' type='text' class='form-control' value='LocationID' />
  41. </div>
  42. <p></p>
  43. <div class='input-group'>
  44. <span class='input-group-addon' data-i18n="resources.text_statisticModes"></span>
  45. <input id='statisticModes' type='text' class='form-control' value='sum' />
  46. </div>
  47. <p></p>
  48. <div align="right">
  49. <input type="button" id='btn' class="btn btn-primary" data-i18n="[value]resources.btn_summary" />
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <script type="text/javascript" include="bootstrap,jquery,widgets" src="../js/include-web.js"></script>
  55. <script type="text/javascript">
  56. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  57. var control,
  58. processingsUrl = host + "/iserver/services/distributedanalyst/rest/v1/jobs",
  59. mapURL = host + "/iserver/services/map-world/rest/maps/World",
  60. map = new ol.Map({
  61. target: 'map',
  62. controls: ol.control.defaults({
  63. attributionOptions: {
  64. collapsed: false
  65. }
  66. })
  67. .extend([new ol.supermap.control.Logo()]),
  68. view: new ol.View({
  69. center: [-73.95, 40.75],
  70. zoom: 12,
  71. projection: 'EPSG:4326',
  72. multiWorld: true
  73. })
  74. });
  75. map.addLayer(new ol.layer.Tile({
  76. source: new ol.source.TileSuperMapRest({
  77. url: mapURL,
  78. }),
  79. }));
  80. var processingService = new ol.supermap.ProcessingService(processingsUrl, {
  81. withCredentials: window.isLocal
  82. }),
  83. info = new ol.control.Control({
  84. element: document.getElementById('popup')
  85. });
  86. info.setMap(map);
  87. map.addControl(info);
  88. SuperMap.SecurityManager.registerToken(processingsUrl, window.exampleToken);
  89. $('#btn').on('click', function () {
  90. if ($('#msg_container')[0]) {
  91. $('#msg_container').remove();
  92. }
  93. widgets.loader.showLoader();
  94. if (map && control) {
  95. map.removeControl(control);
  96. $("#infoControl").html("");
  97. }
  98. var summaryAttributesJobsParameter = new SuperMap.SummaryAttributesJobsParameter({
  99. datasetName: $('#datasetName').val(),
  100. groupField: $('#groupField').val(),
  101. attributeField: $('#attributeField').val(),
  102. statisticModes: $('#statisticModes').val()
  103. });
  104. processingService.addSummaryAttributesJob(summaryAttributesJobsParameter, function (serviceResult) {
  105. if (serviceResult.error) {
  106. widgets.loader.removeLoader();
  107. var errorMsg = serviceResult.error.errorMsg || "code: " + serviceResult.error;
  108. widgets.alert.showAlert(resources.msg_createFailed + "<br>" + errorMsg, false);
  109. return;
  110. }
  111. serviceResult.result.setting.serviceInfo.targetServiceInfos.map(function (info) {
  112. if (info.serviceType === 'RESTDATA') {
  113. var dataUrl = info.serviceAddress + '/data';
  114. var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
  115. queryParameter: {
  116. name: "analystResult@UntitledDatasource",
  117. attributeFilter: "SMID > 0"
  118. },
  119. datasetNames: ["UntitledDatasource:analystResult"]
  120. });
  121. new ol.supermap.FeatureService(dataUrl).getFeaturesBySQL(sqlParam,
  122. function (serviceResult) {
  123. result = serviceResult.result.features.features;
  124. var names = [];
  125. var data1 = [];
  126. var data2 = [];
  127. for (var i = 0; i < result.length; i++) {
  128. names.push(result[i].properties.BOROUGH);
  129. data1.push(parseFloat(result[i].properties.RECORDCOUNT));
  130. data2.push(parseFloat(result[i].properties.SUM_LOCATIONID));
  131. }
  132. chart.setOption({
  133. yAxis: [{
  134. type: 'category',
  135. data: names
  136. },
  137. {
  138. type: 'category',
  139. data: names
  140. }
  141. ],
  142. series: [{
  143. name: "RECORDCOUNT",
  144. data: data1
  145. },
  146. {
  147. name: "SUM_LOCATIONID",
  148. data: data2
  149. }
  150. ]
  151. });
  152. control = new ol.control.Control({
  153. element: chart.getDom(),
  154. target: document.getElementById('infoControl')
  155. });
  156. map.addControl(control);
  157. });
  158. widgets.loader.removeLoader();
  159. }
  160. });
  161. });
  162. });
  163. option = {
  164. backgroundColor: '#0E2A43',
  165. legend: {
  166. bottom: 20,
  167. textStyle: {
  168. color: '#fff',
  169. },
  170. data: ['RECORDCOUNT', 'SUM_LOCATIONID']
  171. },
  172. grid: {
  173. left: '3%',
  174. right: '4%',
  175. bottom: '20%',
  176. containLabel: true
  177. },
  178. tooltip: {
  179. show: "true",
  180. trigger: 'axis',
  181. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  182. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  183. }
  184. },
  185. xAxis: {
  186. type: 'value',
  187. axisTick: {
  188. show: false
  189. },
  190. axisLine: {
  191. show: false,
  192. lineStyle: {
  193. color: '#fff',
  194. }
  195. },
  196. splitLine: {
  197. show: false
  198. },
  199. },
  200. yAxis: [{
  201. type: 'category',
  202. axisTick: {
  203. show: false
  204. },
  205. axisLine: {
  206. show: true,
  207. lineStyle: {
  208. color: '#fff',
  209. }
  210. }
  211. },
  212. {
  213. type: 'category',
  214. axisLine: {
  215. show: false
  216. },
  217. axisTick: {
  218. show: false
  219. },
  220. axisLabel: {
  221. show: false
  222. },
  223. splitArea: {
  224. show: false
  225. },
  226. splitLine: {
  227. show: false
  228. }
  229. }
  230. ],
  231. series: [{
  232. name: 'bar1',
  233. type: 'bar',
  234. itemStyle: {
  235. normal: {
  236. show: true,
  237. color: '#5de3e1',
  238. barBorderRadius: 50,
  239. borderWidth: 0,
  240. borderColor: '#333',
  241. }
  242. },
  243. barGap: '0%',
  244. barCategoryGap: '50%'
  245. },
  246. {
  247. name: 'bar2',
  248. type: 'bar',
  249. yAxisIndex: 1,
  250. itemStyle: {
  251. normal: {
  252. show: true,
  253. color: '#277ace',
  254. barBorderRadius: 50,
  255. borderWidth: 0,
  256. borderColor: '#333',
  257. }
  258. },
  259. barGap: '0%',
  260. barCategoryGap: '50%'
  261. }
  262. ]
  263. };
  264. var chart = echarts.init(document.createElement('div'), '', {
  265. width: 400,
  266. height: 300
  267. });
  268. chart.setOption(option);
  269. </script>
  270. </body>
  271. </html>