m4-w-fast 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -1
- package/dist/index.cjs +1 -6533
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -6531
- package/dist/intersect.worker.js +9 -9
- package/dist/isoBands.worker.js +1 -1
- package/dist/leaflet/leafletLayer.d.ts +8 -0
- package/dist/leaflet/leafletLayer.js +1 -0
- package/dist/leaflet/types.d.ts +42 -0
- package/dist/leaflet/types.js +1 -0
- package/dist/m4-w-fast.umd.js +1 -1
- package/dist/raster-overlay/color.d.ts +11 -0
- package/dist/raster-overlay/color.js +1 -0
- package/dist/raster-overlay/core.d.ts +31 -0
- package/dist/raster-overlay/core.js +1 -0
- package/dist/raster-overlay/index.cjs +2 -0
- package/dist/raster-overlay/index.d.ts +4 -0
- package/dist/raster-overlay/index.js +1 -0
- package/dist/raster-overlay/index.mjs +2 -0
- package/dist/raster-overlay/leaflet-renderers/cpuRenderer.d.ts +0 -0
- package/dist/raster-overlay/leaflet-renderers/cpuRenderer.js +1 -0
- package/dist/raster-overlay/leaflet-renderers/createRenderer.d.ts +3 -0
- package/dist/raster-overlay/leaflet-renderers/createRenderer.js +1 -0
- package/dist/raster-overlay/leaflet-renderers/renderer.d.ts +51 -0
- package/dist/raster-overlay/leaflet-renderers/renderer.js +1 -0
- package/dist/raster-overlay/leaflet-renderers/webgl2Renderer.d.ts +74 -0
- package/dist/raster-overlay/leaflet-renderers/webgl2Renderer.js +1 -0
- package/dist/raster-overlay/leaflet-renderers/webglRenderer.d.ts +0 -0
- package/dist/raster-overlay/leaflet-renderers/webglRenderer.js +1 -0
- package/dist/raster-overlay/leaflet-renderers/webgpuRenderer.d.ts +0 -0
- package/dist/raster-overlay/leaflet-renderers/webgpuRenderer.js +1 -0
- package/dist/raster-overlay/leafletLayer.d.ts +48 -0
- package/dist/raster-overlay/leafletLayer.js +1 -0
- package/dist/raster-overlay/m4-w-raster-overlay.umd.js +2 -0
- package/dist/raster-overlay/types.d.ts +114 -0
- package/dist/raster-overlay/types.js +1 -0
- package/dist/readFile.d.ts +7 -1
- package/dist/readFile.js +1 -1
- package/dist/types.d.ts +6 -0
- package/package.json +12 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RasterColorStopInput, RasterColorStop } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 归一化到 0-1的rgba
|
|
4
|
+
* @param colorStops
|
|
5
|
+
*/
|
|
6
|
+
export declare const normalizeColorStops: (colorStops: RasterColorStopInput[]) => RasterColorStop[];
|
|
7
|
+
/**
|
|
8
|
+
* 解析颜色
|
|
9
|
+
* @param color
|
|
10
|
+
*/
|
|
11
|
+
export declare const parseRasterColor: (color: string) => RasterColorStop["color"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _0x42d4b2=_0x3e5b;(function(_0x5beee4,_0xeb88f3){const _0x333882=_0x3e5b,_0x2ab9e7=_0x5beee4();while(!![]){try{const _0x290bb4=-parseInt(_0x333882(0x175))/0x1*(-parseInt(_0x333882(0x16b))/0x2)+parseInt(_0x333882(0x169))/0x3+-parseInt(_0x333882(0x17d))/0x4*(parseInt(_0x333882(0x17f))/0x5)+-parseInt(_0x333882(0x180))/0x6*(parseInt(_0x333882(0x185))/0x7)+parseInt(_0x333882(0x186))/0x8*(parseInt(_0x333882(0x16a))/0x9)+parseInt(_0x333882(0x16c))/0xa+-parseInt(_0x333882(0x16f))/0xb;if(_0x290bb4===_0xeb88f3)break;else _0x2ab9e7['push'](_0x2ab9e7['shift']());}catch(_0x2475a0){_0x2ab9e7['push'](_0x2ab9e7['shift']());}}}(_0x2467,0xa564b));function _0x3e5b(_0x559cde,_0x1dacd3){const _0x2467ab=_0x2467();return _0x3e5b=function(_0x3e5bb9,_0x466e2b){_0x3e5bb9=_0x3e5bb9-0x168;let _0x4df4c5=_0x2467ab[_0x3e5bb9];return _0x4df4c5;},_0x3e5b(_0x559cde,_0x1dacd3);}export const normalizeColorStops=_0x3aebc6=>{const _0x358957=_0x3e5b;if(_0x3aebc6[_0x358957(0x17e)]===0x0)throw new Error('colorStops\x20不能为空');return _0x3aebc6['map']((_0x4d7f4f,_0x1a9da1)=>{const _0x14a106=_0x358957;if(Number[_0x14a106(0x171)](_0x4d7f4f['min'])||Number['isNaN'](_0x4d7f4f[_0x14a106(0x172)]))throw new TypeError('第'+(_0x1a9da1+0x1)+_0x14a106(0x17b));if(_0x4d7f4f['min']>=_0x4d7f4f[_0x14a106(0x172)])throw new Error('第'+(_0x1a9da1+0x1)+_0x14a106(0x183));return{'min':_0x4d7f4f[_0x14a106(0x179)],'max':_0x4d7f4f[_0x14a106(0x172)],'color':parseRasterColor(_0x4d7f4f['color'])};})[_0x358957(0x16e)]((_0x1d8af2,_0x2b10e7)=>_0x1d8af2[_0x358957(0x179)]-_0x2b10e7['min']);};function _0x2467(){const _0x4e7a7c=['4cgkGSX','length','2035135vEvIRc','282uNNeTe','trim','startsWith','个色标范围的\x20min\x20必须小于\x20max','slice','105861pCPqKQ','3821424LQoQSr','RGB\x20颜色通道必须在\x200\x20~\x20255\x20之间','2758596uvsdmE','18pqyGzz','371226xGzXnY','533630UwIezx','不支持的颜色格式:\x20','sort','9629884EpVwWT','match','isNaN','max','split','parseInt','4XMUMkb','isFinite','rgb(','toLowerCase','min','Alpha\x20颜色通道必须在0\x20~\x201之间','个色标范围不能是NaN','map'];_0x2467=function(){return _0x4e7a7c;};return _0x2467();}export const parseRasterColor=_0x2d0aa1=>{const _0x1bd600=_0x3e5b,_0x41f1f3=_0x2d0aa1[_0x1bd600(0x181)]()[_0x1bd600(0x178)]();if(_0x41f1f3[_0x1bd600(0x182)]('#'))return parseHexColor(_0x41f1f3);if(_0x41f1f3[_0x1bd600(0x182)]('rgba('))return parseRgbColor(_0x41f1f3,!![]);if(_0x41f1f3['startsWith'](_0x1bd600(0x177)))return parseRgbColor(_0x41f1f3,![]);throw new Error(_0x1bd600(0x16d)+_0x2d0aa1);};const parseHexColor=_0x578fef=>{const _0x1b5696=_0x3e5b;if(_0x578fef[_0x1b5696(0x17e)]===0x4){const _0x4227dc=Number[_0x1b5696(0x174)](''+_0x578fef[0x1]+_0x578fef[0x1],0x10),_0x1cd3f3=Number[_0x1b5696(0x174)](''+_0x578fef[0x2]+_0x578fef[0x2],0x10),_0x4ebb59=Number[_0x1b5696(0x174)](''+_0x578fef[0x3]+_0x578fef[0x3],0x10);return normalizeRgb(_0x4227dc,_0x1cd3f3,_0x4ebb59,0x1);}if(_0x578fef['length']===0x7){const _0x4bb3e1=Number[_0x1b5696(0x174)](_0x578fef['slice'](0x1,0x3),0x10),_0xec8220=Number[_0x1b5696(0x174)](_0x578fef[_0x1b5696(0x184)](0x3,0x5),0x10),_0x53bc22=Number['parseInt'](_0x578fef[_0x1b5696(0x184)](0x5,0x7),0x10);return normalizeRgb(_0x4bb3e1,_0xec8220,_0x53bc22,0x1);}throw new Error('不支持的\x20hex\x20颜色格式:\x20'+_0x578fef);},parseRgbColor=(_0x48f93b,_0x24eb7e)=>{const _0x5b1ee3=_0x3e5b,_0x5c98aa=_0x48f93b[_0x5b1ee3(0x170)](/^rgba?\(([^)]+)\)$/);if(!_0x5c98aa)throw new Error('不支持的\x20rgb\x20颜色格式:\x20'+_0x48f93b);const _0x261221=_0x5c98aa[0x1][_0x5b1ee3(0x173)](',')[_0x5b1ee3(0x17c)](_0x226195=>_0x226195[_0x5b1ee3(0x181)]()),_0x57132e=_0x24eb7e?0x4:0x3;if(_0x261221[_0x5b1ee3(0x17e)]!==_0x57132e)throw new Error('rgb\x20颜色通道数量不正确:\x20'+_0x48f93b);const _0x52f2c1=Number(_0x261221[0x0]),_0x4760fd=Number(_0x261221[0x1]),_0x77201f=Number(_0x261221[0x2]),_0x15fc0b=_0x24eb7e?Number(_0x261221[0x3]):0x1;return normalizeRgb(_0x52f2c1,_0x4760fd,_0x77201f,_0x15fc0b);},normalizeRgb=(_0x4d1314,_0x4571a0,_0x5f1094,_0x4902d3)=>{const _0x358668=_0x3e5b;if(!isValidRgbChannel(_0x4d1314)||!isValidRgbChannel(_0x4571a0)||!isValidRgbChannel(_0x5f1094))throw new Error(_0x358668(0x168));if(!Number[_0x358668(0x176)](_0x4902d3)||_0x4902d3<0x0||_0x4902d3>0x1)throw new Error(_0x358668(0x17a));return[_0x4d1314/0xff,_0x4571a0/0xff,_0x5f1094/0xff,_0x4902d3];},isValidRgbChannel=_0xace7fe=>Number[_0x42d4b2(0x176)](_0xace7fe)&&_0xace7fe>=0x0&&_0xace7fe<=0xff;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RasterGrid, RasterLoadOptions, RasterParams, RasterSource } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 根据直接参数创建统一栅格数据
|
|
4
|
+
* @param params
|
|
5
|
+
* @param options
|
|
6
|
+
*/
|
|
7
|
+
export declare const createGridFromParams: (params: RasterParams, options?: RasterLoadOptions) => RasterGrid;
|
|
8
|
+
export declare const parseMicaps4Text: (text: string, options?: RasterLoadOptions) => RasterGrid;
|
|
9
|
+
/**
|
|
10
|
+
* 从URL加载M4文件
|
|
11
|
+
* @param url
|
|
12
|
+
* @param options
|
|
13
|
+
*/
|
|
14
|
+
export declare const loadMicaps4Grid: (url: string, options?: RasterLoadOptions) => Promise<RasterGrid>;
|
|
15
|
+
/**
|
|
16
|
+
* 从URL加载tif, 首个图像
|
|
17
|
+
* @param url
|
|
18
|
+
* @param options
|
|
19
|
+
*/
|
|
20
|
+
export declare const loadTifGrid: (url: string, options?: RasterLoadOptions) => Promise<RasterGrid>;
|
|
21
|
+
/**
|
|
22
|
+
* 根据数据源加载统一的栅格数据
|
|
23
|
+
* @param source
|
|
24
|
+
* @param optiosn
|
|
25
|
+
*/
|
|
26
|
+
export declare const loadRasterGrid: (source: RasterSource, optiosn?: RasterLoadOptions) => Promise<RasterGrid>;
|
|
27
|
+
/**
|
|
28
|
+
* 验证栅格数据的合法性
|
|
29
|
+
* @param grid
|
|
30
|
+
*/
|
|
31
|
+
export declare const validateRasterGrid: (grid: RasterGrid) => RasterGrid;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(_0x155ad5,_0x4ece16){const _0x5700e3=_0x170e,_0x25157c=_0x155ad5();while(!![]){try{const _0x4f64ab=parseInt(_0x5700e3(0x116))/0x1+parseInt(_0x5700e3(0x12b))/0x2*(parseInt(_0x5700e3(0x123))/0x3)+parseInt(_0x5700e3(0x117))/0x4+parseInt(_0x5700e3(0x105))/0x5+parseInt(_0x5700e3(0xf8))/0x6*(-parseInt(_0x5700e3(0x10c))/0x7)+-parseInt(_0x5700e3(0xfb))/0x8*(-parseInt(_0x5700e3(0x11b))/0x9)+-parseInt(_0x5700e3(0xf5))/0xa*(parseInt(_0x5700e3(0x110))/0xb);if(_0x4f64ab===_0x4ece16)break;else _0x25157c['push'](_0x25157c['shift']());}catch(_0x35405f){_0x25157c['push'](_0x25157c['shift']());}}}(_0x7b3e,0xc7270));import{fromUrl}from'geotiff';const MICAPS4_HEADER_SIZE=0x16;export const createGridFromParams=(_0x50d73c,_0x559a7f={})=>{const _0x284a86=_0x170e;if(!Number['isInteger'](_0x50d73c['nx'])||_0x50d73c['nx']<=0x0||!Number[_0x284a86(0x10a)](_0x50d73c['ny'])||_0x50d73c['ny']<=0x0)throw new Error('栅格数据的\x20nx\x20和\x20ny\x20必须是正整数');const _0x2fb3cc=_0x50d73c['nx']*_0x50d73c['ny'];if(_0x50d73c[_0x284a86(0xfc)][_0x284a86(0x125)]!==_0x2fb3cc)throw new Error(_0x284a86(0x11d)+_0x2fb3cc+_0x284a86(0xf3)+_0x50d73c[_0x284a86(0xfc)][_0x284a86(0x125)]);const _0x1dcd0a=new Float32Array(_0x2fb3cc),_0x3b44c8=_0x50d73c[_0x284a86(0x108)]??_0x559a7f[_0x284a86(0x108)]??![];for(let _0x46593d=0x0;_0x46593d<_0x50d73c['ny'];_0x46593d+=0x1){const _0x77c77e=_0x3b44c8?_0x50d73c['ny']-_0x46593d-0x1:_0x46593d;for(let _0x368b26=0x0;_0x368b26<_0x50d73c['nx'];_0x368b26+=0x1){const _0x29eabf=_0x77c77e*_0x50d73c['nx']+_0x368b26,_0x361e61=_0x46593d*_0x50d73c['nx']+_0x368b26,_0x338715=Number(_0x50d73c[_0x284a86(0xfc)][_0x29eabf]);_0x1dcd0a[_0x361e61]=Number[_0x284a86(0x106)](_0x338715)?_0x338715:_0x50d73c[_0x284a86(0x101)]??Number[_0x284a86(0x112)];}}const _0x58555c=_0x50d73c['minLng']+_0x50d73c[_0x284a86(0x10e)]*(_0x50d73c['nx']-0x1),_0x2ca3bd=_0x50d73c[_0x284a86(0x127)]+_0x50d73c['gjLat']*(_0x50d73c['ny']-0x1);return validateRasterGrid({'values':_0x1dcd0a,'width':_0x50d73c['nx'],'height':_0x50d73c['ny'],'minLng':Math['min'](_0x50d73c[_0x284a86(0x111)],_0x58555c),'maxLng':Math[_0x284a86(0x11a)](_0x50d73c['minLng'],_0x58555c),'minLat':Math[_0x284a86(0x115)](_0x50d73c[_0x284a86(0x127)],_0x2ca3bd),'maxLat':Math['max'](_0x50d73c[_0x284a86(0x127)],_0x2ca3bd),'noData':_0x50d73c['noData']??_0x559a7f['noData'],'valueScale':_0x50d73c[_0x284a86(0x10d)]??_0x559a7f[_0x284a86(0x10d)]??0x1});};export const parseMicaps4Text=(_0x390257,_0x24c938={})=>{const _0x4ff3e7=_0x170e,_0x444599=_0x390257[_0x4ff3e7(0x121)]()[_0x4ff3e7(0xfd)](/\s+/);if(_0x444599[0x0][_0x4ff3e7(0xf9)]()!==_0x4ff3e7(0x11f)||_0x444599[0x1]!=='4')throw new Error(_0x4ff3e7(0x12c));return createGridFromParams({'values':_0x444599[_0x4ff3e7(0x11c)](MICAPS4_HEADER_SIZE)[_0x4ff3e7(0x12d)](Number),'nx':parseNumber(_0x444599[0xf],'nx'),'ny':parseNumber(_0x444599[0x10],'ny'),'minLng':parseNumber(_0x444599[0xb],'minLng'),'minLat':parseNumber(_0x444599[0xd],_0x4ff3e7(0x127)),'gjLng':parseNumber(_0x444599[0x9],_0x4ff3e7(0x10e)),'gjLat':parseNumber(_0x444599[0xa],_0x4ff3e7(0x118)),'flipY':_0x24c938[_0x4ff3e7(0x108)]??!![],'noData':_0x24c938['noData'],'valueScale':_0x24c938[_0x4ff3e7(0x10d)]});};function _0x170e(_0x4fee04,_0x267c80){const _0x7b3ea1=_0x7b3e();return _0x170e=function(_0x170e7a,_0x34791d){_0x170e7a=_0x170e7a-0xef;let _0x5b9622=_0x7b3ea1[_0x170e7a];return _0x5b9622;},_0x170e(_0x4fee04,_0x267c80);}function _0x7b3e(){const _0x450e8e=['height','栅格数据的\x20noData\x20必须是有限数字或\x20NaN','88tYEcqc','不支持的\x20MICAPS4\x20格式','map','maxLat','params','resolve','栅格数据的\x20minLng\x20必须小于\x20maxLng',',实际为','getHeight','20695420DkcHDf','isNaN','无法加载\x20MICAPS4\x20文件:\x20','198uFEHgY','toLowerCase','width','16AlyQGq','values','split','micaps4','statusText','栅格数据的\x20width\x20和\x20height\x20必须是正整数','noData','status','getBoundingBox','getGDALNoData','4898475YlDsXl','isFinite','tif','flipY','every','isInteger','getImage','322343rdftLD','valueScale','gjLng','readRasters','11BDyEoD','minLng','NaN','栅格数据的\x20minLng,\x20maxLng,\x20minLat,\x20maxLat\x20必须是有限数字','栅格数据的\x20valueScale\x20必须是有限数字','min','258606SfTKkb','6234016tuAQpR','gjLat','栅格数据的\x20minLat\x20必须小于\x20maxLat','max','1993527fsyvKr','slice','栅格数据长度应为','type','diamond','MICAPS4字段解析失败:','trim','text','79437KMczfT','url','length','maxLng','minLat','from'];_0x7b3e=function(){return _0x450e8e;};return _0x7b3e();}export const loadMicaps4Grid=async(_0x65c0c0,_0x27c440={})=>{const _0x1bd129=_0x170e,_0x1b86f2=await fetch(_0x65c0c0);if(!_0x1b86f2['ok'])throw new Error(_0x1bd129(0xf7)+_0x1b86f2[_0x1bd129(0x102)]+'\x20'+_0x1b86f2[_0x1bd129(0xff)]);return parseMicaps4Text(await _0x1b86f2[_0x1bd129(0x122)](),_0x27c440);};export const loadTifGrid=async(_0x4bfc78,_0x5da96c={})=>{const _0x445453=_0x170e,_0x529b76=await fromUrl(_0x4bfc78),_0x2d00c1=await _0x529b76[_0x445453(0x10b)](),_0x2cea2b=await _0x2d00c1[_0x445453(0x10f)]({'samples':[0x0],'interleave':!![]}),[_0x54923a,_0x20390b,_0x37fd2e,_0x83ce45]=_0x2d00c1[_0x445453(0x103)]();return validateRasterGrid({'values':toFloat32Array(_0x2cea2b),'width':_0x2cea2b[_0x445453(0xfa)]??_0x2d00c1['getWidth'](),'height':_0x2cea2b['height']??_0x2d00c1[_0x445453(0xf4)](),'minLng':_0x54923a,'maxLng':_0x37fd2e,'minLat':_0x20390b,'maxLat':_0x83ce45,'noData':_0x2d00c1[_0x445453(0x104)]()??_0x5da96c[_0x445453(0x101)],'valueScale':_0x5da96c['valueScale']??0x1});};export const loadRasterGrid=(_0x1916eb,_0x47e405={})=>{const _0xcabf6e=_0x170e;switch(_0x1916eb[_0xcabf6e(0x11e)]){case _0xcabf6e(0x107):return loadTifGrid(_0x1916eb[_0xcabf6e(0x124)],_0x47e405);case _0xcabf6e(0xfe):return loadMicaps4Grid(_0x1916eb[_0xcabf6e(0x124)],_0x47e405);case _0xcabf6e(0xf0):return Promise[_0xcabf6e(0xf1)](createGridFromParams(_0x1916eb[_0xcabf6e(0xf0)],_0x47e405));}};const parseNumber=(_0xfce132,_0xc821a1)=>{const _0x3f047a=_0x170e,_0x2d5b8e=Number(_0xfce132);if(!Number['isFinite'](_0x2d5b8e))throw new TypeError(_0x3f047a(0x120)+_0xc821a1);return _0x2d5b8e;},toFloat32Array=_0x5b95ab=>{const _0x420ca6=_0x170e;if(_0x5b95ab instanceof Float32Array)return _0x5b95ab;return Float32Array[_0x420ca6(0x128)](_0x5b95ab);};export const validateRasterGrid=_0x14637f=>{const _0x2939c2=_0x170e;if(!Number[_0x2939c2(0x10a)](_0x14637f[_0x2939c2(0xfa)])||_0x14637f[_0x2939c2(0xfa)]<=0x0||!Number['isInteger'](_0x14637f[_0x2939c2(0x129)])||_0x14637f[_0x2939c2(0x129)]<=0x0)throw new Error(_0x2939c2(0x100));const _0x1f5f5d=_0x14637f[_0x2939c2(0xfa)]*_0x14637f[_0x2939c2(0x129)];if(_0x14637f[_0x2939c2(0xfc)][_0x2939c2(0x125)]!==_0x1f5f5d)throw new Error(_0x2939c2(0x11d)+_0x1f5f5d+_0x2939c2(0xf3)+_0x14637f[_0x2939c2(0xfc)][_0x2939c2(0x125)]);validateRasterBounds(_0x14637f);if(!Number[_0x2939c2(0x106)](_0x14637f[_0x2939c2(0x10d)]))throw new TypeError(_0x2939c2(0x114));if(_0x14637f['noData']!==undefined&&!Number[_0x2939c2(0x106)](_0x14637f[_0x2939c2(0x101)])&&!Number[_0x2939c2(0xf6)](_0x14637f['noData']))throw new TypeError(_0x2939c2(0x12a));return _0x14637f;};const validateRasterBounds=_0x3a5532=>{const _0x3ba0ac=_0x170e,_0x518b45=[_0x3a5532[_0x3ba0ac(0x111)],_0x3a5532[_0x3ba0ac(0x126)],_0x3a5532['minLat'],_0x3a5532[_0x3ba0ac(0xef)]];if(!_0x518b45[_0x3ba0ac(0x109)](Number[_0x3ba0ac(0x106)]))throw new Error(_0x3ba0ac(0x113));if(_0x3a5532[_0x3ba0ac(0x111)]>=_0x3a5532[_0x3ba0ac(0x126)])throw new Error(_0x3ba0ac(0xf2));if(_0x3a5532[_0x3ba0ac(0x127)]>=_0x3a5532[_0x3ba0ac(0xef)])throw new Error(_0x3ba0ac(0x119));};
|