common_wasm_bg.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. let wasm;
  2. export function __wbg_set_wasm(val) {
  3. wasm = val;
  4. }
  5. const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
  6. let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
  7. cachedTextDecoder.decode();
  8. let cachedUint8Memory0 = null;
  9. function getUint8Memory0() {
  10. if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
  11. cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
  12. }
  13. return cachedUint8Memory0;
  14. }
  15. function getStringFromWasm0(ptr, len) {
  16. return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
  17. }
  18. const heap = new Array(128).fill(undefined);
  19. heap.push(undefined, null, true, false);
  20. let heap_next = heap.length;
  21. function addHeapObject(obj) {
  22. if (heap_next === heap.length) heap.push(heap.length + 1);
  23. const idx = heap_next;
  24. heap_next = heap[idx];
  25. heap[idx] = obj;
  26. return idx;
  27. }
  28. function getObject(idx) { return heap[idx]; }
  29. function dropObject(idx) {
  30. if (idx < 132) return;
  31. heap[idx] = heap_next;
  32. heap_next = idx;
  33. }
  34. function takeObject(idx) {
  35. const ret = getObject(idx);
  36. dropObject(idx);
  37. return ret;
  38. }
  39. /**
  40. */
  41. export function greet() {
  42. wasm.greet();
  43. }
  44. let WASM_VECTOR_LEN = 0;
  45. function passArray8ToWasm0(arg, malloc) {
  46. const ptr = malloc(arg.length * 1);
  47. getUint8Memory0().set(arg, ptr / 1);
  48. WASM_VECTOR_LEN = arg.length;
  49. return ptr;
  50. }
  51. let cachedInt32Memory0 = null;
  52. function getInt32Memory0() {
  53. if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
  54. cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
  55. }
  56. return cachedInt32Memory0;
  57. }
  58. /**
  59. * 解析地图包Zip
  60. * @param {Uint8Array} data
  61. * @returns {MapPackage}
  62. */
  63. export function parse_map_package(data) {
  64. try {
  65. const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
  66. const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
  67. const len0 = WASM_VECTOR_LEN;
  68. wasm.parse_map_package(retptr, ptr0, len0);
  69. var r0 = getInt32Memory0()[retptr / 4 + 0];
  70. var r1 = getInt32Memory0()[retptr / 4 + 1];
  71. var r2 = getInt32Memory0()[retptr / 4 + 2];
  72. if (r2) {
  73. throw takeObject(r1);
  74. }
  75. return MapPackage.__wrap(r0);
  76. } finally {
  77. wasm.__wbindgen_add_to_stack_pointer(16);
  78. }
  79. }
  80. function _assertClass(instance, klass) {
  81. if (!(instance instanceof klass)) {
  82. throw new Error(`expected instance of ${klass.name}`);
  83. }
  84. return instance.ptr;
  85. }
  86. function getArrayU8FromWasm0(ptr, len) {
  87. return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
  88. }
  89. const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
  90. let cachedTextEncoder = new lTextEncoder('utf-8');
  91. const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
  92. ? function (arg, view) {
  93. return cachedTextEncoder.encodeInto(arg, view);
  94. }
  95. : function (arg, view) {
  96. const buf = cachedTextEncoder.encode(arg);
  97. view.set(buf);
  98. return {
  99. read: arg.length,
  100. written: buf.length
  101. };
  102. });
  103. function passStringToWasm0(arg, malloc, realloc) {
  104. if (realloc === undefined) {
  105. const buf = cachedTextEncoder.encode(arg);
  106. const ptr = malloc(buf.length);
  107. getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
  108. WASM_VECTOR_LEN = buf.length;
  109. return ptr;
  110. }
  111. let len = arg.length;
  112. let ptr = malloc(len);
  113. const mem = getUint8Memory0();
  114. let offset = 0;
  115. for (; offset < len; offset++) {
  116. const code = arg.charCodeAt(offset);
  117. if (code > 0x7F) break;
  118. mem[ptr + offset] = code;
  119. }
  120. if (offset !== len) {
  121. if (offset !== 0) {
  122. arg = arg.slice(offset);
  123. }
  124. ptr = realloc(ptr, len, len = offset + arg.length * 3);
  125. const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
  126. const ret = encodeString(arg, view);
  127. offset += ret.written;
  128. }
  129. WASM_VECTOR_LEN = offset;
  130. return ptr;
  131. }
  132. /**
  133. */
  134. export class MapPackage {
  135. static __wrap(ptr) {
  136. const obj = Object.create(MapPackage.prototype);
  137. obj.ptr = ptr;
  138. return obj;
  139. }
  140. __destroy_into_raw() {
  141. const ptr = this.ptr;
  142. this.ptr = 0;
  143. return ptr;
  144. }
  145. free() {
  146. const ptr = this.__destroy_into_raw();
  147. wasm.__wbg_mappackage_free(ptr);
  148. }
  149. /**
  150. * 地图图片格式
  151. * @returns {string}
  152. */
  153. get map_ext() {
  154. try {
  155. const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
  156. wasm.mappackage_map_ext(retptr, this.ptr);
  157. var r0 = getInt32Memory0()[retptr / 4 + 0];
  158. var r1 = getInt32Memory0()[retptr / 4 + 1];
  159. return getStringFromWasm0(r0, r1);
  160. } finally {
  161. wasm.__wbindgen_add_to_stack_pointer(16);
  162. wasm.__wbindgen_free(r0, r1);
  163. }
  164. }
  165. /**
  166. * 地图原始像素尺寸
  167. * @returns {Size}
  168. */
  169. get src_size() {
  170. const ret = wasm.mappackage_src_size(this.ptr);
  171. return Size.__wrap(ret);
  172. }
  173. /**
  174. * 地图缩放后后像素尺寸,用于计算新尺寸下地理坐标
  175. * @param {Size} size
  176. */
  177. set dst_size(size) {
  178. _assertClass(size, Size);
  179. var ptr0 = size.__destroy_into_raw();
  180. wasm.mappackage_set_dst_size(this.ptr, ptr0);
  181. }
  182. /**
  183. * 地图图片
  184. * @returns {Uint8Array}
  185. */
  186. get map_image_data() {
  187. try {
  188. const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
  189. wasm.mappackage_map_image_data(retptr, this.ptr);
  190. var r0 = getInt32Memory0()[retptr / 4 + 0];
  191. var r1 = getInt32Memory0()[retptr / 4 + 1];
  192. var v0 = getArrayU8FromWasm0(r0, r1).slice();
  193. wasm.__wbindgen_free(r0, r1 * 1);
  194. return v0;
  195. } finally {
  196. wasm.__wbindgen_add_to_stack_pointer(16);
  197. }
  198. }
  199. /**
  200. * 图上坐标转经纬度
  201. * @param {Offset} on_pic
  202. * @returns {Position}
  203. */
  204. pic_to_position(on_pic) {
  205. _assertClass(on_pic, Offset);
  206. var ptr0 = on_pic.__destroy_into_raw();
  207. const ret = wasm.mappackage_pic_to_position(this.ptr, ptr0);
  208. return Position.__wrap(ret);
  209. }
  210. /**
  211. * 经纬度转图上坐标
  212. * @param {Position} position
  213. * @returns {Offset}
  214. */
  215. position_to_pic(position) {
  216. _assertClass(position, Position);
  217. var ptr0 = position.__destroy_into_raw();
  218. const ret = wasm.mappackage_position_to_pic(this.ptr, ptr0);
  219. return Offset.__wrap(ret);
  220. }
  221. }
  222. /**
  223. * 点在图片上的坐标,原点为左上角
  224. */
  225. export class Offset {
  226. static __wrap(ptr) {
  227. const obj = Object.create(Offset.prototype);
  228. obj.ptr = ptr;
  229. return obj;
  230. }
  231. __destroy_into_raw() {
  232. const ptr = this.ptr;
  233. this.ptr = 0;
  234. return ptr;
  235. }
  236. free() {
  237. const ptr = this.__destroy_into_raw();
  238. wasm.__wbg_offset_free(ptr);
  239. }
  240. /**
  241. * @returns {number}
  242. */
  243. get x() {
  244. const ret = wasm.__wbg_get_offset_x(this.ptr);
  245. return ret;
  246. }
  247. /**
  248. * @param {number} arg0
  249. */
  250. set x(arg0) {
  251. wasm.__wbg_set_offset_x(this.ptr, arg0);
  252. }
  253. /**
  254. * @returns {number}
  255. */
  256. get y() {
  257. const ret = wasm.__wbg_get_offset_y(this.ptr);
  258. return ret;
  259. }
  260. /**
  261. * @param {number} arg0
  262. */
  263. set y(arg0) {
  264. wasm.__wbg_set_offset_y(this.ptr, arg0);
  265. }
  266. /**
  267. */
  268. constructor() {
  269. const ret = wasm.offset_new();
  270. return Offset.__wrap(ret);
  271. }
  272. }
  273. /**
  274. */
  275. export class Position {
  276. static __wrap(ptr) {
  277. const obj = Object.create(Position.prototype);
  278. obj.ptr = ptr;
  279. return obj;
  280. }
  281. __destroy_into_raw() {
  282. const ptr = this.ptr;
  283. this.ptr = 0;
  284. return ptr;
  285. }
  286. free() {
  287. const ptr = this.__destroy_into_raw();
  288. wasm.__wbg_position_free(ptr);
  289. }
  290. /**
  291. * @returns {number}
  292. */
  293. get latitude() {
  294. const ret = wasm.__wbg_get_offset_x(this.ptr);
  295. return ret;
  296. }
  297. /**
  298. * @param {number} arg0
  299. */
  300. set latitude(arg0) {
  301. wasm.__wbg_set_offset_x(this.ptr, arg0);
  302. }
  303. /**
  304. * @returns {number}
  305. */
  306. get longitude() {
  307. const ret = wasm.__wbg_get_offset_y(this.ptr);
  308. return ret;
  309. }
  310. /**
  311. * @param {number} arg0
  312. */
  313. set longitude(arg0) {
  314. wasm.__wbg_set_offset_y(this.ptr, arg0);
  315. }
  316. /**
  317. */
  318. constructor() {
  319. const ret = wasm.offset_new();
  320. return Position.__wrap(ret);
  321. }
  322. /**
  323. * 计算两点距离,单位:米
  324. * @param {Position} other
  325. * @returns {number}
  326. */
  327. distance_to(other) {
  328. _assertClass(other, Position);
  329. var ptr0 = other.__destroy_into_raw();
  330. const ret = wasm.position_distance_to(this.ptr, ptr0);
  331. return ret;
  332. }
  333. }
  334. /**
  335. */
  336. export class Size {
  337. static __wrap(ptr) {
  338. const obj = Object.create(Size.prototype);
  339. obj.ptr = ptr;
  340. return obj;
  341. }
  342. __destroy_into_raw() {
  343. const ptr = this.ptr;
  344. this.ptr = 0;
  345. return ptr;
  346. }
  347. free() {
  348. const ptr = this.__destroy_into_raw();
  349. wasm.__wbg_size_free(ptr);
  350. }
  351. /**
  352. * @returns {number}
  353. */
  354. get width() {
  355. const ret = wasm.__wbg_get_offset_x(this.ptr);
  356. return ret;
  357. }
  358. /**
  359. * @param {number} arg0
  360. */
  361. set width(arg0) {
  362. wasm.__wbg_set_offset_x(this.ptr, arg0);
  363. }
  364. /**
  365. * @returns {number}
  366. */
  367. get height() {
  368. const ret = wasm.__wbg_get_offset_y(this.ptr);
  369. return ret;
  370. }
  371. /**
  372. * @param {number} arg0
  373. */
  374. set height(arg0) {
  375. wasm.__wbg_set_offset_y(this.ptr, arg0);
  376. }
  377. /**
  378. */
  379. constructor() {
  380. const ret = wasm.offset_new();
  381. return Size.__wrap(ret);
  382. }
  383. }
  384. export function __wbg_alert_43a45fac7dbd48cc(arg0, arg1) {
  385. alert(getStringFromWasm0(arg0, arg1));
  386. };
  387. export function __wbindgen_error_new(arg0, arg1) {
  388. const ret = new Error(getStringFromWasm0(arg0, arg1));
  389. return addHeapObject(ret);
  390. };
  391. export function __wbg_new_abda76e883ba8a5f() {
  392. const ret = new Error();
  393. return addHeapObject(ret);
  394. };
  395. export function __wbg_stack_658279fe44541cf6(arg0, arg1) {
  396. const ret = getObject(arg1).stack;
  397. const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
  398. const len0 = WASM_VECTOR_LEN;
  399. getInt32Memory0()[arg0 / 4 + 1] = len0;
  400. getInt32Memory0()[arg0 / 4 + 0] = ptr0;
  401. };
  402. export function __wbg_error_f851667af71bcfc6(arg0, arg1) {
  403. try {
  404. console.error(getStringFromWasm0(arg0, arg1));
  405. } finally {
  406. wasm.__wbindgen_free(arg0, arg1);
  407. }
  408. };
  409. export function __wbindgen_object_drop_ref(arg0) {
  410. takeObject(arg0);
  411. };
  412. export function __wbindgen_throw(arg0, arg1) {
  413. throw new Error(getStringFromWasm0(arg0, arg1));
  414. };