CGCS2000ArcGisMapServerImageryProvider-nohx.js 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787
  1. ; (function (Cesium) {
  2. const coordinate = {
  3. x_PI: (Math.PI * 3000.0) / 180.0,
  4. PI: Math.PI,
  5. ee: 0.00669342162296594323,
  6. a: 6378245.0,
  7. projs: {
  8. '01': 'wgs84', // 84坐标
  9. '02': 'gcj02', // 火星坐标
  10. '03': 'bd09', // 百度坐标
  11. '04': 'utm4', // utm坐标
  12. '05': 'shcj', // 城建坐标
  13. '06': 'meter', // 米制单位
  14. '07': 'degree' // 度制单位
  15. },
  16. epsg: {
  17. //WGS 84 - WGS84 - World Geodetic System 1984, used in GPS
  18. '4326': '+proj=longlat +datum=WGS84 +no_defs',
  19. //WGS 84 / Pseudo-Mercator - Spherical Mercator, Google Maps, OpenStreetMap, Bing, ArcGIS, ESRI
  20. '3857':
  21. '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs',
  22. //CGCS2000 / 3-degree Gauss-Kruger zone 40
  23. '4528':
  24. '+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=GRS80 +units=m +no_defs'
  25. },
  26. bd09_to_gcj02: function (bd_lon, bd_lat) {
  27. var x = bd_lon - 0.0065
  28. var y = bd_lat - 0.006
  29. var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * this.x_PI)
  30. var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.x_PI)
  31. var gg_lng = z * Math.cos(theta)
  32. var gg_lat = z * Math.sin(theta)
  33. return [gg_lng, gg_lat]
  34. },
  35. gcj02_to_bd09: function (lng, lat) {
  36. var z =
  37. Math.Sqrt(lng * lng + lat * lat) + 0.00002 * Math.Sin(lat * this.x_PI)
  38. var theta = Math.Atan2(lat, lng) + 0.000003 * Math.Cos(lng * this.x_PI)
  39. var bd_lng = z * Math.Cos(theta) + 0.0065
  40. var bd_lat = z * Math.Sin(theta) + 0.006
  41. return [bd_lng, bd_lat]
  42. },
  43. wgs84_to_gcj02: function (lng, lat) {
  44. if (this.out_of_china(lng, lat)) {
  45. [lng, lat]
  46. } else {
  47. var dlat = this.transformlat(lng - 105.0, lat - 35.0)
  48. var dlng = this.transformlng(lng - 105.0, lat - 35.0)
  49. var radlat = (lat / 180.0) * this.PI
  50. var magic = Math.sin(radlat)
  51. magic = 1 - this.ee * magic * magic
  52. var sqrtmagic = Math.sqrt(magic)
  53. dlat =
  54. (dlat * 180.0) /
  55. (((this.a * (1 - this.ee)) / (magic * sqrtmagic)) * this.PI)
  56. dlng =
  57. (dlng * 180.0) / ((this.a / sqrtmagic) * Math.cos(radlat) * this.PI)
  58. var mglat = parseFloat(lat) + parseFloat(dlat)
  59. var mglng = parseFloat(lng) + parseFloat(dlng)
  60. return [mglng, mglat]
  61. }
  62. },
  63. gcj02_to_wgs84: function (lng, lat) {
  64. if (this.out_of_china(lng, lat)) {
  65. return [lng, lat]
  66. } else {
  67. var dlat = this.transformlat(lng - 105.0, lat - 35.0)
  68. var dlng = this.transformlng(lng - 105.0, lat - 35.0)
  69. var radlat = (lat / 180.0) * this.PI
  70. var magic = Math.sin(radlat)
  71. magic = 1 - this.ee * magic * magic
  72. var sqrtmagic = Math.sqrt(magic)
  73. dlat =
  74. (dlat * 180.0) /
  75. (((this.a * (1 - this.ee)) / (magic * sqrtmagic)) * this.PI)
  76. dlng =
  77. (dlng * 180.0) / ((this.a / sqrtmagic) * Math.cos(radlat) * this.PI)
  78. var mglat = lat + dlat
  79. var mglng = lng + dlng
  80. return [lng * 2 - mglng, lat * 2 - mglat]
  81. }
  82. },
  83. out_of_china: function (lng, lat) {
  84. // 纬度3.86~53.55,经度73.66~135.05
  85. return !(lng > 73.66 && lng < 135.05 && lat > 3.86 && lat < 53.55)
  86. },
  87. transformlat: function (lng, lat) {
  88. var ret =
  89. -100.0 +
  90. 2.0 * lng +
  91. 3.0 * lat +
  92. 0.2 * lat * lat +
  93. 0.1 * lng * lat +
  94. 0.2 * Math.sqrt(Math.abs(lng))
  95. ret +=
  96. ((20.0 * Math.sin(6.0 * lng * this.PI) +
  97. 20.0 * Math.sin(2.0 * lng * this.PI)) *
  98. 2.0) /
  99. 3.0
  100. ret +=
  101. ((20.0 * Math.sin(lat * this.PI) +
  102. 40.0 * Math.sin((lat / 3.0) * this.PI)) *
  103. 2.0) /
  104. 3.0
  105. ret +=
  106. ((160.0 * Math.sin((lat / 12.0) * this.PI) +
  107. 320 * Math.sin((lat * this.PI) / 30.0)) *
  108. 2.0) /
  109. 3.0
  110. return ret
  111. },
  112. transformlng: function (lng, lat) {
  113. var ret =
  114. 300.0 +
  115. lng +
  116. 2.0 * lat +
  117. 0.1 * lng * lng +
  118. 0.1 * lng * lat +
  119. 0.1 * Math.sqrt(Math.abs(lng))
  120. ret +=
  121. ((20.0 * Math.sin(6.0 * lng * this.PI) +
  122. 20.0 * Math.sin(2.0 * lng * this.PI)) *
  123. 2.0) /
  124. 3.0
  125. ret +=
  126. ((20.0 * Math.sin(lng * this.PI) +
  127. 40.0 * Math.sin((lng / 3.0) * this.PI)) *
  128. 2.0) /
  129. 3.0
  130. ret +=
  131. ((150.0 * Math.sin((lng / 12.0) * this.PI) +
  132. 300.0 * Math.sin((lng / 30.0) * this.PI)) *
  133. 2.0) /
  134. 3.0
  135. return ret
  136. },
  137. /// <summary>
  138. /// web墨卡托经纬度转米
  139. /// </summary>
  140. /// <param name="lng"></param>
  141. /// <param name="lat"></param>
  142. /// <returns></returns>
  143. degree_to_meter: function (lng, lat) {
  144. var x = (lng * 20037508.34) / 180
  145. var y = Math.log(Math.tan(((90 + lat) * this.PI) / 360)) / (this.PI / 180)
  146. y = (y * 20037508.34) / 180
  147. return [x, y]
  148. },
  149. //Web墨卡托转经纬度
  150. meter_to_degree: function (x, y) {
  151. var lon = (x / 20037508.34) * 180
  152. var lat = (y / 20037508.34) * 180
  153. lat =
  154. (180 / this.PI) *
  155. (2 * Math.atan(Math.exp((lat * this.PI) / 180)) - this.PI / 2)
  156. return [lon, lat]
  157. },
  158. /**
  159. * @description wgs84坐标转上海城建
  160. * @time 2020-09-02
  161. * @author zhb
  162. * @param {*} x
  163. * @param {*} y
  164. */
  165. wgs84_to_shcj: function (x, y) {
  166. let xy = []
  167. xy = this.shcj_get_UTM_from_WGS(x, y)
  168. return this.utm_to_shcj4(xy[0], xy[1])
  169. },
  170. utm_to_shcj4(x, y) {
  171. let DX, DY, T, K
  172. DX = -500199.29965
  173. DY = -3457078.805985
  174. T = 0.0000001755
  175. K = 1.0004000106
  176. return this.covert_by_four_parm(x, y, DX, DY, T, K)
  177. },
  178. shcj_get_UTM_from_WGS: function (lon, lat) {
  179. let a = 6378137
  180. let b = 6356752.3142451
  181. let f = (a - b) / a
  182. let eSquare = 2 * f - f * f
  183. let k0 = 0.9996
  184. let lonOrigin = 121.46714714
  185. let FN = 0
  186. // # 确保longtitude位于-180.00----179.9之间
  187. let lonTemp = lon + 180 - Math.floor((lon + 180) / 360) * 360 - 180
  188. let latRad = (lat * this.PI) / 180
  189. let lonRad = (lonTemp * this.PI) / 180
  190. let lonOriginRad = (lonOrigin * this.PI) / 180
  191. let e2Square = eSquare / (1 - eSquare)
  192. let V = a / Math.sqrt(1 - eSquare * Math.pow(Math.sin(latRad), 2))
  193. let T = Math.pow(Math.tan(latRad), 2)
  194. let C = e2Square * Math.pow(Math.cos(latRad), 2)
  195. let A = Math.cos(latRad) * (lonRad - lonOriginRad)
  196. let M =
  197. a *
  198. ((1 -
  199. eSquare / 4 -
  200. (3 * Math.pow(eSquare, 2)) / 64 -
  201. (5 * Math.pow(eSquare, 3)) / 256) *
  202. latRad -
  203. ((3 * eSquare) / 8 +
  204. (3 * Math.pow(eSquare, 2)) / 32 +
  205. (45 * Math.pow(eSquare, 3)) / 1024) *
  206. Math.sin(2 * latRad) +
  207. ((15 * Math.pow(eSquare, 2)) / 256 +
  208. (45 * Math.pow(eSquare, 3)) / 1024) *
  209. Math.sin(4 * latRad) -
  210. ((35 * Math.pow(eSquare, 3)) / 3072) * Math.sin(6 * latRad))
  211. // # x
  212. let UTMEasting =
  213. k0 *
  214. V *
  215. (A +
  216. ((1 - T + C) * Math.pow(A, 3)) / 6 +
  217. ((5 - 18 * T + Math.pow(T, 2) + 72 * C - 58 * e2Square) *
  218. Math.pow(A, 5)) /
  219. 120) +
  220. 500000.0
  221. // # y
  222. let UTMNorthing =
  223. k0 *
  224. (M +
  225. V *
  226. Math.tan(latRad) *
  227. (Math.pow(A, 2) / 2 +
  228. ((5 - T + 9 * C + 4 * Math.pow(C, 2)) * Math.pow(A, 4)) / 24 +
  229. ((61 - 58 * T + Math.pow(T, 2) + 600 * C - 330 * e2Square) *
  230. Math.pow(A, 6)) /
  231. 720))
  232. //# 南半球纬度起点为10000000.0m
  233. UTMNorthing += FN
  234. let xy = []
  235. xy[0] = UTMEasting
  236. xy[1] = UTMNorthing
  237. return xy
  238. },
  239. /**
  240. * @description 上海城建坐标转wgs84
  241. * @time 2020-09-02
  242. * @author zhb
  243. * @param {*} x
  244. * @param {*} y
  245. */
  246. shcj_to_wgs84: function (x, y) {
  247. let xy = []
  248. xy = this.shcj_to_utm4(x, y)
  249. return this.shcj_get_WGS_from_UTM(xy[0], xy[1])
  250. },
  251. shcj_to_utm4: function (x, y) {
  252. let DX, DY, T, K
  253. DX = 499999.90104
  254. DY = 3455696.403019
  255. T = -0.0000001755
  256. K = 0.999600149344
  257. return this.covert_by_four_parm(x, y, DX, DY, T, K)
  258. },
  259. //四参数公式
  260. covert_by_four_parm: function (x, y, dx, dy, a, k) {
  261. let px = 0
  262. let py = 0
  263. px = x * k * Math.cos(a) - y * k * Math.sin(a) + dx
  264. py = x * k * Math.sin(a) + y * k * Math.cos(a) + dy
  265. let xy = []
  266. xy[0] = px
  267. xy[1] = py
  268. return xy
  269. },
  270. shcj_get_WGS_from_UTM: function (x, y) {
  271. //WGS84
  272. let a = 6378137 //椭球体长半轴
  273. let b = 6356752.3142451 //椭球体短半轴
  274. // double a = 6378245 ;
  275. // double b =6356863.018773047300000000;
  276. x = 500000 - x
  277. let k0 = 0.9996
  278. let e = Math.sqrt(1 - Math.pow(b, 2) / Math.pow(a, 2))
  279. // # calculate the meridional arc
  280. let M = y / k0
  281. //# calculate footprint latitude
  282. let mu =
  283. M /
  284. (a *
  285. (1 -
  286. Math.pow(e, 2) / 4 -
  287. (3 * Math.pow(e, 4)) / 64 -
  288. (5 * Math.pow(e, 6)) / 256))
  289. let e1 =
  290. (1 - Math.pow(1 - Math.pow(e, 2), 1.0 / 2)) /
  291. (1 + Math.pow(1 - Math.pow(e, 2), 1.0 / 2))
  292. let J1 = (3 * e1) / 2 - (27 * Math.pow(e1, 3)) / 32
  293. let J2 = (21 * Math.pow(e1, 2)) / 16 - (55 * Math.pow(e1, 4)) / 32
  294. let J3 = (151 * Math.pow(e1, 3)) / 96
  295. let J4 = (1097 * Math.pow(e1, 4)) / 512
  296. let fp =
  297. mu +
  298. J1 * Math.sin(2 * mu) +
  299. J2 * Math.sin(4 * mu) +
  300. J3 * Math.sin(6 * mu) +
  301. J4 * Math.sin(8 * mu)
  302. // # Calculate Latitude and Longitude
  303. let e2 = Math.pow(e, 2) / (1 - Math.pow(e, 2))
  304. let C1 = e2 * Math.pow(Math.cos(fp), 2)
  305. let T1 = Math.pow(Math.tan(fp), 2)
  306. let R1 =
  307. (a * (1 - Math.pow(e, 2))) /
  308. Math.pow(1 - Math.pow(e * Math.sin(fp), 2), 3.0 / 2)
  309. //# This is the same as rho in the forward conversion formulas above, but calculated for fp instead of lat.
  310. let N1 = a / Math.pow(1 - Math.pow(e * Math.sin(fp), 2), 1.0 / 2)
  311. //# This is the same as nu in the forward conversion formulas above, but calculated for fp instead of lat.
  312. let D = x / (N1 * k0)
  313. let Q1 = (N1 * Math.tan(fp)) / R1
  314. let Q2 = Math.pow(D, 2) / 2
  315. let Q3 =
  316. ((5 + 3 * T1 + 10 * C1 - 4 * Math.pow(C1, 2) - 9 * e2) * Math.pow(D, 4)) /
  317. 24
  318. let Q4 =
  319. ((61 +
  320. 90 * T1 +
  321. 298 * C1 +
  322. 45 * Math.pow(T1, 2) -
  323. 3 * Math.pow(C1, 2) -
  324. 252 * e2) *
  325. Math.pow(D, 6)) /
  326. 720
  327. let lat = ((fp - Q1 * (Q2 - Q3 + Q4)) * 180) / this.PI
  328. // System.out.println("lat===="+Math.toRadians(fp - Q1*(Q2 - Q3 + Q4)));
  329. let Q5 = D
  330. let Q6 = ((1 + 2 * T1 + C1) * Math.pow(D, 3)) / 6
  331. let Q7 =
  332. ((5 -
  333. 2 * C1 +
  334. 28 * T1 -
  335. 3 * Math.pow(C1, 2) +
  336. 8 * e2 +
  337. 24 * Math.pow(T1, 2)) *
  338. Math.pow(D, 5)) /
  339. 120
  340. let lonmid = 121.46714714
  341. let lon = lonmid - (((Q5 - Q6 + Q7) / Math.cos(fp)) * 180) / this.PI
  342. //System.out.println("lon===="+(mMid - Math.toRadians((Q5 - Q6 + Q7)/Math.cos(fp))));
  343. // System.out.println(lat+","+lon);
  344. let xy = []
  345. xy[0] = lon
  346. xy[1] = lat
  347. return xy
  348. },
  349. wgs84_to_bd09: function (x, y) {
  350. let ll = this.wgs84_to_gcj02(x, y)
  351. ll = this.gcj02_to_bd09(ll[0], ll[1])
  352. return ll
  353. },
  354. bd09_to_wgs84: function (x, y) {
  355. let ll = this.bd09_to_gcj02(x, y)
  356. ll = this.gcj02_to_wgs84(ll[0], ll[1])
  357. return ll
  358. },
  359. gcj02_to_shcj: function (x, y) {
  360. let ll = this.gcj02_to_wgs84(x, y)
  361. ll = this.wgs84_to_shcj(ll[0], ll[1])
  362. return ll
  363. },
  364. shcj_to_gcj02: function (x, y) {
  365. let ll = this.shcj_to_wgs84(x, y)
  366. ll = this.wgs84_to_gcj02(ll[0], ll[1])
  367. return ll
  368. },
  369. /**
  370. * @description 坐标转换转换 01:84,02:高德,03.百度,04,UTM,05,上海城建,06:米制单位
  371. * @param {} from
  372. * @param {*} to
  373. * @param {*} xy
  374. * @time 2020-09-02
  375. * @author zhb
  376. */
  377. convert_proj_from_to: function (from, to, xy) {
  378. if (from === to) {
  379. return xy
  380. } else {
  381. let fromProj = this.projs[from]
  382. let toProj = this.projs[to]
  383. let targetMethod = `${fromProj}_to_${toProj}`
  384. return this[targetMethod](xy[0], xy[1])
  385. }
  386. }
  387. }
  388. class CoordTransform {
  389. constructor() {
  390. this.PI = 3.1415926535897932384626;
  391. this.RADIUS = 6378245.0;
  392. this.EE = 0.00669342162296594323;
  393. }
  394. static WGS84ToSH2000(lng, lat) {
  395. if (this.out_of_sh(lng, lat)) {
  396. return [lng, lat];
  397. } else {
  398. var templatlng = coordinate.wgs84_to_shcj(lng, lat);
  399. templatlng = coordinate.meter_to_degree(templatlng[0], templatlng[1])
  400. return [templatlng[0], templatlng[1]];
  401. }
  402. }
  403. static SH2000ToWGS84(x, y) {
  404. //墨卡托转经纬度
  405. var templatlng = coordinate.meter_to_degree(x, y);
  406. if (this.out_of_sh2000(templatlng[0], templatlng[1])) {
  407. return [x, y];
  408. } else {
  409. templatlng = coordinate.shcj_to_wgs84(x, y);
  410. return templatlng;
  411. }
  412. }
  413. static SH2000lnglatToWGS84(lng, lat) {
  414. //墨卡托转经纬度
  415. if (this.out_of_sh2000(lng, lat)) {
  416. return [lng, lat];
  417. } else {
  418. var templatlng = coordinate.degree_to_meter(lng, lat);
  419. templatlng = coordinate.shcj_to_wgs84(templatlng[0], templatlng[1]);
  420. return templatlng;
  421. }
  422. }
  423. /**
  424. * 判断是否在上海。不在上海不做偏移
  425. * 118.48721797337146,30.26010209544536,122.69588184110438,32.52150117412529
  426. * @param lng
  427. * @param lat
  428. * @returns {boolean}
  429. */
  430. static out_of_sh(lng, lat) {
  431. lat = +lat;
  432. lng = +lng;
  433. return !(lng > 115.487 && lng < 123.696 && lat > 28.260 && lat < 33.521);
  434. }
  435. /*
  436. * 上海坐标系范围判断
  437. */
  438. static out_of_sh2000(lng, lat) {
  439. lat = +lat;
  440. lng = +lng;
  441. return !(lng > -12.819008830308748 && lng < 10.125641358030961 && lat > -7.553039281805486 && lat < 8.400473860032621);
  442. }
  443. /**
  444. *
  445. * @param lng
  446. * @param lat
  447. * @returns {number[]}
  448. */
  449. static delta(lng, lat) {
  450. let dLng = this.transformLng(lng - 105, lat - 35);
  451. let dLat = this.transformLat(lng - 105, lat - 35);
  452. const radLat = (lat / 180) * this.PI;
  453. let magic = Math.sin(radLat);
  454. magic = 1 - this.EE * magic * magic;
  455. const sqrtMagic = Math.sqrt(magic);
  456. dLng = (dLng * 180) / ((this.RADIUS / sqrtMagic) * Math.cos(radLat) * this.PI);
  457. dLat = (dLat * 180) / (((this.RADIUS * (1 - this.EE)) / (magic * sqrtMagic)) * this.PI);
  458. return [dLng, dLat];
  459. }
  460. /**
  461. *
  462. * @param lng
  463. * @param lat
  464. * @returns {number}
  465. */
  466. static transformLng(lng, lat) {
  467. lat = +lat;
  468. lng = +lng;
  469. let ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
  470. ret += ((20.0 * Math.sin(6.0 * lng * this.PI) + 20.0 * Math.sin(2.0 * lng * this.PI)) * 2.0) / 3.0;
  471. ret += ((20.0 * Math.sin(lng * this.PI) + 40.0 * Math.sin((lng / 3.0) * this.PI)) * 2.0) / 3.0;
  472. ret += ((150.0 * Math.sin((lng / 12.0) * this.PI) + 300.0 * Math.sin((lng / 30.0) * this.PI)) * 2.0) / 3.0;
  473. return ret;
  474. }
  475. /**
  476. *
  477. * @param lng
  478. * @param lat
  479. * @returns {number}
  480. */
  481. static transformLat(lng, lat) {
  482. lat = +lat;
  483. lng = +lng;
  484. let ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
  485. ret += ((20.0 * Math.sin(6.0 * lng * this.PI) + 20.0 * Math.sin(2.0 * lng * this.PI)) * 2.0) / 3.0;
  486. ret += ((20.0 * Math.sin(lat * this.PI) + 40.0 * Math.sin((lat / 3.0) * this.PI)) * 2.0) / 3.0;
  487. ret += ((160.0 * Math.sin((lat / 12.0) * this.PI) + 320 * Math.sin((lat * this.PI) / 30.0)) * 2.0) / 3.0;
  488. return ret;
  489. }
  490. // 经纬度转墨卡托
  491. static transformMercator(lonLat) {
  492. var mercator = {};
  493. var x = lonLat.x * 20037508.34 / 180;
  494. var y = Math.log(Math.tan((90 + lonLat.y) * Math.PI / 360)) / (Math.PI / 180);
  495. y = y * 20037508.34 / 180;
  496. mercator.x = x;
  497. mercator.y = y;
  498. return mercator;
  499. }
  500. }
  501. Cesium.CoordTransform = CoordTransform;
  502. /**
  503. * A tiling scheme for geometry referenced to a {@link WebMercatorProjection}, EPSG:3857. This is
  504. * the tiling scheme used by Google Maps, Microsoft Bing Maps, and most of ESRI ArcGIS Online.
  505. *
  506. * @alias SHmapMercatorTilingScheme
  507. * @constructor
  508. *
  509. * @param {Object} [options] Object with the following properties:
  510. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid whose surface is being tiled. Defaults to
  511. * the WGS84 ellipsoid.
  512. * @param {Number} [options.numberOfLevelZeroTilesX=1] The number of tiles in the X direction at level zero of
  513. * the tile tree.
  514. * @param {Number} [options.numberOfLevelZeroTilesY=1] The number of tiles in the Y direction at level zero of
  515. * the tile tree.
  516. * @param {Cartesian2} [options.rectangleSouthwestInMeters] The southwest corner of the rectangle covered by the
  517. * tiling scheme, in meters. If this parameter or rectangleNortheastInMeters is not specified, the entire
  518. * globe is covered in the longitude direction and an equal distance is covered in the latitude
  519. * direction, resulting in a square projection.
  520. * @param {Cartesian2} [options.rectangleNortheastInMeters] The northeast corner of the rectangle covered by the
  521. * tiling scheme, in meters. If this parameter or rectangleSouthwestInMeters is not specified, the entire
  522. * globe is covered in the longitude direction and an equal distance is covered in the latitude
  523. * direction, resulting in a square projection.
  524. */
  525. function SHmapMercatorTilingScheme(options) {
  526. options = Cesium.defaultValue(options, Cesium.defaultValue.EMPTY_OBJECT);
  527. this._ellipsoid = Cesium.defaultValue(options.ellipsoid, Cesium.Ellipsoid.WGS84);
  528. this._numberOfLevelZeroTilesX = Cesium.defaultValue(
  529. options.numberOfLevelZeroTilesX,
  530. 1
  531. );
  532. this._numberOfLevelZeroTilesY = Cesium.defaultValue(
  533. options.numberOfLevelZeroTilesY,
  534. 1
  535. );
  536. this._projection = new Cesium.WebMercatorProjection();
  537. var oprojection = new Cesium.WebMercatorProjection();
  538. this._projection.project = function (cartographic, result) {
  539. result = CoordTransform.WGS84ToSH2000(
  540. Cesium.Math.toDegrees(cartographic.longitude),
  541. Cesium.Math.toDegrees(cartographic.latitude)
  542. );
  543. result = oprojection.project(new Cesium.Cartographic(Cesium.Math.toRadians(result[0]), Cesium.Math.toRadians(result[1])));
  544. return new Cesium.Cartesian2(result.x, result.y);
  545. };
  546. this._projection.unproject = function (cartesian, result) {
  547. let cartographic = oprojection.unproject(cartesian);
  548. result = CoordTransform.SH2000lnglatToWGS84(
  549. Cesium.Math.toDegrees(cartographic.longitude),
  550. Cesium.Math.toDegrees(cartographic.latitude)
  551. );
  552. return new Cesium.Cartographic(Cesium.Math.toRadians(result[0]), Cesium.Math.toRadians(result[1]));
  553. };
  554. if (
  555. Cesium.defined(options.rectangleSouthwestInMeters) &&
  556. Cesium.defined(options.rectangleNortheastInMeters)
  557. ) {
  558. this._rectangleSouthwestInMeters = options.rectangleSouthwestInMeters;
  559. this._rectangleNortheastInMeters = options.rectangleNortheastInMeters;
  560. } else {
  561. const semimajorAxisTimesPi = this._ellipsoid.maximumRadius * Cesium.Math.PI;
  562. this._rectangleSouthwestInMeters = new Cesium.Cartesian2(
  563. -semimajorAxisTimesPi,
  564. -semimajorAxisTimesPi
  565. );
  566. this._rectangleNortheastInMeters = new Cesium.Cartesian2(
  567. semimajorAxisTimesPi,
  568. semimajorAxisTimesPi
  569. );
  570. }
  571. const southwest = this._projection.unproject(
  572. this._rectangleSouthwestInMeters
  573. );
  574. const northeast = this._projection.unproject(
  575. this._rectangleNortheastInMeters
  576. );
  577. this._rectangle = new Cesium.Rectangle(
  578. southwest.longitude,
  579. southwest.latitude,
  580. northeast.longitude,
  581. northeast.latitude
  582. );
  583. }
  584. Object.defineProperties(SHmapMercatorTilingScheme.prototype, {
  585. /**
  586. * Gets the ellipsoid that is tiled by this tiling scheme.
  587. * @memberof SHmapMercatorTilingScheme.prototype
  588. * @type {Ellipsoid}
  589. */
  590. ellipsoid: {
  591. get: function () {
  592. return this._ellipsoid;
  593. },
  594. },
  595. /**
  596. * Gets the rectangle, in radians, covered by this tiling scheme.
  597. * @memberof SHmapMercatorTilingScheme.prototype
  598. * @type {Rectangle}
  599. */
  600. rectangle: {
  601. get: function () {
  602. return this._rectangle;
  603. },
  604. },
  605. /**
  606. * Gets the map projection used by this tiling scheme.
  607. * @memberof SHmapMercatorTilingScheme.prototype
  608. * @type {MapProjection}
  609. */
  610. projection: {
  611. get: function () {
  612. return this._projection;
  613. },
  614. },
  615. });
  616. /**
  617. * Gets the total number of tiles in the X direction at a specified level-of-detail.
  618. *
  619. * @param {Number} level The level-of-detail.
  620. * @returns {Number} The number of tiles in the X direction at the given level.
  621. */
  622. SHmapMercatorTilingScheme.prototype.getNumberOfXTilesAtLevel = function (level) {
  623. return this._numberOfLevelZeroTilesX << level;
  624. };
  625. /**
  626. * Gets the total number of tiles in the Y direction at a specified level-of-detail.
  627. *
  628. * @param {Number} level The level-of-detail.
  629. * @returns {Number} The number of tiles in the Y direction at the given level.
  630. */
  631. SHmapMercatorTilingScheme.prototype.getNumberOfYTilesAtLevel = function (level) {
  632. return this._numberOfLevelZeroTilesY << level;
  633. };
  634. /**
  635. * Transforms a rectangle specified in geodetic radians to the native coordinate system
  636. * of this tiling scheme.
  637. *
  638. * @param {Rectangle} rectangle The rectangle to transform.
  639. * @param {Rectangle} [result] The instance to which to copy the result, or undefined if a new instance
  640. * should be created.
  641. * @returns {Rectangle} The specified 'result', or a new object containing the native rectangle if 'result'
  642. * is undefined.
  643. */
  644. SHmapMercatorTilingScheme.prototype.rectangleToNativeRectangle = function (
  645. rectangle,
  646. result
  647. ) {
  648. const projection = this._projection;
  649. const southwest = projection.project(Cesium.Rectangle.southwest(rectangle));
  650. const northeast = projection.project(Cesium.Rectangle.northeast(rectangle));
  651. if (!Cesium.defined(result)) {
  652. return new Cesium.Rectangle(southwest.x, southwest.y, northeast.x, northeast.y);
  653. }
  654. result.west = southwest.x;
  655. result.south = southwest.y;
  656. result.east = northeast.x;
  657. result.north = northeast.y;
  658. return result;
  659. };
  660. /**
  661. * Converts tile x, y coordinates and level to a rectangle expressed in the native coordinates
  662. * of the tiling scheme.
  663. *
  664. * @param {Number} x The integer x coordinate of the tile.
  665. * @param {Number} y The integer y coordinate of the tile.
  666. * @param {Number} level The tile level-of-detail. Zero is the least detailed.
  667. * @param {Object} [result] The instance to which to copy the result, or undefined if a new instance
  668. * should be created.
  669. * @returns {Rectangle} The specified 'result', or a new object containing the rectangle
  670. * if 'result' is undefined.
  671. */
  672. SHmapMercatorTilingScheme.prototype.tileXYToNativeRectangle = function (
  673. x,
  674. y,
  675. level,
  676. result
  677. ) {
  678. const xTiles = this.getNumberOfXTilesAtLevel(level);
  679. const yTiles = this.getNumberOfYTilesAtLevel(level);
  680. const xTileWidth =
  681. (this._rectangleNortheastInMeters.x - this._rectangleSouthwestInMeters.x) /
  682. xTiles;
  683. const west = this._rectangleSouthwestInMeters.x + x * xTileWidth;
  684. const east = this._rectangleSouthwestInMeters.x + (x + 1) * xTileWidth;
  685. const yTileHeight =
  686. (this._rectangleNortheastInMeters.y - this._rectangleSouthwestInMeters.y) /
  687. yTiles;
  688. const north = this._rectangleNortheastInMeters.y - y * yTileHeight;
  689. const south = this._rectangleNortheastInMeters.y - (y + 1) * yTileHeight;
  690. if (!Cesium.defined(result)) {
  691. return new Cesium.Rectangle(west, south, east, north);
  692. }
  693. result.west = west;
  694. result.south = south;
  695. result.east = east;
  696. result.north = north;
  697. return result;
  698. };
  699. /**
  700. * Converts tile x, y coordinates and level to a cartographic rectangle in radians.
  701. *
  702. * @param {Number} x The integer x coordinate of the tile.
  703. * @param {Number} y The integer y coordinate of the tile.
  704. * @param {Number} level The tile level-of-detail. Zero is the least detailed.
  705. * @param {Object} [result] The instance to which to copy the result, or undefined if a new instance
  706. * should be created.
  707. * @returns {Rectangle} The specified 'result', or a new object containing the rectangle
  708. * if 'result' is undefined.
  709. */
  710. SHmapMercatorTilingScheme.prototype.tileXYToRectangle = function (
  711. x,
  712. y,
  713. level,
  714. result
  715. ) {
  716. const nativeRectangle = this.tileXYToNativeRectangle(x, y, level, result);
  717. const projection = this._projection;
  718. const southwest = projection.unproject(
  719. new Cesium.Cartesian2(nativeRectangle.west, nativeRectangle.south)
  720. );
  721. const northeast = projection.unproject(
  722. new Cesium.Cartesian2(nativeRectangle.east, nativeRectangle.north)
  723. );
  724. nativeRectangle.west = southwest.longitude;
  725. nativeRectangle.south = southwest.latitude;
  726. nativeRectangle.east = northeast.longitude;
  727. nativeRectangle.north = northeast.latitude;
  728. return nativeRectangle;
  729. };
  730. /**
  731. * Calculates the tile x, y coordinates of the tile containing
  732. * a given cartographic position.
  733. *
  734. * @param {Cartographic} position The position.
  735. * @param {Number} level The tile level-of-detail. Zero is the least detailed.
  736. * @param {Cartesian2} [result] The instance to which to copy the result, or undefined if a new instance
  737. * should be created.
  738. * @returns {Cartesian2} The specified 'result', or a new object containing the tile x, y coordinates
  739. * if 'result' is undefined.
  740. */
  741. SHmapMercatorTilingScheme.prototype.positionToTileXY = function (
  742. position,
  743. level,
  744. result
  745. ) {
  746. const rectangle = this._rectangle;
  747. if (!Cesium.Rectangle.contains(rectangle, position)) {
  748. // outside the bounds of the tiling scheme
  749. return undefined;
  750. }
  751. const xTiles = this.getNumberOfXTilesAtLevel(level);
  752. const yTiles = this.getNumberOfYTilesAtLevel(level);
  753. const overallWidth =
  754. this._rectangleNortheastInMeters.x - this._rectangleSouthwestInMeters.x;
  755. const xTileWidth = overallWidth / xTiles;
  756. const overallHeight =
  757. this._rectangleNortheastInMeters.y - this._rectangleSouthwestInMeters.y;
  758. const yTileHeight = overallHeight / yTiles;
  759. const projection = this._projection;
  760. const webMercatorPosition = projection.project(position);
  761. const distanceFromWest =
  762. webMercatorPosition.x - this._rectangleSouthwestInMeters.x;
  763. const distanceFromNorth =
  764. this._rectangleNortheastInMeters.y - webMercatorPosition.y;
  765. let xTileCoordinate = (distanceFromWest / xTileWidth) | 0;
  766. if (xTileCoordinate >= xTiles) {
  767. xTileCoordinate = xTiles - 1;
  768. }
  769. let yTileCoordinate = (distanceFromNorth / yTileHeight) | 0;
  770. if (yTileCoordinate >= yTiles) {
  771. yTileCoordinate = yTiles - 1;
  772. }
  773. if (!Cesium.defined(result)) {
  774. return new Cesium.Cartesian2(xTileCoordinate, yTileCoordinate);
  775. }
  776. result.x = xTileCoordinate;
  777. result.y = yTileCoordinate;
  778. return result;
  779. }
  780. Cesium.SHmapMercatorTilingScheme = SHmapMercatorTilingScheme;
  781. /**
  782. * @typedef {Object} CGCS2000ArcGisMapServerImageryProvider.ConstructorOptions
  783. *
  784. * Initialization options for the CGCS2000ArcGisMapServerImageryProvider constructor
  785. *
  786. * @property {Resource|String} url The URL of the ArcGIS MapServer service.
  787. * @property {String} [token] The ArcGIS token used to authenticate with the ArcGIS MapServer service.
  788. * @property {TileDiscardPolicy} [tileDiscardPolicy] The policy that determines if a tile
  789. * is invalid and should be discarded. If this value is not specified, a default
  790. * {@link DiscardMissingTileImagePolicy} is used for tiled map servers, and a
  791. * {@link NeverTileDiscardPolicy} is used for non-tiled map servers. In the former case,
  792. * we request tile 0,0 at the maximum tile level and check pixels (0,0), (200,20), (20,200),
  793. * (80,110), and (160, 130). If all of these pixels are transparent, the discard check is
  794. * disabled and no tiles are discarded. If any of them have a non-transparent color, any
  795. * tile that has the same values in these pixel locations is discarded. The end result of
  796. * these defaults should be correct tile discarding for a standard ArcGIS Server. To ensure
  797. * that no tiles are discarded, construct and pass a {@link NeverTileDiscardPolicy} for this
  798. * parameter.
  799. * @property {Boolean} [usePreCachedTilesIfAvailable=true] If true, the server's pre-cached
  800. * tiles are used if they are available. If false, any pre-cached tiles are ignored and the
  801. * 'export' service is used.
  802. * @property {String} [layers] A comma-separated list of the layers to show, or undefined if all layers should be shown.
  803. * @property {Boolean} [enablePickFeatures=true] If true, {@link CGCS2000ArcGisMapServerImageryProvider#pickFeatures} will invoke
  804. * the Identify service on the MapServer and return the features included in the response. If false,
  805. * {@link CGCS2000ArcGisMapServerImageryProvider#pickFeatures} will immediately return undefined (indicating no pickable features)
  806. * without communicating with the server. Set this property to false if you don't want this provider's features to
  807. * be pickable. Can be overridden by setting the {@link CGCS2000ArcGisMapServerImageryProvider#enablePickFeatures} property on the object.
  808. * @property {Rectangle} [rectangle=Rectangle.MAX_VALUE] The rectangle of the layer. This parameter is ignored when accessing
  809. * a tiled layer.
  810. * @property {TilingScheme} [tilingScheme=new GeographicTilingScheme()] The tiling scheme to use to divide the world into tiles.
  811. * This parameter is ignored when accessing a tiled server.
  812. * @property {Ellipsoid} [ellipsoid] The ellipsoid. If the tilingScheme is specified and used,
  813. * this parameter is ignored and the tiling scheme's ellipsoid is used instead. If neither
  814. * parameter is specified, the WGS84 ellipsoid is used.
  815. * @property {Credit|String} [credit] A credit for the data source, which is displayed on the canvas. This parameter is ignored when accessing a tiled server.
  816. * @property {Number} [tileWidth=256] The width of each tile in pixels. This parameter is ignored when accessing a tiled server.
  817. * @property {Number} [tileHeight=256] The height of each tile in pixels. This parameter is ignored when accessing a tiled server.
  818. * @property {Number} [maximumLevel] The maximum tile level to request, or undefined if there is no maximum. This parameter is ignored when accessing
  819. * a tiled server.
  820. */
  821. /**
  822. * Provides tiled imagery hosted by an ArcGIS MapServer. By default, the server's pre-cached tiles are
  823. * used, if available.
  824. *
  825. * @alias CGCS2000ArcGisMapServerImageryProvider
  826. * @constructor
  827. *
  828. * @param {CGCS2000ArcGisMapServerImageryProvider.ConstructorOptions} options Object describing initialization options
  829. *
  830. * @see BingMapsImageryProvider
  831. * @see GoogleEarthEnterpriseMapsProvider
  832. * @see OpenStreetMapImageryProvider
  833. * @see SingleTileImageryProvider
  834. * @see TileMapServiceImageryProvider
  835. * @see WebMapServiceImageryProvider
  836. * @see WebMapTileServiceImageryProvider
  837. * @see UrlTemplateImageryProvider
  838. *
  839. *
  840. * @example
  841. * const esri = new Cesium.CGCS2000ArcGisMapServerImageryProvider({
  842. * url : 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer'
  843. * });
  844. *
  845. * @see {@link https://developers.arcgis.com/rest/|ArcGIS Server REST API}
  846. * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
  847. */
  848. function CGCS2000ArcGisMapServerImageryProvider(options) {
  849. options = Cesium.defaultValue(options, Cesium.defaultValue.EMPTY_OBJECT);
  850. //>>includeStart('debug', pragmas.debug);
  851. if (!Cesium.defined(options.url)) {
  852. throw new Cesium.DeveloperError("options.url is required.");
  853. }
  854. //>>includeEnd('debug');
  855. /**
  856. * The default alpha blending value of this provider, with 0.0 representing fully transparent and
  857. * 1.0 representing fully opaque.
  858. *
  859. * @type {Number|undefined}
  860. * @default undefined
  861. */
  862. this.defaultAlpha = undefined;
  863. /**
  864. * The default alpha blending value on the night side of the globe of this provider, with 0.0 representing fully transparent and
  865. * 1.0 representing fully opaque.
  866. *
  867. * @type {Number|undefined}
  868. * @default undefined
  869. */
  870. this.defaultNightAlpha = undefined;
  871. /**
  872. * The default alpha blending value on the day side of the globe of this provider, with 0.0 representing fully transparent and
  873. * 1.0 representing fully opaque.
  874. *
  875. * @type {Number|undefined}
  876. * @default undefined
  877. */
  878. this.defaultDayAlpha = undefined;
  879. /**
  880. * The default brightness of this provider. 1.0 uses the unmodified imagery color. Less than 1.0
  881. * makes the imagery darker while greater than 1.0 makes it brighter.
  882. *
  883. * @type {Number|undefined}
  884. * @default undefined
  885. */
  886. this.defaultBrightness = undefined;
  887. /**
  888. * The default contrast of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces
  889. * the contrast while greater than 1.0 increases it.
  890. *
  891. * @type {Number|undefined}
  892. * @default undefined
  893. */
  894. this.defaultContrast = undefined;
  895. /**
  896. * The default hue of this provider in radians. 0.0 uses the unmodified imagery color.
  897. *
  898. * @type {Number|undefined}
  899. * @default undefined
  900. */
  901. this.defaultHue = undefined;
  902. /**
  903. * The default saturation of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces the
  904. * saturation while greater than 1.0 increases it.
  905. *
  906. * @type {Number|undefined}
  907. * @default undefined
  908. */
  909. this.defaultSaturation = undefined;
  910. /**
  911. * The default gamma correction to apply to this provider. 1.0 uses the unmodified imagery color.
  912. *
  913. * @type {Number|undefined}
  914. * @default undefined
  915. */
  916. this.defaultGamma = undefined;
  917. /**
  918. * The default texture minification filter to apply to this provider.
  919. *
  920. * @type {TextureMinificationFilter}
  921. * @default undefined
  922. */
  923. this.defaultMinificationFilter = undefined;
  924. /**
  925. * The default texture magnification filter to apply to this provider.
  926. *
  927. * @type {TextureMagnificationFilter}
  928. * @default undefined
  929. */
  930. this.defaultMagnificationFilter = undefined;
  931. const resource = Cesium.Resource.createIfNeeded(options.url);
  932. resource.appendForwardSlash();
  933. if (Cesium.defined(options.token)) {
  934. resource.setQueryParameters({
  935. token: options.token,
  936. });
  937. }
  938. this._resource = resource;
  939. this._tileDiscardPolicy = options.tileDiscardPolicy;
  940. this._tileWidth = Cesium.defaultValue(options.tileWidth, 256);
  941. this._tileHeight = Cesium.defaultValue(options.tileHeight, 256);
  942. this._maximumLevel = options.maximumLevel;
  943. this._tilingScheme = Cesium.defaultValue(
  944. options.tilingScheme,
  945. new Cesium.SHmapMercatorTilingScheme()
  946. );
  947. this._useTiles = Cesium.defaultValue(options.usePreCachedTilesIfAvailable, true);
  948. this._rectangle = Cesium.defaultValue(
  949. options.rectangle,
  950. this._tilingScheme.rectangle
  951. );
  952. this._layers = options.layers;
  953. let credit = options.credit;
  954. if (typeof credit === "string") {
  955. credit = new Cesium.Credit(credit);
  956. }
  957. this._credit = credit;
  958. /**
  959. * Gets or sets a value indicating whether feature picking is enabled. If true, {@link CGCS2000ArcGisMapServerImageryProvider#pickFeatures} will
  960. * invoke the "identify" operation on the ArcGIS server and return the features included in the response. If false,
  961. * {@link CGCS2000ArcGisMapServerImageryProvider#pickFeatures} will immediately return undefined (indicating no pickable features)
  962. * without communicating with the server.
  963. * @type {Boolean}
  964. * @default true
  965. */
  966. this.enablePickFeatures = Cesium.defaultValue(options.enablePickFeatures, true);
  967. this._errorEvent = new Cesium.Event();
  968. this._ready = false;
  969. this._readyPromise = Cesium.defer();
  970. // Grab the details of this MapServer.
  971. const that = this;
  972. let metadataError;
  973. function metadataSuccess(data) {
  974. const tileInfo = data.tileInfo;
  975. if (!Cesium.defined(tileInfo)) {
  976. that._useTiles = false;
  977. } else if (!tileInfo.spatialReference.wkid) {
  978. that._useTiles = false;
  979. } else {
  980. that._tileWidth = tileInfo.rows;
  981. that._tileHeight = tileInfo.cols;
  982. if (!tileInfo.spatialReference.wkid) {
  983. tileInfo.spatialReference.wkid = 1001;
  984. }
  985. if (
  986. tileInfo.spatialReference.wkid === 102100 ||
  987. tileInfo.spatialReference.wkid === 102113
  988. ) {
  989. that._tilingScheme = new Cesium.SHmapMercatorTilingScheme();
  990. } else if (data.tileInfo.spatialReference.wkid === 4326) {
  991. that._tilingScheme = new Cesium.GeographicTilingScheme({
  992. ellipsoid: options.ellipsoid,
  993. });
  994. } else if (data.fullExtent.spatialReference.wkid === 4490 || data.fullExtent.spatialReference.wkid === 1001) {
  995. that._tilingScheme = new Cesium.GeographicTilingScheme({
  996. ellipsoid: options.ellipsoid,
  997. tileInfo: data.tileInfo,
  998. rectangle: that._rectangle
  999. });
  1000. that._tilingScheme._tileInfo = data.tileInfo; //附加自定义属性
  1001. } else {
  1002. const message = `Tile spatial reference WKID ${data.tileInfo.spatialReference.wkid} is not supported.`;
  1003. metadataError = Cesium.TileProviderError.reportError(
  1004. metadataError,
  1005. that,
  1006. that._errorEvent,
  1007. message,
  1008. undefined,
  1009. undefined,
  1010. undefined,
  1011. requestMetadata
  1012. );
  1013. if (!metadataError.retry) {
  1014. that._readyPromise.reject(new Cesium.RuntimeError(message));
  1015. }
  1016. return;
  1017. }
  1018. that._maximumLevel = data.tileInfo.lods.length - 1;
  1019. if (Cesium.defined(data.fullExtent)) {
  1020. if (
  1021. Cesium.defined(data.fullExtent.spatialReference) &&
  1022. Cesium.defined(data.fullExtent.spatialReference.wkid)
  1023. ) {
  1024. if (
  1025. data.fullExtent.spatialReference.wkid === 102100 ||
  1026. data.fullExtent.spatialReference.wkid === 102113
  1027. ) {
  1028. const projection = new Cesium.WebMercatorProjection();
  1029. const extent = data.fullExtent;
  1030. //{x: 13521978.544776667, y: 3662655.182794742}
  1031. // extent.xmin = extent.xmin + 13521978.544776667;
  1032. // extent.ymin = extent.ymin + 3662655.182794742;
  1033. extent.xmax = extent.xmax + 13521978.544776667;
  1034. extent.ymax = extent.ymax + 3662655.182794742;
  1035. const sw = projection.unproject(
  1036. new Cesium.Cartesian3(
  1037. Math.max(
  1038. extent.xmin,
  1039. -that._tilingScheme.ellipsoid.maximumRadius * Math.PI
  1040. ),
  1041. Math.max(
  1042. extent.ymin,
  1043. -that._tilingScheme.ellipsoid.maximumRadius * Math.PI
  1044. ),
  1045. 0.0
  1046. )
  1047. );
  1048. const ne = projection.unproject(
  1049. new Cesium.Cartesian3(
  1050. Math.min(
  1051. extent.xmax,
  1052. that._tilingScheme.ellipsoid.maximumRadius * Math.PI
  1053. ),
  1054. Math.min(
  1055. extent.ymax,
  1056. that._tilingScheme.ellipsoid.maximumRadius * Math.PI
  1057. ),
  1058. 0.0
  1059. )
  1060. );
  1061. that._rectangle = new Cesium.Rectangle(
  1062. sw.longitude,
  1063. sw.latitude,
  1064. ne.longitude,
  1065. ne.latitude
  1066. );
  1067. } else if (data.fullExtent.spatialReference.wkid === 4326 || data.fullExtent.spatialReference.wkid === 4490) {
  1068. that._rectangle = Cesium.Rectangle.fromDegrees(
  1069. data.fullExtent.xmin,
  1070. data.fullExtent.ymin,
  1071. data.fullExtent.xmax,
  1072. data.fullExtent.ymax
  1073. );
  1074. } else if (data.fullExtent.spatialReference.wkid === 1001) {
  1075. // var minlatlng = gaussToGeo(data.fullExtent.xmin, data.fullExtent.ymin, 121.2751921);
  1076. // console.log(minlatlng)
  1077. // var maxlatlng = gaussToGeo(data.fullExtent.xmax, data.fullExtent.ymax, 121.2751921);
  1078. that._rectangle = Cesium.Rectangle.fromDegrees(
  1079. 106.19840661411284,
  1080. 22.72534254352711,
  1081. 132.3724776782459,
  1082. 39.41964096043237
  1083. );
  1084. console.log(that._rectangle);
  1085. } else {
  1086. const extentMessage = `fullExtent.spatialReference WKID ${data.fullExtent.spatialReference.wkid} is not supported.`;
  1087. metadataError = Cesium.TileProviderError.reportError(
  1088. metadataError,
  1089. that,
  1090. that._errorEvent,
  1091. extentMessage,
  1092. undefined,
  1093. undefined,
  1094. undefined,
  1095. requestMetadata
  1096. );
  1097. if (!metadataError.retry) {
  1098. that._readyPromise.reject(new Cesium.RuntimeError(extentMessage));
  1099. }
  1100. return;
  1101. }
  1102. }
  1103. } else {
  1104. that._rectangle = that._tilingScheme.rectangle;
  1105. }
  1106. // Install the default tile discard policy if none has been supplied.
  1107. if (!Cesium.defined(that._tileDiscardPolicy)) {
  1108. that._tileDiscardPolicy = new Cesium.DiscardMissingTileImagePolicy({
  1109. missingImageUrl: buildImageResource(that, 0, 0, that._maximumLevel)
  1110. .url,
  1111. pixelsToCheck: [
  1112. new Cesium.Cartesian2(0, 0),
  1113. new Cesium.Cartesian2(200, 20),
  1114. new Cesium.Cartesian2(20, 200),
  1115. new Cesium.Cartesian2(80, 110),
  1116. new Cesium.Cartesian2(160, 130),
  1117. ],
  1118. disableCheckIfAllPixelsAreTransparent: true,
  1119. });
  1120. }
  1121. that._useTiles = true;
  1122. }
  1123. if (Cesium.defined(data.copyrightText) && data.copyrightText.length > 0) {
  1124. that._credit = new Cesium.Credit(data.copyrightText);
  1125. }
  1126. that._ready = true;
  1127. that._readyPromise.resolve(true);
  1128. Cesium.TileProviderError.reportSuccess(metadataError);
  1129. }
  1130. function metadataFailure(e) {
  1131. const message = `An error occurred while accessing ${that._resource.url}.`;
  1132. metadataError = Cesium.TileProviderError.reportError(
  1133. metadataError,
  1134. that,
  1135. that._errorEvent,
  1136. message,
  1137. undefined,
  1138. undefined,
  1139. undefined,
  1140. requestMetadata
  1141. );
  1142. that._readyPromise.reject(new Cesium.RuntimeError(message));
  1143. }
  1144. function requestMetadata() {
  1145. const resource = that._resource.getDerivedResource({
  1146. queryParameters: {
  1147. f: "json",
  1148. },
  1149. });
  1150. resource
  1151. .fetchJsonp()
  1152. .then(function (result) {
  1153. metadataSuccess(result);
  1154. })
  1155. .catch(function (e) {
  1156. metadataFailure(e);
  1157. });
  1158. }
  1159. if (this._useTiles) {
  1160. requestMetadata();
  1161. } else {
  1162. this._ready = true;
  1163. this._readyPromise.resolve(true);
  1164. }
  1165. }
  1166. function buildImageResource(imageryProvider, x, y, level, request) {
  1167. let resource;
  1168. if (imageryProvider._useTiles) {
  1169. resource = imageryProvider._resource.getDerivedResource({
  1170. url: `tile/${level}/${y}/${x}`,
  1171. request: request,
  1172. });
  1173. } else {
  1174. const nativeRectangle = imageryProvider._tilingScheme.tileXYToNativeRectangle(
  1175. x,
  1176. y,
  1177. level
  1178. );
  1179. const bbox = `${nativeRectangle.west},${nativeRectangle.south},${nativeRectangle.east},${nativeRectangle.north}`;
  1180. const query = {
  1181. bbox: bbox,
  1182. size: `${imageryProvider._tileWidth},${imageryProvider._tileHeight}`,
  1183. format: "png32",
  1184. transparent: true,
  1185. f: "image",
  1186. };
  1187. if (
  1188. imageryProvider._tilingScheme.projection instanceof Cesium.GeographicProjection
  1189. ) {
  1190. query.bboxSR = 4326;
  1191. query.imageSR = 4326;
  1192. } else {
  1193. query.bboxSR = 3857;
  1194. query.imageSR = 3857;
  1195. }
  1196. if (imageryProvider.layers) {
  1197. query.layers = `show:${imageryProvider.layers}`;
  1198. }
  1199. resource = imageryProvider._resource.getDerivedResource({
  1200. url: "export",
  1201. request: request,
  1202. queryParameters: query,
  1203. });
  1204. }
  1205. return resource;
  1206. }
  1207. Object.defineProperties(CGCS2000ArcGisMapServerImageryProvider.prototype, {
  1208. /**
  1209. * Gets the URL of the ArcGIS MapServer.
  1210. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1211. * @type {String}
  1212. * @readonly
  1213. */
  1214. url: {
  1215. get: function () {
  1216. return this._resource._url;
  1217. },
  1218. },
  1219. /**
  1220. * Gets the ArcGIS token used to authenticate with the ArcGis MapServer service.
  1221. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1222. * @type {String}
  1223. * @readonly
  1224. */
  1225. token: {
  1226. get: function () {
  1227. return this._resource.queryParameters.token;
  1228. },
  1229. },
  1230. /**
  1231. * Gets the proxy used by this provider.
  1232. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1233. * @type {Proxy}
  1234. * @readonly
  1235. */
  1236. proxy: {
  1237. get: function () {
  1238. return this._resource.proxy;
  1239. },
  1240. },
  1241. /**
  1242. * Gets the width of each tile, in pixels. This function should
  1243. * not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1244. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1245. * @type {Number}
  1246. * @readonly
  1247. */
  1248. tileWidth: {
  1249. get: function () {
  1250. //>>includeStart('debug', pragmas.debug);
  1251. if (!this._ready) {
  1252. throw new Cesium.DeveloperError(
  1253. "tileWidth must not be called before the imagery provider is ready."
  1254. );
  1255. }
  1256. //>>includeEnd('debug');
  1257. return this._tileWidth;
  1258. },
  1259. },
  1260. /**
  1261. * Gets the height of each tile, in pixels. This function should
  1262. * not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1263. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1264. * @type {Number}
  1265. * @readonly
  1266. */
  1267. tileHeight: {
  1268. get: function () {
  1269. //>>includeStart('debug', pragmas.debug);
  1270. if (!this._ready) {
  1271. throw new Cesium.DeveloperError(
  1272. "tileHeight must not be called before the imagery provider is ready."
  1273. );
  1274. }
  1275. //>>includeEnd('debug');
  1276. return this._tileHeight;
  1277. },
  1278. },
  1279. /**
  1280. * Gets the maximum level-of-detail that can be requested. This function should
  1281. * not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1282. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1283. * @type {Number|undefined}
  1284. * @readonly
  1285. */
  1286. maximumLevel: {
  1287. get: function () {
  1288. //>>includeStart('debug', pragmas.debug);
  1289. if (!this._ready) {
  1290. throw new Cesium.DeveloperError(
  1291. "maximumLevel must not be called before the imagery provider is ready."
  1292. );
  1293. }
  1294. //>>includeEnd('debug');
  1295. return this._maximumLevel;
  1296. },
  1297. },
  1298. /**
  1299. * Gets the minimum level-of-detail that can be requested. This function should
  1300. * not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1301. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1302. * @type {Number}
  1303. * @readonly
  1304. */
  1305. minimumLevel: {
  1306. get: function () {
  1307. //>>includeStart('debug', pragmas.debug);
  1308. if (!this._ready) {
  1309. throw new Cesium.DeveloperError(
  1310. "minimumLevel must not be called before the imagery provider is ready."
  1311. );
  1312. }
  1313. //>>includeEnd('debug');
  1314. return 0;
  1315. },
  1316. },
  1317. /**
  1318. * Gets the tiling scheme used by this provider. This function should
  1319. * not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1320. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1321. * @type {TilingScheme}
  1322. * @readonly
  1323. */
  1324. tilingScheme: {
  1325. get: function () {
  1326. //>>includeStart('debug', pragmas.debug);
  1327. if (!this._ready) {
  1328. throw new Cesium.DeveloperError(
  1329. "tilingScheme must not be called before the imagery provider is ready."
  1330. );
  1331. }
  1332. //>>includeEnd('debug');
  1333. return this._tilingScheme;
  1334. },
  1335. },
  1336. /**
  1337. * Gets the rectangle, in radians, of the imagery provided by this instance. This function should
  1338. * not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1339. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1340. * @type {Rectangle}
  1341. * @readonly
  1342. */
  1343. rectangle: {
  1344. get: function () {
  1345. //>>includeStart('debug', pragmas.debug);
  1346. if (!this._ready) {
  1347. throw new Cesium.DeveloperError(
  1348. "rectangle must not be called before the imagery provider is ready."
  1349. );
  1350. }
  1351. //>>includeEnd('debug');
  1352. return this._rectangle;
  1353. },
  1354. },
  1355. /**
  1356. * Gets the tile discard policy. If not undefined, the discard policy is responsible
  1357. * for filtering out "missing" tiles via its shouldDiscardImage function. If this function
  1358. * returns undefined, no tiles are filtered. This function should
  1359. * not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1360. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1361. * @type {TileDiscardPolicy}
  1362. * @readonly
  1363. */
  1364. tileDiscardPolicy: {
  1365. get: function () {
  1366. //>>includeStart('debug', pragmas.debug);
  1367. if (!this._ready) {
  1368. throw new Cesium.DeveloperError(
  1369. "tileDiscardPolicy must not be called before the imagery provider is ready."
  1370. );
  1371. }
  1372. //>>includeEnd('debug');
  1373. return this._tileDiscardPolicy;
  1374. },
  1375. },
  1376. /**
  1377. * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
  1378. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  1379. * are passed an instance of {@link TileProviderError}.
  1380. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1381. * @type {Event}
  1382. * @readonly
  1383. */
  1384. errorEvent: {
  1385. get: function () {
  1386. return this._errorEvent;
  1387. },
  1388. },
  1389. /**
  1390. * Gets a value indicating whether or not the provider is ready for use.
  1391. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1392. * @type {Boolean}
  1393. * @readonly
  1394. */
  1395. ready: {
  1396. get: function () {
  1397. return this._ready;
  1398. },
  1399. },
  1400. /**
  1401. * Gets a promise that resolves to true when the provider is ready for use.
  1402. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1403. * @type {Promise.<Boolean>}
  1404. * @readonly
  1405. */
  1406. readyPromise: {
  1407. get: function () {
  1408. return this._readyPromise.promise;
  1409. },
  1410. },
  1411. /**
  1412. * Gets the credit to display when this imagery provider is active. Typically this is used to credit
  1413. * the source of the imagery. This function should not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1414. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1415. * @type {Credit}
  1416. * @readonly
  1417. */
  1418. credit: {
  1419. get: function () {
  1420. return this._credit;
  1421. },
  1422. },
  1423. /**
  1424. * Gets a value indicating whether this imagery provider is using pre-cached tiles from the
  1425. * ArcGIS MapServer. If the imagery provider is not yet ready ({@link CGCS2000ArcGisMapServerImageryProvider#ready}), this function
  1426. * will return the value of `options.usePreCachedTilesIfAvailable`, even if the MapServer does
  1427. * not have pre-cached tiles.
  1428. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1429. *
  1430. * @type {Boolean}
  1431. * @readonly
  1432. * @default true
  1433. */
  1434. usingPrecachedTiles: {
  1435. get: function () {
  1436. return this._useTiles;
  1437. },
  1438. },
  1439. /**
  1440. * Gets a value indicating whether or not the images provided by this imagery provider
  1441. * include an alpha channel. If this property is false, an alpha channel, if present, will
  1442. * be ignored. If this property is true, any images without an alpha channel will be treated
  1443. * as if their alpha is 1.0 everywhere. When this property is false, memory usage
  1444. * and texture upload time are reduced.
  1445. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1446. *
  1447. * @type {Boolean}
  1448. * @readonly
  1449. * @default true
  1450. */
  1451. hasAlphaChannel: {
  1452. get: function () {
  1453. return true;
  1454. },
  1455. },
  1456. /**
  1457. * Gets the comma-separated list of layer IDs to show.
  1458. * @memberof CGCS2000ArcGisMapServerImageryProvider.prototype
  1459. *
  1460. * @type {String}
  1461. */
  1462. layers: {
  1463. get: function () {
  1464. return this._layers;
  1465. },
  1466. },
  1467. });
  1468. /**
  1469. * Gets the credits to be displayed when a given tile is displayed.
  1470. *
  1471. * @param {Number} x The tile X coordinate.
  1472. * @param {Number} y The tile Y coordinate.
  1473. * @param {Number} level The tile level;
  1474. * @returns {Credit[]} The credits to be displayed when the tile is displayed.
  1475. *
  1476. * @exception {DeveloperError} <code>getTileCredits</code> must not be called before the imagery provider is ready.
  1477. */
  1478. CGCS2000ArcGisMapServerImageryProvider.prototype.getTileCredits = function (
  1479. x,
  1480. y,
  1481. level
  1482. ) {
  1483. return undefined;
  1484. };
  1485. /**
  1486. * Requests the image for a given tile. This function should
  1487. * not be called before {@link CGCS2000ArcGisMapServerImageryProvider#ready} returns true.
  1488. *
  1489. * @param {Number} x The tile X coordinate.
  1490. * @param {Number} y The tile Y coordinate.
  1491. * @param {Number} level The tile level.
  1492. * @param {Request} [request] The request object. Intended for internal use only.
  1493. * @returns {Promise.<HTMLImageElement|HTMLCanvasElement>|undefined} A promise for the image that will resolve when the image is available, or
  1494. * undefined if there are too many active requests to the server, and the request
  1495. * should be retried later. The resolved image may be either an
  1496. * Image or a Canvas DOM object.
  1497. *
  1498. * @exception {DeveloperError} <code>requestImage</code> must not be called before the imagery provider is ready.
  1499. */
  1500. CGCS2000ArcGisMapServerImageryProvider.prototype.requestImage = function (
  1501. x,
  1502. y,
  1503. level,
  1504. request
  1505. ) {
  1506. //>>includeStart('debug', pragmas.debug);
  1507. if (!this._ready) {
  1508. throw new Cesium.DeveloperError(
  1509. "requestImage must not be called before the imagery provider is ready."
  1510. );
  1511. }
  1512. //>>includeEnd('debug');
  1513. level = level;
  1514. return Cesium.ImageryProvider.loadImage(
  1515. this,
  1516. buildImageResource(this, x, y, level, request)
  1517. );
  1518. };
  1519. /**
  1520. /**
  1521. * Asynchronously determines what features, if any, are located at a given longitude and latitude within
  1522. * a tile. This function should not be called before {@link ImageryProvider#ready} returns true.
  1523. *
  1524. * @param {Number} x The tile X coordinate.
  1525. * @param {Number} y The tile Y coordinate.
  1526. * @param {Number} level The tile level.
  1527. * @param {Number} longitude The longitude at which to pick features.
  1528. * @param {Number} latitude The latitude at which to pick features.
  1529. * @return {Promise.<ImageryLayerFeatureInfo[]>|undefined} A promise for the picked features that will resolve when the asynchronous
  1530. * picking completes. The resolved value is an array of {@link ImageryLayerFeatureInfo}
  1531. * instances. The array may be empty if no features are found at the given location.
  1532. *
  1533. * @exception {DeveloperError} <code>pickFeatures</code> must not be called before the imagery provider is ready.
  1534. */
  1535. CGCS2000ArcGisMapServerImageryProvider.prototype.pickFeatures = function (
  1536. x,
  1537. y,
  1538. level,
  1539. longitude,
  1540. latitude
  1541. ) {
  1542. //>>includeStart('debug', pragmas.debug);
  1543. if (!this._ready) {
  1544. throw new Cesium.DeveloperError(
  1545. "pickFeatures must not be called before the imagery provider is ready."
  1546. );
  1547. }
  1548. //>>includeEnd('debug');
  1549. if (!this.enablePickFeatures) {
  1550. return undefined;
  1551. }
  1552. const rectangle = this._tilingScheme.tileXYToNativeRectangle(x, y, level);
  1553. let horizontal;
  1554. let vertical;
  1555. let sr;
  1556. if (this._tilingScheme.projection instanceof Cesium.GeographicProjection) {
  1557. horizontal = Cesium.Math.toDegrees(longitude);
  1558. vertical = Cesium.Math.toDegrees(latitude);
  1559. sr = "4326";
  1560. } else {
  1561. const projected = this._tilingScheme.projection.project(
  1562. new Cesium.Cartographic(longitude, latitude, 0.0)
  1563. );
  1564. horizontal = projected.x;
  1565. vertical = projected.y;
  1566. sr = "3857";
  1567. }
  1568. let layers = "visible";
  1569. if (Cesium.defined(this._layers)) {
  1570. layers += `:${this._layers}`;
  1571. }
  1572. const query = {
  1573. f: "json",
  1574. tolerance: 2,
  1575. geometryType: "esriGeometryPoint",
  1576. geometry: `${horizontal},${vertical}`,
  1577. mapExtent: `${rectangle.west},${rectangle.south},${rectangle.east},${rectangle.north}`,
  1578. imageDisplay: `${this._tileWidth},${this._tileHeight},96`,
  1579. sr: sr,
  1580. layers: layers,
  1581. };
  1582. const resource = this._resource.getDerivedResource({
  1583. url: "identify",
  1584. queryParameters: query,
  1585. });
  1586. return resource.fetchJson().then(function (json) {
  1587. const result = [];
  1588. const features = json.results;
  1589. if (!Cesium.defined(features)) {
  1590. return result;
  1591. }
  1592. for (let i = 0; i < features.length; ++i) {
  1593. const feature = features[i];
  1594. const featureInfo = new Cesium.ImageryLayerFeatureInfo();
  1595. featureInfo.data = feature;
  1596. featureInfo.name = feature.value;
  1597. featureInfo.properties = feature.attributes;
  1598. featureInfo.configureDescriptionFromProperties(feature.attributes);
  1599. // If this is a point feature, use the coordinates of the point.
  1600. if (feature.geometryType === "esriGeometryPoint" && feature.geometry) {
  1601. const wkid =
  1602. feature.geometry.spatialReference &&
  1603. feature.geometry.spatialReference.wkid ?
  1604. feature.geometry.spatialReference.wkid :
  1605. 4326;
  1606. if (wkid === 4326 || wkid === 4283) {
  1607. featureInfo.position = Cesium.Cartographic.fromDegrees(
  1608. feature.geometry.x,
  1609. feature.geometry.y,
  1610. feature.geometry.z
  1611. );
  1612. } else if (wkid === 102100 || wkid === 900913 || wkid === 3857) {
  1613. const projection = new Cesium.WebMercatorProjection();
  1614. featureInfo.position = projection.unproject(
  1615. new Cesium.Cartesian3(
  1616. feature.geometry.x,
  1617. feature.geometry.y,
  1618. feature.geometry.z
  1619. )
  1620. );
  1621. }
  1622. }
  1623. result.push(featureInfo);
  1624. }
  1625. return result;
  1626. });
  1627. };
  1628. Cesium.CGCS2000ArcGisMapServerImageryProvider = CGCS2000ArcGisMapServerImageryProvider;
  1629. Cesium.changeCoor = function (name, lon, lat) {
  1630. if (name == "wgs84_to_shcj")
  1631. return coordinate.wgs84_to_shcj(lon, lat);
  1632. }
  1633. }(Cesium));