1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > 空间分析-点密度插值分析</ title >
6+
7+ < link rel ="stylesheet " href ="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css ">
8+ < link rel ="stylesheet " href ="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.css ">
9+ </ head >
10+ < body style =" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0; ">
11+ < div id ="map " style ="margin:0 auto;width: 100%;height: 100% "> </ div >
12+
13+ < script type ="text/javascript " src ="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.js "> </ script >
14+ < script type ="text/javascript " src ="../../dist/iclient9-leaflet.js "> </ script >
15+ < script type ="text/javascript ">
16+ var map , interpolationAnalystService , interpolationAnalystParameters , interpolationAnalystResult ,
17+ themeService , themeGridRange , themeParameters , themeLayer ,
18+ baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-temperature/rest/maps/全国温度变化图" ,
19+ serviceUrl = "http://support.supermap.com.cn:8090/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst" ;
20+ map = L . map ( 'map' , {
21+ crs : L . CRS . NonEarthCRS ( {
22+ bounds : L . bounds ( [ - 2640403.63 , 1873792.1 ] , [ 3247669.39 , 5921501.4 ] ) ,
23+ origin : L . point ( - 2640403.63 , 5921501.4 )
24+ } ) ,
25+ center : [ 3580330 , 531762 ] ,
26+ maxZoom : 18 ,
27+ zoom : 1
28+ } ) ;
29+ L . supermap . tiledMapLayer ( baseUrl , { noWrap : true , layersID : "[0,1,2]" } ) . addTo ( map ) ;
30+ interpolationAnalystProcess ( ) ;
31+
32+ function interpolationAnalystProcess ( ) {
33+ //创建点密度插值分析参数实例
34+ interpolationAnalystParameters = new SuperMap . InterpolationDensityAnalystParameters ( {
35+ //用于做插值分析的数据源中数据集的名称
36+ dataset : "SamplesP@Interpolation" ,
37+ //插值分析结果数据集的名称
38+ outputDatasetName : "Density_Result" ,
39+ //插值分析结果数据源的名称
40+ outputDatasourceName : "Interpolation" ,
41+ //结果栅格数据集存储的像素格式
42+ pixelFormat : SuperMap . PixelFormat . DOUBLE ,
43+ //插值结果栅格数据集的分辨率
44+ resolution : 3000 ,
45+ // 存储用于进行插值分析的字段名称
46+ zValueFieldName : "AVG_TMP" ,
47+ //结果栅格数据集的范围
48+ bounds : L . bounds ( [ - 2640403.63 , 1873792.1 ] , [ 3247669.39 , 5921501.4 ] )
49+ } ) ;
50+ //创建点密度插值分析服务实例
51+ interpolationAnalystService = L . supermap . spatialAnalystService ( serviceUrl ) ;
52+ interpolationAnalystService . interpolationAnalysis ( interpolationAnalystParameters , function ( serviceResult ) {
53+ interpolationAnalystResult = serviceResult . result ;
54+ if ( interpolationAnalystResult && interpolationAnalystResult . dataset ) {
55+ //用栅格专题图展示分析结果
56+ showAnalysisResult_ThemeGridRange ( ) ;
57+ } else {
58+ alert ( serviceResult . error . errorMsg ) ;
59+ }
60+ } ) ;
61+ }
62+
63+ function showAnalysisResult_ThemeGridRange ( ) {
64+ //创建专题图服务实例
65+ themeService = L . supermap . themeService ( baseUrl ) ;
66+ var color1 = new SuperMap . ServerColor ( 170 , 240 , 233 ) ,
67+ color2 = new SuperMap . ServerColor ( 176 , 244 , 188 ) ,
68+ color3 = new SuperMap . ServerColor ( 218 , 251 , 178 ) ,
69+ color4 = new SuperMap . ServerColor ( 220 , 236 , 145 ) ,
70+ color5 = new SuperMap . ServerColor ( 96 , 198 , 66 ) ,
71+ color6 = new SuperMap . ServerColor ( 20 , 142 , 53 ) ,
72+ color7 = new SuperMap . ServerColor ( 85 , 144 , 55 ) ,
73+ color8 = new SuperMap . ServerColor ( 171 , 168 , 38 ) ,
74+ color9 = new SuperMap . ServerColor ( 235 , 165 , 9 ) ,
75+ color10 = new SuperMap . ServerColor ( 203 , 89 , 2 ) ,
76+ color11 = new SuperMap . ServerColor ( 157 , 25 , 1 ) ,
77+ color12 = new SuperMap . ServerColor ( 118 , 15 , 3 ) ,
78+ color13 = new SuperMap . ServerColor ( 112 , 32 , 7 ) ,
79+ color14 = new SuperMap . ServerColor ( 106 , 45 , 12 ) ,
80+ color15 = new SuperMap . ServerColor ( 129 , 80 , 50 ) ,
81+ color16 = new SuperMap . ServerColor ( 160 , 154 , 146 ) ,
82+ color17 = new SuperMap . ServerColor ( 107 , 47 , 14 ) ,
83+ color18 = new SuperMap . ServerColor ( 125 , 75 , 44 ) ,
84+ color19 = new SuperMap . ServerColor ( 146 , 110 , 88 ) ,
85+ color20 = new SuperMap . ServerColor ( 166 , 153 , 146 ) ;
86+
87+ var themeGridRangeItem1 = new SuperMap . ThemeGridRangeItem ( {
88+ start : - 5 ,
89+ end : - 3.4 ,
90+ color : color1
91+ } ) ,
92+ themeGridRangeItem2 = new SuperMap . ThemeGridRangeItem ( {
93+ start : - 3.4 ,
94+ end : - 1.8 ,
95+ color : color2
96+ } ) ,
97+ themeGridRangeItem3 = new SuperMap . ThemeGridRangeItem ( {
98+ start : - 1.8 ,
99+ end : - 0.2 ,
100+ color : color3
101+ } ) ,
102+ themeGridRangeItem4 = new SuperMap . ThemeGridRangeItem ( {
103+ start : - 0.2 ,
104+ end : 1.4 ,
105+ color : color4
106+ } ) ,
107+ themeGridRangeItem5 = new SuperMap . ThemeGridRangeItem ( {
108+ start : 1.4 ,
109+ end : 3 ,
110+ color : color5
111+ } ) ,
112+ themeGridRangeItem6 = new SuperMap . ThemeGridRangeItem ( {
113+ start : 3 ,
114+ end : 4.6 ,
115+ color : color6
116+ } ) ,
117+ themeGridRangeItem7 = new SuperMap . ThemeGridRangeItem ( {
118+ start : 4.6 ,
119+ end : 6.2 ,
120+ color : color7
121+ } ) ,
122+ themeGridRangeItem8 = new SuperMap . ThemeGridRangeItem ( {
123+ start : 6.2 ,
124+ end : 7.8 ,
125+ color : color8
126+ } ) ,
127+ themeGridRangeItem9 = new SuperMap . ThemeGridRangeItem ( {
128+ start : 7.8 ,
129+ end : 9.4 ,
130+ color : color9
131+ } ) ,
132+ themeGridRangeItem10 = new SuperMap . ThemeGridRangeItem ( {
133+ start : 9.4 ,
134+ end : 11 ,
135+ color : color10
136+ } ) ,
137+ themeGridRangeItem11 = new SuperMap . ThemeGridRangeItem ( {
138+ start : 11 ,
139+ end : 12.6 ,
140+ color : color11
141+ } ) ,
142+ themeGridRangeItem12 = new SuperMap . ThemeGridRangeItem ( {
143+ start : 12.6 ,
144+ end : 14.2 ,
145+ color : color12
146+ } ) ,
147+ themeGridRangeItem13 = new SuperMap . ThemeGridRangeItem ( {
148+ start : 14.2 ,
149+ end : 35.8 ,
150+ color : color13
151+ } ) ,
152+ themeGridRangeItem14 = new SuperMap . ThemeGridRangeItem ( {
153+ start : 35.8 ,
154+ end : 57.4 ,
155+ color : color14
156+ } ) ,
157+ themeGridRangeItem15 = new SuperMap . ThemeGridRangeItem ( {
158+ start : 57.4 ,
159+ end : 79 ,
160+ color : color15
161+ } ) ,
162+ themeGridRangeItem16 = new SuperMap . ThemeGridRangeItem ( {
163+ start : 79 ,
164+ end : 90.6 ,
165+ color : color16
166+ } ) ,
167+ themeGridRangeItem17 = new SuperMap . ThemeGridRangeItem ( {
168+ start : 90.6 ,
169+ end : 112.2 ,
170+ color : color17
171+ } ) ,
172+ themeGridRangeItem18 = new SuperMap . ThemeGridRangeItem ( {
173+ start : 112.2 ,
174+ end : 123.8 ,
175+ color : color18
176+ } ) ,
177+ themeGridRangeItem19 = new SuperMap . ThemeGridRangeItem ( {
178+ start : 123.8 ,
179+ end : 125.4 ,
180+ color : color19
181+ } ) ,
182+ themeGridRangeItem20 = new SuperMap . ThemeGridRangeItem ( {
183+ start : 125.4 ,
184+ end : 135 ,
185+ color : color20
186+ } ) ;
187+
188+ themeGridRange = new SuperMap . ThemeGridRange ( {
189+ reverseColor : false ,
190+ rangeMode : SuperMap . RangeMode . EQUALINTERVAL ,
191+ //栅格分段专题图子项数组
192+ items : [ themeGridRangeItem1 , themeGridRangeItem2 ,
193+ themeGridRangeItem3 , themeGridRangeItem4 ,
194+ themeGridRangeItem5 , themeGridRangeItem6 ,
195+ themeGridRangeItem7 , themeGridRangeItem8 ,
196+ themeGridRangeItem9 , themeGridRangeItem10 ,
197+ themeGridRangeItem11 , themeGridRangeItem12 ,
198+ themeGridRangeItem13 , themeGridRangeItem14 ,
199+ themeGridRangeItem15 , themeGridRangeItem16 ,
200+ themeGridRangeItem17 , themeGridRangeItem18 ,
201+ themeGridRangeItem19 , themeGridRangeItem20
202+ ]
203+ } ) ;
204+
205+ themeParameters = new SuperMap . ThemeParameters ( {
206+ //制作专题图的数据集
207+ datasetNames : [ interpolationAnalystResult . dataset . split ( '@' ) [ 0 ] ] ,
208+ dataSourceNames : [ "Interpolation" ] ,
209+ joinItems : null ,
210+ themes : [ themeGridRange ]
211+ } ) ;
212+
213+ themeService . getThemeInfo ( themeParameters , function ( getThemeInfoServiceResult ) {
214+ var result = getThemeInfoServiceResult . result ;
215+ if ( result && result . newResourceID ) {
216+ themeLayer = L . supermap . tiledMapLayer ( baseUrl , {
217+ noWrap : true ,
218+ cacheEnabled : false ,
219+ transparent : true ,
220+ layersID : result . newResourceID ,
221+ //opacity: 0.8
222+ } ) . addTo ( map ) ;
223+ }
224+ } ) . on ( 'failed' , function ( error ) {
225+ alert ( error . errorMsg ) ;
226+ } ) ;
227+ }
228+ </ script >
229+ </ body >
230+ </ html >
0 commit comments