@antv/l7-layers 2.14.6 → 2.14.7

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.
@@ -33,7 +33,7 @@ var TextureService = /*#__PURE__*/function () {
33
33
  var createTexture2D = this.rendererService.createTexture2D;
34
34
  var imageData = this.getColorRampBar(colorRamp, domain);
35
35
  var texture = createTexture2D({
36
- data: imageData.data,
36
+ data: new Uint8Array(imageData.data),
37
37
  width: imageData.width,
38
38
  height: imageData.height,
39
39
  flipY: false
@@ -1,5 +1,5 @@
1
1
  import { IAnimateOption, IMapService, ITexture2D } from '@antv/l7-core';
2
- import { IColorRamp, IImagedata } from '@antv/l7-utils';
2
+ import { IColorRamp } from '@antv/l7-utils';
3
3
  import { styleOffset } from '../core/BaseModel';
4
4
  import { anchorType } from '../utils/symbol-layout';
5
5
  export declare enum lineStyleType {
@@ -147,7 +147,6 @@ export interface IImageLayerStyleOptions extends IBaseLayerStyleOptions {
147
147
  clampLow?: boolean;
148
148
  clampHigh?: boolean;
149
149
  rampColors?: IColorRamp;
150
- rampColorsData?: ImageData | IImagedata;
151
150
  colorTexture?: ITexture2D;
152
151
  }
153
152
  export interface ICityBuildLayerStyleOptions {
@@ -209,16 +208,23 @@ export interface IHeatMapLayerStyleOptions extends IBaseLayerStyleOptions {
209
208
  rampColors: IColorRamp;
210
209
  coverage?: number;
211
210
  }
212
- export interface IRasterLayerStyleOptions extends IBaseLayerStyleOptions {
211
+ export interface IBaseRasterLayerStyleOptions extends IBaseLayerStyleOptions {
213
212
  colorTexture?: ITexture2D;
214
213
  domain: [number, number];
215
214
  noDataValue: number;
216
215
  clampLow: boolean;
217
216
  clampHigh: boolean;
218
217
  rampColors: IColorRamp;
219
- rampColorsData?: ImageData | IImagedata;
218
+ }
219
+ export interface IRasterLayerStyleOptions extends IBaseRasterLayerStyleOptions {
220
220
  channelRMax?: number;
221
221
  channelGMax?: number;
222
222
  channelBMax?: number;
223
223
  }
224
+ export interface IRasterTerrainLayerStyleOptions extends IBaseRasterLayerStyleOptions {
225
+ rScaler?: number;
226
+ gScaler?: number;
227
+ bScaler?: number;
228
+ offset?: number;
229
+ }
224
230
  export {};
@@ -16,7 +16,7 @@ import BaseModel from "../../core/BaseModel";
16
16
  import { RasterImageTriangulation } from "../../core/triangulation";
17
17
 
18
18
  /* babel-plugin-inline-import '../shaders/raster_terrain_rgb_frag.glsl' */
19
- var Raster_terrainFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nvarying vec2 v_texCoord;\n\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\n\nvoid main() {\n vec4 baseColor = texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y)) * 256.0;\n float r = baseColor.r * 256.0 * 256.0;\n float g = baseColor.g * 256.0;\n float b = baseColor.b;\n float value = (r + g + b) * 0.1 - 10000.0;\n \n if (value == u_noDataValue) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec4 color = texture2D(u_colorTexture, vec2(normalisedValue, 0));\n gl_FragColor = color;\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n if(gl_FragColor.a < 0.01)\n discard;\n }\n}\n";
19
+ var Raster_terrainFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nvarying vec2 v_texCoord;\n\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nuniform vec4 u_unpack;\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture2D(u_texture, coord,bias) * 255.0;\n data.a = -1.0;\n return dot(data, u_unpack);\n}\n\nvec4 getColor(float value) {\n float normalisedValue =(value- u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec2 coord = vec2(normalisedValue, 0);\n return texture2D(u_colorTexture, coord);\n}\n\nvoid main() {\n float value = getElevation(v_texCoord,0.0);\n if (value == u_noDataValue) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else {\n \n gl_FragColor = getColor(value);\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n if(gl_FragColor.a < 0.01)\n discard;\n }\n}\n";
20
20
 
21
21
  /* babel-plugin-inline-import '../shaders/rater_terrain_rgb_vert.glsl' */
22
22
  var Raster_terrainVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy,0., 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n }\n}\n";
@@ -45,7 +45,15 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
45
45
  noDataValue = _ref$noDataValue === void 0 ? -9999999 : _ref$noDataValue,
46
46
  domain = _ref.domain,
47
47
  rampColors = _ref.rampColors,
48
- colorTexture = _ref.colorTexture;
48
+ colorTexture = _ref.colorTexture,
49
+ _ref$rScaler = _ref.rScaler,
50
+ rScaler = _ref$rScaler === void 0 ? 6553.6 : _ref$rScaler,
51
+ _ref$gScaler = _ref.gScaler,
52
+ gScaler = _ref$gScaler === void 0 ? 25.6 : _ref$gScaler,
53
+ _ref$bScaler = _ref.bScaler,
54
+ bScaler = _ref$bScaler === void 0 ? 0.1 : _ref$bScaler,
55
+ _ref$offset = _ref.offset,
56
+ offset = _ref$offset === void 0 ? 10000 : _ref$offset;
49
57
 
50
58
  var newdomain = domain || getDefaultDomain(rampColors);
51
59
  var texture = colorTexture;
@@ -63,6 +71,7 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
63
71
  u_clampLow: clampLow,
64
72
  u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
65
73
  u_noDataValue: noDataValue,
74
+ u_unpack: [rScaler, gScaler, bScaler, offset],
66
75
  u_colorTexture: texture
67
76
  };
68
77
  }
@@ -85,7 +94,9 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
85
94
  this.texture = createTexture2D({
86
95
  data: imageData[0],
87
96
  width: imageData[0].width,
88
- height: imageData[0].height
97
+ height: imageData[0].height,
98
+ min: gl.LINEAR,
99
+ mag: gl.LINEAR
89
100
  });
90
101
  _context.next = 8;
91
102
  return this.layer.buildLayerModel({
@@ -10,22 +10,30 @@ uniform vec2 u_domain;
10
10
  uniform float u_noDataValue;
11
11
  uniform bool u_clampLow: true;
12
12
  uniform bool u_clampHigh: true;
13
+ uniform vec4 u_unpack;
14
+
15
+ float getElevation(vec2 coord, float bias) {
16
+ // Convert encoded elevation value to meters
17
+ vec4 data = texture2D(u_texture, coord,bias) * 255.0;
18
+ data.a = -1.0;
19
+ return dot(data, u_unpack);
20
+ }
21
+
22
+ vec4 getColor(float value) {
23
+ float normalisedValue =(value- u_domain[0]) / (u_domain[1] - u_domain[0]);
24
+ vec2 coord = vec2(normalisedValue, 0);
25
+ return texture2D(u_colorTexture, coord);
26
+ }
13
27
 
14
28
  void main() {
15
- vec4 baseColor = texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y)) * 256.0;
16
- float r = baseColor.r * 256.0 * 256.0;
17
- float g = baseColor.g * 256.0;
18
- float b = baseColor.b;
19
- float value = (r + g + b) * 0.1 - 10000.0;
20
-
29
+ float value = getElevation(v_texCoord,0.0);
21
30
  if (value == u_noDataValue) {
22
31
  gl_FragColor = vec4(0.0, 0, 0, 0.0);
23
32
  } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {
24
33
  gl_FragColor = vec4(0.0, 0, 0, 0.0);
25
34
  } else {
26
- float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);
27
- vec4 color = texture2D(u_colorTexture, vec2(normalisedValue, 0));
28
- gl_FragColor = color;
35
+
36
+ gl_FragColor = getColor(value);
29
37
  gl_FragColor.a = gl_FragColor.a * u_opacity ;
30
38
  if(gl_FragColor.a < 0.01)
31
39
  discard;
@@ -44,7 +44,7 @@ var TextureService = /*#__PURE__*/function () {
44
44
  var createTexture2D = this.rendererService.createTexture2D;
45
45
  var imageData = this.getColorRampBar(colorRamp, domain);
46
46
  var texture = createTexture2D({
47
- data: imageData.data,
47
+ data: new Uint8Array(imageData.data),
48
48
  width: imageData.width,
49
49
  height: imageData.height,
50
50
  flipY: false
@@ -34,7 +34,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
34
34
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
35
35
 
36
36
  /* babel-plugin-inline-import '../shaders/raster_terrain_rgb_frag.glsl' */
37
- var Raster_terrainFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nvarying vec2 v_texCoord;\n\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\n\nvoid main() {\n vec4 baseColor = texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y)) * 256.0;\n float r = baseColor.r * 256.0 * 256.0;\n float g = baseColor.g * 256.0;\n float b = baseColor.b;\n float value = (r + g + b) * 0.1 - 10000.0;\n \n if (value == u_noDataValue) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec4 color = texture2D(u_colorTexture, vec2(normalisedValue, 0));\n gl_FragColor = color;\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n if(gl_FragColor.a < 0.01)\n discard;\n }\n}\n";
37
+ var Raster_terrainFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nvarying vec2 v_texCoord;\n\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nuniform vec4 u_unpack;\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture2D(u_texture, coord,bias) * 255.0;\n data.a = -1.0;\n return dot(data, u_unpack);\n}\n\nvec4 getColor(float value) {\n float normalisedValue =(value- u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec2 coord = vec2(normalisedValue, 0);\n return texture2D(u_colorTexture, coord);\n}\n\nvoid main() {\n float value = getElevation(v_texCoord,0.0);\n if (value == u_noDataValue) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else {\n \n gl_FragColor = getColor(value);\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n if(gl_FragColor.a < 0.01)\n discard;\n }\n}\n";
38
38
 
39
39
  /* babel-plugin-inline-import '../shaders/rater_terrain_rgb_vert.glsl' */
40
40
  var Raster_terrainVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy,0., 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n }\n}\n";
@@ -62,7 +62,15 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
62
62
  noDataValue = _ref$noDataValue === void 0 ? -9999999 : _ref$noDataValue,
63
63
  domain = _ref.domain,
64
64
  rampColors = _ref.rampColors,
65
- colorTexture = _ref.colorTexture;
65
+ colorTexture = _ref.colorTexture,
66
+ _ref$rScaler = _ref.rScaler,
67
+ rScaler = _ref$rScaler === void 0 ? 6553.6 : _ref$rScaler,
68
+ _ref$gScaler = _ref.gScaler,
69
+ gScaler = _ref$gScaler === void 0 ? 25.6 : _ref$gScaler,
70
+ _ref$bScaler = _ref.bScaler,
71
+ bScaler = _ref$bScaler === void 0 ? 0.1 : _ref$bScaler,
72
+ _ref$offset = _ref.offset,
73
+ offset = _ref$offset === void 0 ? 10000 : _ref$offset;
66
74
 
67
75
  var newdomain = domain || (0, _l7Utils.getDefaultDomain)(rampColors);
68
76
  var texture = colorTexture;
@@ -80,6 +88,7 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
80
88
  u_clampLow: clampLow,
81
89
  u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
82
90
  u_noDataValue: noDataValue,
91
+ u_unpack: [rScaler, gScaler, bScaler, offset],
83
92
  u_colorTexture: texture
84
93
  };
85
94
  }
@@ -102,7 +111,9 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
102
111
  this.texture = createTexture2D({
103
112
  data: imageData[0],
104
113
  width: imageData[0].width,
105
- height: imageData[0].height
114
+ height: imageData[0].height,
115
+ min: _l7Core.gl.LINEAR,
116
+ mag: _l7Core.gl.LINEAR
106
117
  });
107
118
  _context.next = 8;
108
119
  return this.layer.buildLayerModel({
@@ -10,22 +10,30 @@ uniform vec2 u_domain;
10
10
  uniform float u_noDataValue;
11
11
  uniform bool u_clampLow: true;
12
12
  uniform bool u_clampHigh: true;
13
+ uniform vec4 u_unpack;
14
+
15
+ float getElevation(vec2 coord, float bias) {
16
+ // Convert encoded elevation value to meters
17
+ vec4 data = texture2D(u_texture, coord,bias) * 255.0;
18
+ data.a = -1.0;
19
+ return dot(data, u_unpack);
20
+ }
21
+
22
+ vec4 getColor(float value) {
23
+ float normalisedValue =(value- u_domain[0]) / (u_domain[1] - u_domain[0]);
24
+ vec2 coord = vec2(normalisedValue, 0);
25
+ return texture2D(u_colorTexture, coord);
26
+ }
13
27
 
14
28
  void main() {
15
- vec4 baseColor = texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y)) * 256.0;
16
- float r = baseColor.r * 256.0 * 256.0;
17
- float g = baseColor.g * 256.0;
18
- float b = baseColor.b;
19
- float value = (r + g + b) * 0.1 - 10000.0;
20
-
29
+ float value = getElevation(v_texCoord,0.0);
21
30
  if (value == u_noDataValue) {
22
31
  gl_FragColor = vec4(0.0, 0, 0, 0.0);
23
32
  } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {
24
33
  gl_FragColor = vec4(0.0, 0, 0, 0.0);
25
34
  } else {
26
- float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);
27
- vec4 color = texture2D(u_colorTexture, vec2(normalisedValue, 0));
28
- gl_FragColor = color;
35
+
36
+ gl_FragColor = getColor(value);
29
37
  gl_FragColor.a = gl_FragColor.a * u_opacity ;
30
38
  if(gl_FragColor.a < 0.01)
31
39
  discard;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.14.6",
3
+ "version": "2.14.7",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -27,10 +27,10 @@
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
29
  "@antv/async-hook": "^2.2.9",
30
- "@antv/l7-core": "2.14.6",
31
- "@antv/l7-maps": "2.14.6",
32
- "@antv/l7-source": "2.14.6",
33
- "@antv/l7-utils": "2.14.6",
30
+ "@antv/l7-core": "2.14.7",
31
+ "@antv/l7-maps": "2.14.7",
32
+ "@antv/l7-source": "2.14.7",
33
+ "@antv/l7-utils": "2.14.7",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "@mapbox/martini": "^0.2.0",
36
36
  "@turf/clone": "^6.5.0",
@@ -53,7 +53,7 @@
53
53
  "reflect-metadata": "^0.1.13"
54
54
  },
55
55
  "devDependencies": {
56
- "@antv/l7-test-utils": "2.14.6",
56
+ "@antv/l7-test-utils": "2.14.7",
57
57
  "@types/d3-array": "^2.0.0",
58
58
  "@types/d3-color": "^1.2.2",
59
59
  "@types/d3-interpolate": "1.1.6",
@@ -62,7 +62,7 @@
62
62
  "@types/gl-matrix": "^2.4.5",
63
63
  "@types/lodash": "^4.14.138"
64
64
  },
65
- "gitHead": "5f8823a2b58da0d8bed10a23e21fc903458c1f77",
65
+ "gitHead": "66930cd0d38ec341382493065defb77911c38d15",
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  }