@antv/l7-core
Advanced tools
Comparing version 2.8.45 to 2.9.0
@@ -42,3 +42,3 @@ import 'reflect-metadata'; | ||
*/ | ||
refresh(): void; | ||
refresh(offsetCenter?: [number, number]): void; | ||
getCoordinateSystem(): CoordinateSystem; | ||
@@ -45,0 +45,0 @@ setCoordinateSystem(coordinateSystem: CoordinateSystem): void; |
@@ -40,6 +40,6 @@ import _initializerDefineProperty from "@babel/runtime/helpers/initializerDefineProperty"; | ||
key: "refresh", | ||
value: function refresh() { | ||
value: function refresh(offsetCenter) { | ||
var zoom = this.cameraService.getZoom(); | ||
var zoomScale = this.cameraService.getZoomScale(); | ||
var center = this.cameraService.getCenter(); | ||
var center = offsetCenter ? offsetCenter : this.cameraService.getCenter(); | ||
@@ -46,0 +46,0 @@ var _getDistanceScales = getDistanceScales({ |
@@ -31,3 +31,3 @@ /** | ||
needRefresh: boolean; | ||
refresh(): void; | ||
refresh(offset?: [number, number]): void; | ||
getCoordinateSystem(): CoordinateSystem; | ||
@@ -34,0 +34,0 @@ setCoordinateSystem(coordinateSystem: CoordinateSystem): void; |
@@ -0,4 +1,8 @@ | ||
import { IInteractionTarget } from '../interaction/IInteractionService'; | ||
import { ILayer } from '../layer/ILayerService'; | ||
export interface IPickingService { | ||
pickedColors: Uint8Array | undefined; | ||
pickedTileLayers: ILayer[]; | ||
init(id: string): void; | ||
pickFromPickingFBO(layer: ILayer, target: IInteractionTarget): boolean; | ||
pickBox(layer: ILayer, box: [number, number, number, number]): any[]; | ||
@@ -5,0 +9,0 @@ boxPickLayer(layer: ILayer, box: [number, number, number, number], cb: (...args: any[]) => void): Promise<any>; |
import 'reflect-metadata'; | ||
import { IInteractionTarget } from '../interaction/IInteractionService'; | ||
import { ILayer } from '../layer/ILayerService'; | ||
import { IPickingService } from './IPickingService'; | ||
export default class PickingService implements IPickingService { | ||
pickedColors: Uint8Array | undefined; | ||
pickedTileLayers: ILayer[]; | ||
private readonly mapService; | ||
@@ -21,2 +24,3 @@ private rendererService; | ||
destroy(): void; | ||
pickFromPickingFBO: (layer: ILayer, { x, y, lngLat, type, target }: IInteractionTarget) => boolean; | ||
private getContainerSize; | ||
@@ -26,3 +30,2 @@ private pickingAllLayer; | ||
private pickingLayers; | ||
private pickFromPickingFBO; | ||
private triggerHoverOnLayer; | ||
@@ -29,0 +32,0 @@ /** |
@@ -31,2 +31,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; | ||
_defineProperty(this, "pickedColors", void 0); | ||
_defineProperty(this, "pickedTileLayers", []); | ||
_initializerDefineProperty(this, "mapService", _descriptor, this); | ||
@@ -95,2 +99,3 @@ | ||
}); | ||
_this.pickedColors = pickedColors; | ||
@@ -159,2 +164,10 @@ if (pickedColors[0] !== 0 || pickedColors[1] !== 0 || pickedColors[2] !== 0) { | ||
} | ||
if (!layer.isVector) { | ||
_this.layerService.getLayers().filter(function (l) { | ||
return l.tileLayer; | ||
}).map(function (l) { | ||
l.tileLayer.clearPickState(); | ||
}); | ||
} | ||
} | ||
@@ -419,2 +432,19 @@ | ||
}); | ||
_this4.pickedLayers.filter(function (pickedlayer) { | ||
return !pickedlayer.isVector; | ||
}).map(function (pickedlayer) { | ||
_this4.selectFeature(pickedlayer, new Uint8Array([0, 0, 0, 0])); | ||
}); | ||
_this4.pickedTileLayers.map(function (pickedTileLayer) { | ||
var _pickedTileLayer$tile; | ||
return (_pickedTileLayer$tile = pickedTileLayer.tileLayer) === null || _pickedTileLayer$tile === void 0 ? void 0 : _pickedTileLayer$tile.clearPick(target.type); | ||
}); | ||
if (layer.tileLayer) { | ||
return layer.tileLayer.pickLayers(target); | ||
} | ||
layer.hooks.beforePickingEncode.call(); | ||
@@ -434,6 +464,2 @@ | ||
_this4.pickedLayers.map(function (pickedlayer) { | ||
_this4.selectFeature(pickedlayer, new Uint8Array([0, 0, 0, 0])); | ||
}); | ||
var isPicked = _this4.pickFromPickingFBO(layer, target); | ||
@@ -440,0 +466,0 @@ |
import { SyncBailHook, SyncHook, SyncWaterfallHook } from '@antv/async-hook'; | ||
import { IColorRamp, Tile, TilesetManager } from '@antv/l7-utils'; | ||
import { Container } from 'inversify'; | ||
import Clock from '../../utils/clock'; | ||
import { ISceneConfig } from '../config/IConfigService'; | ||
import { IInteractionTarget } from '../interaction/IInteractionService'; | ||
import { IPickingService } from '../interaction/IPickingService'; | ||
import { IMapService } from '../map/IMapService'; | ||
@@ -12,3 +15,3 @@ import { IAttribute } from '../renderer/IAttribute'; | ||
import { ISource, ISourceCFG } from '../source/ISourceService'; | ||
import { IAnimateOption, IEncodeFeature, IScale, IScaleOptions, IStyleAttributeService, IStyleAttributeUpdateOptions, StyleAttrField, StyleAttributeField, StyleAttributeOption, Triangulation } from './IStyleAttributeService'; | ||
import { IAnimateOption, IEncodeFeature, IScale, IScaleOptions, IScaleValue, IStyleAttribute, IStyleAttributeService, IStyleAttributeUpdateOptions, StyleAttrField, StyleAttributeField, StyleAttributeOption, Triangulation } from './IStyleAttributeService'; | ||
export declare enum BlendType { | ||
@@ -83,2 +86,75 @@ normal = "normal", | ||
} | ||
export interface ISubLayerStyles { | ||
opacity: number; | ||
} | ||
/** | ||
* For tile subLayer | ||
*/ | ||
export interface ISubLayerInitOptions { | ||
layerType: string; | ||
shape?: string | string[] | IScaleValue; | ||
zIndex: number; | ||
mask: boolean; | ||
stroke?: string; | ||
strokeWidth?: number; | ||
strokeOpacity?: number; | ||
opacity: number; | ||
color?: IScaleValue; | ||
size?: IScaleValue; | ||
domain?: [number, number]; | ||
clampLow?: boolean; | ||
clampHigh?: boolean; | ||
rampColors?: IColorRamp; | ||
coords?: string; | ||
sourceLayer?: string; | ||
featureId?: string; | ||
} | ||
export interface ITilePickManager { | ||
isLastPicked: boolean; | ||
on(type: string, cb: (option: any) => void): void; | ||
normalRender(layers: ILayer[]): void; | ||
beforeHighlight(pickedColors: any): void; | ||
beforeSelect(pickedColors: any): void; | ||
clearPick(): void; | ||
pickRender(layers: ILayer[], target: IInteractionTarget): boolean; | ||
} | ||
export interface ITileLayerManager { | ||
sourceLayer: string; | ||
parent: ILayer; | ||
children: ILayer[]; | ||
tilePickManager: ITilePickManager; | ||
createTile(tile: Tile): { | ||
layers: ILayer[]; | ||
layerIDList: string[]; | ||
}; | ||
addChild(layer: ILayer): void; | ||
addChilds(layers: ILayer[]): void; | ||
getChilds(layerIDList: string[]): ILayer[]; | ||
removeChild(layer: ILayer): void; | ||
removeChilds(layerIDList: string[]): void; | ||
clearChild(): void; | ||
hasChild(layer: ILayer): boolean; | ||
render(isPicking?: boolean): void; | ||
pickLayers(target: IInteractionTarget): boolean; | ||
updateLayersConfig(layers: ILayer[], key: string, value: any): void; | ||
} | ||
export interface ITileLayer { | ||
type: string; | ||
sourceLayer: string; | ||
parent: ILayer; | ||
tileLayerManager: ITileLayerManager; | ||
tilesetManager: TilesetManager | undefined; | ||
children: ILayer[]; | ||
render(isPicking?: boolean): void; | ||
pickLayers(target: IInteractionTarget): boolean; | ||
clearPick(type: string): void; | ||
clearPickState(): void; | ||
} | ||
export interface ITileLayerOPtions { | ||
parent: ILayer; | ||
rendererService: IRendererService; | ||
mapService: IMapService; | ||
layerService: ILayerService; | ||
pickingService: IPickingService; | ||
} | ||
export declare type LayerEventType = 'inited' | 'add' | 'remove' | 'destroy' | 'contextmenu' | 'uncontextmenu' | 'unpick' | 'mousedown' | 'unmousedown' | 'unclick' | 'undblclick' | 'unmouseenter' | 'unmousemove' | 'mouseout' | 'click' | 'dblclick' | 'mouseenter' | 'unmousemove' | 'mouseout' | any; | ||
@@ -96,2 +172,3 @@ export interface ILayer { | ||
layerModel: ILayerModel; | ||
tileLayer: ITileLayer; | ||
layerChildren: ILayer[]; | ||
@@ -124,3 +201,3 @@ masks: ILayer[]; | ||
layerType?: string | undefined; | ||
isLayerGroup: boolean; | ||
isVector?: boolean; | ||
triangulation?: Triangulation | undefined; | ||
@@ -140,2 +217,3 @@ /** | ||
needPick(type: string): boolean; | ||
getAttribute(name: string): IStyleAttribute | undefined; | ||
getLayerConfig(): Partial<ILayerConfig & ISceneConfig>; | ||
@@ -249,8 +327,2 @@ setBottomColor(color: string): void; | ||
} | ||
export interface ILayerGroup extends ILayer { | ||
addChild(layer: ILayer): void; | ||
removeChild(layer: ILayer): void; | ||
clearChild(): void; | ||
hasChild(layer: ILayer): boolean; | ||
} | ||
/** | ||
@@ -257,0 +329,0 @@ * Layer 插件 |
@@ -113,2 +113,7 @@ import { IAttribute, IAttributeInitializationOptions } from '../renderer/IAttribute'; | ||
} | ||
export interface IScaleValue { | ||
field: StyleAttributeField | undefined; | ||
values: unknown[] | string | undefined; | ||
callback?: (...args: any[]) => [] | undefined; | ||
} | ||
export interface IFeatureRange { | ||
@@ -115,0 +120,0 @@ startIndex: number; |
@@ -198,3 +198,3 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; | ||
if (!layer.isLayerGroup && layer.masks.length > 0) { | ||
if (layer.masks.length > 0) { | ||
this.renderService.clear({ | ||
@@ -282,15 +282,3 @@ stencil: 0, | ||
}).forEach(function (layer) { | ||
if (layer.isLayerGroup) { | ||
layer.layerChildren.filter(function (childlayer) { | ||
return childlayer.inited; | ||
}).filter(function (childlayer) { | ||
return childlayer.isVisible(); | ||
}).sort(function (pre, next) { | ||
return pre.zIndex - next.zIndex; | ||
}).forEach(function (childlayer) { | ||
_this.layerList.push(childlayer); | ||
}); | ||
} else { | ||
_this.layerList.push(layer); | ||
} | ||
_this.layerList.push(layer); | ||
}); | ||
@@ -297,0 +285,0 @@ } |
@@ -20,3 +20,3 @@ import { gl } from './gl'; | ||
*/ | ||
data?: undefined | HTMLCanvasElement | HTMLImageElement | number[] | number[][] | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray; | ||
data?: undefined | HTMLCanvasElement | HTMLImageElement | ImageBitmap | number[] | number[][] | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray; | ||
/** | ||
@@ -23,0 +23,0 @@ * 纹理参数 |
@@ -22,3 +22,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
var project = "\n#define E 2.718281828459045\nvec2 ProjectFlat(vec2 lnglat){\n float maxs=85.0511287798;\n float lat=max(min(maxs,lnglat.y),-maxs);\n float scale= 268435456.;\n float d=PI/180.;\n float x=lnglat.x*d;\n float y=lat*d;\n y=log(tan((PI/4.)+(y/2.)));\n\n float a=.5/PI,\n b=.5,\n c=-.5/PI;\n d=.5;\n x=scale*(a*x+b);\n y=scale*(c*y+d);\n return vec2(x,y);\n}\n\nvec2 unProjectFlat(vec2 px){\n float a=.5/PI;\n float b=.5;\n float c=-.5/PI;\n float d=.5;\n float scale = 268435456.;\n float x=(px.x/scale-b)/a;\n float y=(px.y/scale-d)/c;\n y=(atan(pow(E,y))-(PI/4.))*2.;\n d=PI/180.;\n float lat=y/d;\n float lng=x/d;\n return vec2(lng,lat);\n}\n\nfloat pixelDistance(vec2 from, vec2 to) {\n vec2 a1 = ProjectFlat(from);\n vec2 b1 = ProjectFlat(to);\n return distance(a1, b1);\n}\n\n// gaode2.0\nvec2 customProject(vec2 lnglat) { // \u7ECF\u7EAC\u5EA6 => \u5E73\u9762\u5750\u6807\n float t = lnglat.x;\n float e = lnglat.y;\n float Sm = 180.0 / PI;\n float Tm = 6378137.0;\n float Rm = PI / 180.0;\n float r = 85.0511287798;\n e = max(min(r, e), -r);\n t *= Rm;\n e *= Rm;\n e = log(tan(PI / 4.0 + e / 2.0));\n return vec2(t * Tm, e * Tm);\n}\n\nvec2 unProjCustomCoord(vec2 point) { // \u5E73\u9762\u5750\u6807 => \u7ECF\u7EAC\u5EA6\n float Sm = 57.29577951308232; //180 / Math.PI\n float Tm = 6378137.0;\n float t = point.x;\n float e = point.y;\n return vec2(t / Tm * Sm, (2.0 * atan(exp(e / Tm)) - PI / 2.0) * Sm);\n}\n\n\nfloat customPixelDistance(vec2 from, vec2 to) {\n vec2 a1 = ProjectFlat(from);\n vec2 b1 = ProjectFlat(to);\n return distance(a1, b1);\n}"; | ||
var projection = "#define TILE_SIZE 512.0\n#define PI 3.1415926536\n#define WORLD_SCALE TILE_SIZE / (PI * 2.0)\n\n#define COORDINATE_SYSTEM_LNGLAT 1.0 // mapbox\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0 // mapbox offset\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0 // amap\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0 // amap offset\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\n#define COORDINATE_SYSTEM_P20_2 8.0 // amap2.0\n\nuniform mat4 u_ViewMatrix;\nuniform mat4 u_ProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrix;\nuniform float u_Zoom : 1;\nuniform float u_ZoomScale : 1;\n\nuniform float u_CoordinateSystem;\nuniform vec2 u_ViewportCenter;\nuniform vec4 u_ViewportCenterProjection;\nuniform vec3 u_PixelsPerDegree;\nuniform vec3 u_PixelsPerDegree2;\nuniform vec3 u_PixelsPerMeter;\n\nuniform vec2 u_ViewportSize;\nuniform float u_DevicePixelRatio;\nuniform float u_FocalDistance;\nuniform vec3 u_CameraPosition;\n\n// uniform mat4 u_Mvp;\n\n// web mercator coords -> world coords\nvec2 project_mercator(vec2 lnglat) {\n float x = lnglat.x;\n return vec2(\n radians(x) + PI,\n PI - log(tan(PI * 0.25 + radians(lnglat.y) * 0.5))\n );\n}\n\nfloat project_scale(float meters) {\n return meters * u_PixelsPerMeter.z;\n}\n\n\n// offset coords -> world coords\nvec4 project_offset(vec4 offset) {\n float dy = offset.y;\n dy = clamp(dy, -1., 1.);\n vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;\n return vec4(offset.xyz * pixels_per_unit, offset.w);\n}\n\nvec3 project_normal(vec3 normal) {\n vec4 normal_modelspace = u_ModelMatrix * vec4(normal, 0.0);\n return normalize(normal_modelspace.xyz * u_PixelsPerMeter);\n}\n\nvec3 project_offset_normal(vec3 vector) {\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01\n || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // normals generated by the polygon tesselator are in lnglat offsets instead of meters\n return normalize(vector * u_PixelsPerDegree);\n }\n return project_normal(vector);\n}\n// || u_CoordinateSystem < COORDINATE_SYSTEM_P20_OFFSET + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_P20_OFFSET - 0.01\n// reverse Y\nvec3 reverse_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 ||u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET ) {\n return vector * vec3(1.0, -1.0, 1.0);\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.0\n return vector;\n }\n return vector;\n}\n\nvec4 project_position(vec4 position) {\n float a = COORDINATE_SYSTEM_LNGLAT_OFFSET;\n float b = COORDINATE_SYSTEM_P20_OFFSET;\n float c = COORDINATE_SYSTEM_LNGLAT;\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n float X = position.x - u_ViewportCenter.x;\n float Y = position.y - u_ViewportCenter.y;\n return project_offset(vec4(X, Y, position.z, position.w));\n }\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vec4(\n (project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale - vec2(215440491., 106744817.)) * vec2(1., -1.),\n project_scale(position.z),\n position.w\n );\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // return vec4(\n // (position.xy * WORLD_SCALE * u_ZoomScale) * vec2(1., -1.), \n // project_scale(position.z), \n // position.w);\n\n return vec4(\n position.xy, \n project_scale(position.z), \n position.w);\n }\n return position;\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / u_ViewportSize * u_DevicePixelRatio * 2.0;\n return offset * u_FocalDistance;\n}\n\nfloat project_pixel_allmap(float pixel) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return pixel * pow(2.0, u_Zoom);\n }\n return pixel;\n}\n\n// \u9002\u914D\u7EB9\u7406\u8D34\u56FE\u7684\u7B49\u50CF\u7D20\u5927\u5C0F\nfloat project_pixel_texture(float pixel) {\n // mapbox zoom > 12\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n return pixel * pow(0.5, u_Zoom);\n }\n\n // amap2 zoom > 12\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n\n // amap zoom > 12\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n return pixel * pow(0.5, u_Zoom);\n }\n \n // amap zoom < 12\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return pixel * pow(2.0, (20.0 - u_Zoom));\n }\n return pixel * 2.0;\n}\n\n// \u5728\u4E0D\u8BBA\u4EC0\u4E48\u5E95\u56FE\u4E0B\u9700\u8981\u7EDF\u4E00\u5904\u7406\u7684\u65F6\u5019\u4F7F\u7528\nfloat project_float_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // amap P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // amap2 P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel;\n}\n\nfloat project_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // amap P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // amap2 P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel;\n}\nvec2 project_pixel(vec2 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel * -1.;\n}\nvec3 project_pixel(vec3 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel * -1.;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n position.w *= u_PixelsPerMeter.z;\n }\n\n return viewProjectionMatrix * position + center;\n}\n\n// Projects from common space coordinates to clip space\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(\n position,\n u_ViewProjectionMatrix,\n u_ViewportCenterProjection\n );\n}\n\nvec4 unproject_clipspace_to_position(vec4 clipspacePos, mat4 u_InverseViewProjectionMatrix) {\n vec4 pos = u_InverseViewProjectionMatrix * (clipspacePos - u_ViewportCenterProjection);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n pos.w = pos.w / u_PixelsPerMeter.z;\n }\n return pos;\n}\n\n\nbool isEqual( float a, float b) {\n return a< b + 0.001 && a > b - 0.001;\n}"; | ||
var projection = "#define TILE_SIZE 512.0\n#define PI 3.1415926536\n#define WORLD_SCALE TILE_SIZE / (PI * 2.0)\n\n#define COORDINATE_SYSTEM_LNGLAT 1.0 // mapbox\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0 // mapbox offset\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0 // amap\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0 // amap offset\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\n#define COORDINATE_SYSTEM_P20_2 8.0 // amap2.0\n\nuniform mat4 u_ViewMatrix;\nuniform mat4 u_ProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrix;\nuniform float u_Zoom : 1;\nuniform float u_ZoomScale : 1;\n\nuniform float u_CoordinateSystem;\nuniform vec2 u_ViewportCenter;\nuniform vec4 u_ViewportCenterProjection;\nuniform vec3 u_PixelsPerDegree;\nuniform vec3 u_PixelsPerDegree2;\nuniform vec3 u_PixelsPerMeter;\n\nuniform vec2 u_ViewportSize;\nuniform float u_DevicePixelRatio;\nuniform float u_FocalDistance;\nuniform vec3 u_CameraPosition;\n\n// uniform mat4 u_Mvp;\n\n// web mercator coords -> world coords\nvec2 project_mercator(vec2 lnglat) {\n float x = lnglat.x;\n return vec2(\n radians(x) + PI,\n PI - log(tan(PI * 0.25 + radians(lnglat.y) * 0.5))\n );\n}\n\nfloat project_scale(float meters) {\n return meters * u_PixelsPerMeter.z;\n}\n\n\n// offset coords -> world coords\nvec4 project_offset(vec4 offset) {\n float dy = offset.y;\n dy = clamp(dy, -1., 1.);\n vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;\n return vec4(offset.xyz * pixels_per_unit, offset.w);\n}\n\nvec3 project_normal(vec3 normal) {\n vec4 normal_modelspace = u_ModelMatrix * vec4(normal, 0.0);\n return normalize(normal_modelspace.xyz * u_PixelsPerMeter);\n}\n\nvec3 project_offset_normal(vec3 vector) {\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01\n || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // normals generated by the polygon tesselator are in lnglat offsets instead of meters\n return normalize(vector * u_PixelsPerDegree);\n }\n return project_normal(vector);\n}\n// || u_CoordinateSystem < COORDINATE_SYSTEM_P20_OFFSET + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_P20_OFFSET - 0.01\n// reverse Y\nvec3 reverse_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 ||u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET ) {\n return vector * vec3(1.0, -1.0, 1.0);\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.0\n return vector;\n }\n return vector;\n}\n\nvec4 project_mvt_offset_position(vec4 position) {\n float a = COORDINATE_SYSTEM_LNGLAT_OFFSET;\n float b = COORDINATE_SYSTEM_P20_OFFSET;\n float c = COORDINATE_SYSTEM_LNGLAT;\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n return project_offset(vec4(0.0, 0.0, position.z, position.w));\n }\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n return position;\n}\n\nvec4 project_position(vec4 position) {\n float a = COORDINATE_SYSTEM_LNGLAT_OFFSET;\n float b = COORDINATE_SYSTEM_P20_OFFSET;\n float c = COORDINATE_SYSTEM_LNGLAT;\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n float X = position.x - u_ViewportCenter.x;\n float Y = position.y - u_ViewportCenter.y;\n return project_offset(vec4(X, Y, position.z, position.w));\n }\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vec4(\n (project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale - vec2(215440491., 106744817.)) * vec2(1., -1.),\n project_scale(position.z),\n position.w\n );\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // return vec4(\n // (position.xy * WORLD_SCALE * u_ZoomScale) * vec2(1., -1.), \n // project_scale(position.z), \n // position.w);\n\n return vec4(\n position.xy, \n project_scale(position.z), \n position.w);\n }\n return position;\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / u_ViewportSize * u_DevicePixelRatio * 2.0;\n return offset * u_FocalDistance;\n}\n\nfloat project_pixel_allmap(float pixel) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return pixel * pow(2.0, u_Zoom);\n }\n return pixel;\n}\n\n// \u9002\u914D\u7EB9\u7406\u8D34\u56FE\u7684\u7B49\u50CF\u7D20\u5927\u5C0F\nfloat project_pixel_texture(float pixel) {\n // mapbox zoom > 12\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n return pixel * pow(0.5, u_Zoom);\n }\n\n // amap2 zoom > 12\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n\n // amap zoom > 12\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n return pixel * pow(0.5, u_Zoom);\n }\n \n // amap zoom < 12\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return pixel * pow(2.0, (20.0 - u_Zoom));\n }\n return pixel * 2.0;\n}\n\n// \u5728\u4E0D\u8BBA\u4EC0\u4E48\u5E95\u56FE\u4E0B\u9700\u8981\u7EDF\u4E00\u5904\u7406\u7684\u65F6\u5019\u4F7F\u7528\nfloat project_float_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // amap P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // amap2 P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel;\n}\n\nfloat project_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // amap P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // amap2 P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel;\n}\nvec2 project_pixel(vec2 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel * -1.;\n}\nvec3 project_pixel(vec3 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel * -1.;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n position.w *= u_PixelsPerMeter.z;\n }\n\n return viewProjectionMatrix * position + center;\n}\n\n// Projects from common space coordinates to clip space\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(\n position,\n u_ViewProjectionMatrix,\n u_ViewportCenterProjection\n );\n}\n\nvec4 unproject_clipspace_to_position(vec4 clipspacePos, mat4 u_InverseViewProjectionMatrix) {\n vec4 pos = u_InverseViewProjectionMatrix * (clipspacePos - u_ViewportCenterProjection);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n pos.w = pos.w / u_PixelsPerMeter.z;\n }\n return pos;\n}\n\n\nbool isEqual( float a, float b) {\n return a< b + 0.001 && a > b - 0.001;\n}"; | ||
var sdf2d = "/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat ndot(vec2 a, vec2 b ) { return a.x*b.x - a.y*b.y; }\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\nfloat sdEquilateralTriangle(vec2 p) {\n float k = sqrt(3.0);\n p.x = abs(p.x) - 1.0;\n p.y = p.y + 1.0/k;\n if( p.x + k*p.y > 0.0 ) p = vec2(p.x-k*p.y,-k*p.x-p.y)/2.0;\n p.x -= clamp( p.x, -2.0, 0.0 );\n return -length(p)*sign(p.y);\n}\n\nfloat sdBox(vec2 p, vec2 b) {\n vec2 d = abs(p)-b;\n return length(max(d,vec2(0))) + min(max(d.x,d.y),0.0);\n}\n\nfloat sdPentagon(vec2 p, float r) {\n vec3 k = vec3(0.809016994,0.587785252,0.726542528);\n p.x = abs(p.x);\n p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);\n p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);\n p -= vec2(clamp(p.x,-r*k.z,r*k.z),r);\n return length(p)*sign(p.y);\n}\n\nfloat sdHexagon(vec2 p, float r) {\n vec3 k = vec3(-0.866025404,0.5,0.577350269);\n p = abs(p);\n p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;\n p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);\n return length(p)*sign(p.y);\n}\n\nfloat sdOctogon(vec2 p, float r) {\n vec3 k = vec3(-0.9238795325, 0.3826834323, 0.4142135623 );\n p = abs(p);\n p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);\n p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);\n p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);\n return length(p)*sign(p.y);\n}\n\nfloat sdHexagram(vec2 p, float r) {\n vec4 k=vec4(-0.5,0.8660254038,0.5773502692,1.7320508076);\n p = abs(p);\n p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;\n p -= 2.0*min(dot(k.yx,p),0.0)*k.yx;\n p -= vec2(clamp(p.x,r*k.z,r*k.w),r);\n return length(p)*sign(p.y);\n}\n\nfloat sdRhombus(vec2 p, vec2 b) {\n vec2 q = abs(p);\n float h = clamp((-2.0*ndot(q,b)+ndot(b,b))/dot(b,b),-1.0,1.0);\n float d = length( q - 0.5*b*vec2(1.0-h,1.0+h) );\n return d * sign( q.x*b.y + q.y*b.x - b.x*b.y );\n}\n\nfloat sdVesica(vec2 p, float r, float d) {\n p = abs(p);\n float b = sqrt(r*r-d*d); // can delay this sqrt\n return ((p.y-b)*d>p.x*b)\n ? length(p-vec2(0.0,b))\n : length(p-vec2(-d,0.0))-r;\n}\n"; | ||
@@ -25,0 +25,0 @@ var styleMapping = "attribute float a_vertexId;\n\nuniform mat4 u_cellTypeLayout; // \u63CF\u8FF0\u6570\u636E\u7EB9\u7406 cell \u7ED3\u6784\u7684\u77E9\u9635\nuniform sampler2D u_dataTexture; // \u6570\u636E\u7EB9\u7406\n\nbool hasOpacity() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 opacity \u7684\u6570\u636E\n return u_cellTypeLayout[1][0] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasStrokeOpacity() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 strokeOpacity \u7684\u6570\u636E\n return u_cellTypeLayout[1][1] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasStrokeWidth() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 strokeWidth \u7684\u6570\u636E\n return u_cellTypeLayout[1][2] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasStroke() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 stroke \u7684\u6570\u636E\n return u_cellTypeLayout[1][3] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasOffsets() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 offsets \u7684\u6570\u636E\n return u_cellTypeLayout[2][0] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasThetaOffset() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 thetaOffset \u7684\u6570\u636E\n return u_cellTypeLayout[2][1] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\n// \u6839\u636E\u5750\u6807\u4F4D\u7F6E\u5148\u662F\u8BA1\u7B97 uv \uFF0C\u7136\u540E\u6839\u636E uv \u4ECE\u6570\u636E\u7EB9\u7406\u4E2D\u53D6\u503C\nfloat pos2value(vec2 pos, float columnWidth, float rowHeight) {\n float u = (pos.r - 1.0) * columnWidth + columnWidth/2.0;\n float v = 1.0 - ((pos.g - 1.0) * rowHeight + rowHeight/2.0);\n return texture2D(u_dataTexture, vec2(u, v)).r;\n}\n\n/*\n currentRow \u5F53\u524D\u884C\n currentColumn \u5F53\u524D\u5217\n columnCount \u6709\u591A\u5C11\u5217\n nextStep \u9700\u8981\u8BA1\u7B97\u5F53\u524D cell \u540E\u7684\u7B2C\u51E0\u4E2A cell \uFF08\u5F53\u524D cell \u5219 nextStep = 0\uFF09\n*/\nvec2 nextPos(float currentRow, float currentColumn, float columnCount, float nextStep) {\n float nextColumn = currentColumn;\n float nextRow = currentRow;\n if(currentColumn + nextStep <= columnCount){\n nextColumn = currentColumn + nextStep;\n } else {\n nextColumn = mod(currentColumn + nextStep, columnCount); // \u4E0D\u4F1A\u51FA\u73B0\u8DE8\u4E24\u884C\n nextRow = currentRow + 1.0;\n }\n return vec2(nextColumn, nextRow);\n}\n\n// \u8BA1\u7B97\u5F53\u524D\u5355\u4E2A cell \u7684\u5927\u5C0F\nfloat calCellCount() { \n // u_cellTypeLayout\n // cal_height, WIDTH, 0.0, 0.0, // rowCount columnCount - \u51E0\u884C\u51E0\u5217\n // 1.0, 1.0, 1.0, 0.0, // opacity strokeOpacity strokeWidth stroke - 1.0 \u8868\u793A\u6709\u6570\u636E\u6620\u5C04\u30010.0 \u8868\u793A\u6CA1\u6709\n // 1.0, 1.0, 0.0, 0.0, // offsets thetaOffset\n // 0.0, 0.0, 0.0, 0.0\n \n return u_cellTypeLayout[1][0] + // opacity\n u_cellTypeLayout[1][1] + // strokeOpacity\n u_cellTypeLayout[1][2] + // strokeWidth\n u_cellTypeLayout[1][3] * 4.0 + // stroke\n u_cellTypeLayout[2][0] * 2.0 + // offsets\n u_cellTypeLayout[2][1]; // thetaOffset\n}"; |
@@ -52,6 +52,6 @@ "use strict"; | ||
key: "refresh", | ||
value: function refresh() { | ||
value: function refresh(offsetCenter) { | ||
var zoom = this.cameraService.getZoom(); | ||
var zoomScale = this.cameraService.getZoomScale(); | ||
var center = this.cameraService.getCenter(); | ||
var center = offsetCenter ? offsetCenter : this.cameraService.getCenter(); | ||
@@ -58,0 +58,0 @@ var _getDistanceScales = (0, _project.getDistanceScales)({ |
@@ -53,2 +53,4 @@ "use strict"; | ||
(0, _classCallCheck2.default)(this, PickingService); | ||
(0, _defineProperty2.default)(this, "pickedColors", void 0); | ||
(0, _defineProperty2.default)(this, "pickedTileLayers", []); | ||
(0, _initializerDefineProperty2.default)(this, "mapService", _descriptor, this); | ||
@@ -106,2 +108,3 @@ (0, _initializerDefineProperty2.default)(this, "rendererService", _descriptor2, this); | ||
}); | ||
_this.pickedColors = pickedColors; | ||
@@ -170,2 +173,10 @@ if (pickedColors[0] !== 0 || pickedColors[1] !== 0 || pickedColors[2] !== 0) { | ||
} | ||
if (!layer.isVector) { | ||
_this.layerService.getLayers().filter(function (l) { | ||
return l.tileLayer; | ||
}).map(function (l) { | ||
l.tileLayer.clearPickState(); | ||
}); | ||
} | ||
} | ||
@@ -430,2 +441,19 @@ | ||
}); | ||
_this4.pickedLayers.filter(function (pickedlayer) { | ||
return !pickedlayer.isVector; | ||
}).map(function (pickedlayer) { | ||
_this4.selectFeature(pickedlayer, new Uint8Array([0, 0, 0, 0])); | ||
}); | ||
_this4.pickedTileLayers.map(function (pickedTileLayer) { | ||
var _pickedTileLayer$tile; | ||
return (_pickedTileLayer$tile = pickedTileLayer.tileLayer) === null || _pickedTileLayer$tile === void 0 ? void 0 : _pickedTileLayer$tile.clearPick(target.type); | ||
}); | ||
if (layer.tileLayer) { | ||
return layer.tileLayer.pickLayers(target); | ||
} | ||
layer.hooks.beforePickingEncode.call(); | ||
@@ -445,6 +473,2 @@ | ||
_this4.pickedLayers.map(function (pickedlayer) { | ||
_this4.selectFeature(pickedlayer, new Uint8Array([0, 0, 0, 0])); | ||
}); | ||
var isPicked = _this4.pickFromPickingFBO(layer, target); | ||
@@ -451,0 +475,0 @@ |
@@ -205,3 +205,3 @@ "use strict"; | ||
if (!layer.isLayerGroup && layer.masks.length > 0) { | ||
if (layer.masks.length > 0) { | ||
this.renderService.clear({ | ||
@@ -289,15 +289,3 @@ stencil: 0, | ||
}).forEach(function (layer) { | ||
if (layer.isLayerGroup) { | ||
layer.layerChildren.filter(function (childlayer) { | ||
return childlayer.inited; | ||
}).filter(function (childlayer) { | ||
return childlayer.isVisible(); | ||
}).sort(function (pre, next) { | ||
return pre.zIndex - next.zIndex; | ||
}).forEach(function (childlayer) { | ||
_this.layerList.push(childlayer); | ||
}); | ||
} else { | ||
_this.layerList.push(layer); | ||
} | ||
_this.layerList.push(layer); | ||
}); | ||
@@ -304,0 +292,0 @@ } |
@@ -37,3 +37,3 @@ "use strict"; | ||
var project = "\n#define E 2.718281828459045\nvec2 ProjectFlat(vec2 lnglat){\n float maxs=85.0511287798;\n float lat=max(min(maxs,lnglat.y),-maxs);\n float scale= 268435456.;\n float d=PI/180.;\n float x=lnglat.x*d;\n float y=lat*d;\n y=log(tan((PI/4.)+(y/2.)));\n\n float a=.5/PI,\n b=.5,\n c=-.5/PI;\n d=.5;\n x=scale*(a*x+b);\n y=scale*(c*y+d);\n return vec2(x,y);\n}\n\nvec2 unProjectFlat(vec2 px){\n float a=.5/PI;\n float b=.5;\n float c=-.5/PI;\n float d=.5;\n float scale = 268435456.;\n float x=(px.x/scale-b)/a;\n float y=(px.y/scale-d)/c;\n y=(atan(pow(E,y))-(PI/4.))*2.;\n d=PI/180.;\n float lat=y/d;\n float lng=x/d;\n return vec2(lng,lat);\n}\n\nfloat pixelDistance(vec2 from, vec2 to) {\n vec2 a1 = ProjectFlat(from);\n vec2 b1 = ProjectFlat(to);\n return distance(a1, b1);\n}\n\n// gaode2.0\nvec2 customProject(vec2 lnglat) { // \u7ECF\u7EAC\u5EA6 => \u5E73\u9762\u5750\u6807\n float t = lnglat.x;\n float e = lnglat.y;\n float Sm = 180.0 / PI;\n float Tm = 6378137.0;\n float Rm = PI / 180.0;\n float r = 85.0511287798;\n e = max(min(r, e), -r);\n t *= Rm;\n e *= Rm;\n e = log(tan(PI / 4.0 + e / 2.0));\n return vec2(t * Tm, e * Tm);\n}\n\nvec2 unProjCustomCoord(vec2 point) { // \u5E73\u9762\u5750\u6807 => \u7ECF\u7EAC\u5EA6\n float Sm = 57.29577951308232; //180 / Math.PI\n float Tm = 6378137.0;\n float t = point.x;\n float e = point.y;\n return vec2(t / Tm * Sm, (2.0 * atan(exp(e / Tm)) - PI / 2.0) * Sm);\n}\n\n\nfloat customPixelDistance(vec2 from, vec2 to) {\n vec2 a1 = ProjectFlat(from);\n vec2 b1 = ProjectFlat(to);\n return distance(a1, b1);\n}"; | ||
var projection = "#define TILE_SIZE 512.0\n#define PI 3.1415926536\n#define WORLD_SCALE TILE_SIZE / (PI * 2.0)\n\n#define COORDINATE_SYSTEM_LNGLAT 1.0 // mapbox\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0 // mapbox offset\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0 // amap\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0 // amap offset\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\n#define COORDINATE_SYSTEM_P20_2 8.0 // amap2.0\n\nuniform mat4 u_ViewMatrix;\nuniform mat4 u_ProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrix;\nuniform float u_Zoom : 1;\nuniform float u_ZoomScale : 1;\n\nuniform float u_CoordinateSystem;\nuniform vec2 u_ViewportCenter;\nuniform vec4 u_ViewportCenterProjection;\nuniform vec3 u_PixelsPerDegree;\nuniform vec3 u_PixelsPerDegree2;\nuniform vec3 u_PixelsPerMeter;\n\nuniform vec2 u_ViewportSize;\nuniform float u_DevicePixelRatio;\nuniform float u_FocalDistance;\nuniform vec3 u_CameraPosition;\n\n// uniform mat4 u_Mvp;\n\n// web mercator coords -> world coords\nvec2 project_mercator(vec2 lnglat) {\n float x = lnglat.x;\n return vec2(\n radians(x) + PI,\n PI - log(tan(PI * 0.25 + radians(lnglat.y) * 0.5))\n );\n}\n\nfloat project_scale(float meters) {\n return meters * u_PixelsPerMeter.z;\n}\n\n\n// offset coords -> world coords\nvec4 project_offset(vec4 offset) {\n float dy = offset.y;\n dy = clamp(dy, -1., 1.);\n vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;\n return vec4(offset.xyz * pixels_per_unit, offset.w);\n}\n\nvec3 project_normal(vec3 normal) {\n vec4 normal_modelspace = u_ModelMatrix * vec4(normal, 0.0);\n return normalize(normal_modelspace.xyz * u_PixelsPerMeter);\n}\n\nvec3 project_offset_normal(vec3 vector) {\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01\n || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // normals generated by the polygon tesselator are in lnglat offsets instead of meters\n return normalize(vector * u_PixelsPerDegree);\n }\n return project_normal(vector);\n}\n// || u_CoordinateSystem < COORDINATE_SYSTEM_P20_OFFSET + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_P20_OFFSET - 0.01\n// reverse Y\nvec3 reverse_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 ||u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET ) {\n return vector * vec3(1.0, -1.0, 1.0);\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.0\n return vector;\n }\n return vector;\n}\n\nvec4 project_position(vec4 position) {\n float a = COORDINATE_SYSTEM_LNGLAT_OFFSET;\n float b = COORDINATE_SYSTEM_P20_OFFSET;\n float c = COORDINATE_SYSTEM_LNGLAT;\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n float X = position.x - u_ViewportCenter.x;\n float Y = position.y - u_ViewportCenter.y;\n return project_offset(vec4(X, Y, position.z, position.w));\n }\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vec4(\n (project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale - vec2(215440491., 106744817.)) * vec2(1., -1.),\n project_scale(position.z),\n position.w\n );\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // return vec4(\n // (position.xy * WORLD_SCALE * u_ZoomScale) * vec2(1., -1.), \n // project_scale(position.z), \n // position.w);\n\n return vec4(\n position.xy, \n project_scale(position.z), \n position.w);\n }\n return position;\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / u_ViewportSize * u_DevicePixelRatio * 2.0;\n return offset * u_FocalDistance;\n}\n\nfloat project_pixel_allmap(float pixel) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return pixel * pow(2.0, u_Zoom);\n }\n return pixel;\n}\n\n// \u9002\u914D\u7EB9\u7406\u8D34\u56FE\u7684\u7B49\u50CF\u7D20\u5927\u5C0F\nfloat project_pixel_texture(float pixel) {\n // mapbox zoom > 12\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n return pixel * pow(0.5, u_Zoom);\n }\n\n // amap2 zoom > 12\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n\n // amap zoom > 12\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n return pixel * pow(0.5, u_Zoom);\n }\n \n // amap zoom < 12\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return pixel * pow(2.0, (20.0 - u_Zoom));\n }\n return pixel * 2.0;\n}\n\n// \u5728\u4E0D\u8BBA\u4EC0\u4E48\u5E95\u56FE\u4E0B\u9700\u8981\u7EDF\u4E00\u5904\u7406\u7684\u65F6\u5019\u4F7F\u7528\nfloat project_float_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // amap P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // amap2 P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel;\n}\n\nfloat project_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // amap P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // amap2 P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel;\n}\nvec2 project_pixel(vec2 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel * -1.;\n}\nvec3 project_pixel(vec3 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel * -1.;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n position.w *= u_PixelsPerMeter.z;\n }\n\n return viewProjectionMatrix * position + center;\n}\n\n// Projects from common space coordinates to clip space\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(\n position,\n u_ViewProjectionMatrix,\n u_ViewportCenterProjection\n );\n}\n\nvec4 unproject_clipspace_to_position(vec4 clipspacePos, mat4 u_InverseViewProjectionMatrix) {\n vec4 pos = u_InverseViewProjectionMatrix * (clipspacePos - u_ViewportCenterProjection);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n pos.w = pos.w / u_PixelsPerMeter.z;\n }\n return pos;\n}\n\n\nbool isEqual( float a, float b) {\n return a< b + 0.001 && a > b - 0.001;\n}"; | ||
var projection = "#define TILE_SIZE 512.0\n#define PI 3.1415926536\n#define WORLD_SCALE TILE_SIZE / (PI * 2.0)\n\n#define COORDINATE_SYSTEM_LNGLAT 1.0 // mapbox\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0 // mapbox offset\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0 // amap\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0 // amap offset\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\n#define COORDINATE_SYSTEM_P20_2 8.0 // amap2.0\n\nuniform mat4 u_ViewMatrix;\nuniform mat4 u_ProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrix;\nuniform float u_Zoom : 1;\nuniform float u_ZoomScale : 1;\n\nuniform float u_CoordinateSystem;\nuniform vec2 u_ViewportCenter;\nuniform vec4 u_ViewportCenterProjection;\nuniform vec3 u_PixelsPerDegree;\nuniform vec3 u_PixelsPerDegree2;\nuniform vec3 u_PixelsPerMeter;\n\nuniform vec2 u_ViewportSize;\nuniform float u_DevicePixelRatio;\nuniform float u_FocalDistance;\nuniform vec3 u_CameraPosition;\n\n// uniform mat4 u_Mvp;\n\n// web mercator coords -> world coords\nvec2 project_mercator(vec2 lnglat) {\n float x = lnglat.x;\n return vec2(\n radians(x) + PI,\n PI - log(tan(PI * 0.25 + radians(lnglat.y) * 0.5))\n );\n}\n\nfloat project_scale(float meters) {\n return meters * u_PixelsPerMeter.z;\n}\n\n\n// offset coords -> world coords\nvec4 project_offset(vec4 offset) {\n float dy = offset.y;\n dy = clamp(dy, -1., 1.);\n vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;\n return vec4(offset.xyz * pixels_per_unit, offset.w);\n}\n\nvec3 project_normal(vec3 normal) {\n vec4 normal_modelspace = u_ModelMatrix * vec4(normal, 0.0);\n return normalize(normal_modelspace.xyz * u_PixelsPerMeter);\n}\n\nvec3 project_offset_normal(vec3 vector) {\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01\n || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // normals generated by the polygon tesselator are in lnglat offsets instead of meters\n return normalize(vector * u_PixelsPerDegree);\n }\n return project_normal(vector);\n}\n// || u_CoordinateSystem < COORDINATE_SYSTEM_P20_OFFSET + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_P20_OFFSET - 0.01\n// reverse Y\nvec3 reverse_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 ||u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET ) {\n return vector * vec3(1.0, -1.0, 1.0);\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.0\n return vector;\n }\n return vector;\n}\n\nvec4 project_mvt_offset_position(vec4 position) {\n float a = COORDINATE_SYSTEM_LNGLAT_OFFSET;\n float b = COORDINATE_SYSTEM_P20_OFFSET;\n float c = COORDINATE_SYSTEM_LNGLAT;\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n return project_offset(vec4(0.0, 0.0, position.z, position.w));\n }\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n return position;\n}\n\nvec4 project_position(vec4 position) {\n float a = COORDINATE_SYSTEM_LNGLAT_OFFSET;\n float b = COORDINATE_SYSTEM_P20_OFFSET;\n float c = COORDINATE_SYSTEM_LNGLAT;\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n float X = position.x - u_ViewportCenter.x;\n float Y = position.y - u_ViewportCenter.y;\n return project_offset(vec4(X, Y, position.z, position.w));\n }\n if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vec4(\n (project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale - vec2(215440491., 106744817.)) * vec2(1., -1.),\n project_scale(position.z),\n position.w\n );\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // return vec4(\n // (position.xy * WORLD_SCALE * u_ZoomScale) * vec2(1., -1.), \n // project_scale(position.z), \n // position.w);\n\n return vec4(\n position.xy, \n project_scale(position.z), \n position.w);\n }\n return position;\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / u_ViewportSize * u_DevicePixelRatio * 2.0;\n return offset * u_FocalDistance;\n}\n\nfloat project_pixel_allmap(float pixel) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return pixel * pow(2.0, u_Zoom);\n }\n return pixel;\n}\n\n// \u9002\u914D\u7EB9\u7406\u8D34\u56FE\u7684\u7B49\u50CF\u7D20\u5927\u5C0F\nfloat project_pixel_texture(float pixel) {\n // mapbox zoom > 12\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n return pixel * pow(0.5, u_Zoom);\n }\n\n // amap2 zoom > 12\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n\n // amap zoom > 12\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n return pixel * pow(0.5, u_Zoom);\n }\n \n // amap zoom < 12\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return pixel * pow(2.0, (20.0 - u_Zoom));\n }\n return pixel * 2.0;\n}\n\n// \u5728\u4E0D\u8BBA\u4EC0\u4E48\u5E95\u56FE\u4E0B\u9700\u8981\u7EDF\u4E00\u5904\u7406\u7684\u65F6\u5019\u4F7F\u7528\nfloat project_float_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // amap P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // amap2 P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel;\n}\n\nfloat project_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // amap P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // amap2 P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel;\n}\nvec2 project_pixel(vec2 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel * -1.;\n}\nvec3 project_pixel(vec3 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return pixel * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n return pixel * -1.;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n position.w *= u_PixelsPerMeter.z;\n }\n\n return viewProjectionMatrix * position + center;\n}\n\n// Projects from common space coordinates to clip space\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(\n position,\n u_ViewProjectionMatrix,\n u_ViewportCenterProjection\n );\n}\n\nvec4 unproject_clipspace_to_position(vec4 clipspacePos, mat4 u_InverseViewProjectionMatrix) {\n vec4 pos = u_InverseViewProjectionMatrix * (clipspacePos - u_ViewportCenterProjection);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n pos.w = pos.w / u_PixelsPerMeter.z;\n }\n return pos;\n}\n\n\nbool isEqual( float a, float b) {\n return a< b + 0.001 && a > b - 0.001;\n}"; | ||
var sdf2d = "/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat ndot(vec2 a, vec2 b ) { return a.x*b.x - a.y*b.y; }\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\nfloat sdEquilateralTriangle(vec2 p) {\n float k = sqrt(3.0);\n p.x = abs(p.x) - 1.0;\n p.y = p.y + 1.0/k;\n if( p.x + k*p.y > 0.0 ) p = vec2(p.x-k*p.y,-k*p.x-p.y)/2.0;\n p.x -= clamp( p.x, -2.0, 0.0 );\n return -length(p)*sign(p.y);\n}\n\nfloat sdBox(vec2 p, vec2 b) {\n vec2 d = abs(p)-b;\n return length(max(d,vec2(0))) + min(max(d.x,d.y),0.0);\n}\n\nfloat sdPentagon(vec2 p, float r) {\n vec3 k = vec3(0.809016994,0.587785252,0.726542528);\n p.x = abs(p.x);\n p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);\n p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);\n p -= vec2(clamp(p.x,-r*k.z,r*k.z),r);\n return length(p)*sign(p.y);\n}\n\nfloat sdHexagon(vec2 p, float r) {\n vec3 k = vec3(-0.866025404,0.5,0.577350269);\n p = abs(p);\n p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;\n p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);\n return length(p)*sign(p.y);\n}\n\nfloat sdOctogon(vec2 p, float r) {\n vec3 k = vec3(-0.9238795325, 0.3826834323, 0.4142135623 );\n p = abs(p);\n p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);\n p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);\n p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);\n return length(p)*sign(p.y);\n}\n\nfloat sdHexagram(vec2 p, float r) {\n vec4 k=vec4(-0.5,0.8660254038,0.5773502692,1.7320508076);\n p = abs(p);\n p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;\n p -= 2.0*min(dot(k.yx,p),0.0)*k.yx;\n p -= vec2(clamp(p.x,r*k.z,r*k.w),r);\n return length(p)*sign(p.y);\n}\n\nfloat sdRhombus(vec2 p, vec2 b) {\n vec2 q = abs(p);\n float h = clamp((-2.0*ndot(q,b)+ndot(b,b))/dot(b,b),-1.0,1.0);\n float d = length( q - 0.5*b*vec2(1.0-h,1.0+h) );\n return d * sign( q.x*b.y + q.y*b.x - b.x*b.y );\n}\n\nfloat sdVesica(vec2 p, float r, float d) {\n p = abs(p);\n float b = sqrt(r*r-d*d); // can delay this sqrt\n return ((p.y-b)*d>p.x*b)\n ? length(p-vec2(0.0,b))\n : length(p-vec2(-d,0.0))-r;\n}\n"; | ||
@@ -40,0 +40,0 @@ var styleMapping = "attribute float a_vertexId;\n\nuniform mat4 u_cellTypeLayout; // \u63CF\u8FF0\u6570\u636E\u7EB9\u7406 cell \u7ED3\u6784\u7684\u77E9\u9635\nuniform sampler2D u_dataTexture; // \u6570\u636E\u7EB9\u7406\n\nbool hasOpacity() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 opacity \u7684\u6570\u636E\n return u_cellTypeLayout[1][0] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasStrokeOpacity() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 strokeOpacity \u7684\u6570\u636E\n return u_cellTypeLayout[1][1] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasStrokeWidth() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 strokeWidth \u7684\u6570\u636E\n return u_cellTypeLayout[1][2] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasStroke() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 stroke \u7684\u6570\u636E\n return u_cellTypeLayout[1][3] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasOffsets() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 offsets \u7684\u6570\u636E\n return u_cellTypeLayout[2][0] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\nbool hasThetaOffset() { // \u5224\u65AD cell \u4E2D\u662F\u5426\u5B58\u5728 thetaOffset \u7684\u6570\u636E\n return u_cellTypeLayout[2][1] > 0.0 && u_cellTypeLayout[3][3] > 0.0;\n}\n\n// \u6839\u636E\u5750\u6807\u4F4D\u7F6E\u5148\u662F\u8BA1\u7B97 uv \uFF0C\u7136\u540E\u6839\u636E uv \u4ECE\u6570\u636E\u7EB9\u7406\u4E2D\u53D6\u503C\nfloat pos2value(vec2 pos, float columnWidth, float rowHeight) {\n float u = (pos.r - 1.0) * columnWidth + columnWidth/2.0;\n float v = 1.0 - ((pos.g - 1.0) * rowHeight + rowHeight/2.0);\n return texture2D(u_dataTexture, vec2(u, v)).r;\n}\n\n/*\n currentRow \u5F53\u524D\u884C\n currentColumn \u5F53\u524D\u5217\n columnCount \u6709\u591A\u5C11\u5217\n nextStep \u9700\u8981\u8BA1\u7B97\u5F53\u524D cell \u540E\u7684\u7B2C\u51E0\u4E2A cell \uFF08\u5F53\u524D cell \u5219 nextStep = 0\uFF09\n*/\nvec2 nextPos(float currentRow, float currentColumn, float columnCount, float nextStep) {\n float nextColumn = currentColumn;\n float nextRow = currentRow;\n if(currentColumn + nextStep <= columnCount){\n nextColumn = currentColumn + nextStep;\n } else {\n nextColumn = mod(currentColumn + nextStep, columnCount); // \u4E0D\u4F1A\u51FA\u73B0\u8DE8\u4E24\u884C\n nextRow = currentRow + 1.0;\n }\n return vec2(nextColumn, nextRow);\n}\n\n// \u8BA1\u7B97\u5F53\u524D\u5355\u4E2A cell \u7684\u5927\u5C0F\nfloat calCellCount() { \n // u_cellTypeLayout\n // cal_height, WIDTH, 0.0, 0.0, // rowCount columnCount - \u51E0\u884C\u51E0\u5217\n // 1.0, 1.0, 1.0, 0.0, // opacity strokeOpacity strokeWidth stroke - 1.0 \u8868\u793A\u6709\u6570\u636E\u6620\u5C04\u30010.0 \u8868\u793A\u6CA1\u6709\n // 1.0, 1.0, 0.0, 0.0, // offsets thetaOffset\n // 0.0, 0.0, 0.0, 0.0\n \n return u_cellTypeLayout[1][0] + // opacity\n u_cellTypeLayout[1][1] + // strokeOpacity\n u_cellTypeLayout[1][2] + // strokeWidth\n u_cellTypeLayout[1][3] * 4.0 + // stroke\n u_cellTypeLayout[2][0] * 2.0 + // offsets\n u_cellTypeLayout[2][1]; // thetaOffset\n}"; |
{ | ||
"name": "@antv/l7-core", | ||
"version": "2.8.45", | ||
"version": "2.9.0", | ||
"description": "", | ||
@@ -27,3 +27,3 @@ "main": "lib/index.js", | ||
"@antv/async-hook": "^2.1.0", | ||
"@antv/l7-utils": "2.8.45", | ||
"@antv/l7-utils": "2.9.0", | ||
"@babel/runtime": "^7.7.7", | ||
@@ -49,3 +49,3 @@ "ajv": "^6.10.2", | ||
}, | ||
"gitHead": "c7238a8050d374415b3741f6b7d8aeccd8062d19", | ||
"gitHead": "1b4a9fac41259cf55d7caa7bb9556dc9d0b302da", | ||
"publishConfig": { | ||
@@ -52,0 +52,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1686609
17431
+ Added@antv/l7-utils@2.9.0(transitive)
- Removed@antv/l7-utils@2.8.45(transitive)
Updated@antv/l7-utils@2.9.0