Skip to content

Commit 357f737

Browse files
committed
【test】>12 使用转换坐标的offset
1 parent a53ae1c commit 357f737

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/core/src/services/coordinate/CoordinateSystemService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
CoordinateSystem,
99
ICoordinateSystemService,
1010
} from './ICoordinateSystemService';
11+
import { transformOffset } from '../../../../maps/src/mapbox/utils';
1112

1213
const VECTOR_TO_POINT_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];
1314

@@ -106,7 +107,8 @@ export default class CoordinateSystemService
106107
}
107108

108109
public getViewportCenter(): [number, number] {
109-
return this.viewportCenter;
110+
return transformOffset([Math.fround(this.viewportCenter[0]), Math.fround(this.viewportCenter[1])], window.map, 512)
111+
// return this.viewportCenter;
110112
}
111113

112114
public getViewportCenterProjection(): [number, number, number, number] {

packages/core/src/shaders/projection.glsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ vec4 project_offset(vec4 offset) {
5252
float dy = offset.y;
5353
dy = clamp(dy, -1., 1.);
5454
vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;
55-
return vec4(offset.xyz * pixels_per_unit, offset.w);
55+
return vec4(offset.xyz , offset.w);
5656
}
5757

5858
vec3 project_normal(vec3 normal) {
@@ -105,8 +105,8 @@ vec4 project_position(vec4 position) {
105105

106106
if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
107107
|| u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
108-
float X = position.x - u_ViewportCenter.x;
109-
float Y = position.y - u_ViewportCenter.y;
108+
float X = (position.x - u_ViewportCenter.x)* u_ZoomScale ;
109+
float Y = ( position.y - u_ViewportCenter.y)* u_ZoomScale ;
110110
return project_offset(vec4(X, Y, position.z, position.w));
111111
}
112112
if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {

packages/layers/src/plugins/DataMappingPlugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ export default class DataMappingPlugin implements ILayerPlugin {
201201

202202
// 调整数据兼容 SimpleCoordinates
203203
this.adjustData2SimpleCoordinates(mappedData);
204-
if (this.mapService.map.getZoom() < 12) {
205-
204+
// if (this.mapService.map.getZoom() < 12) {
205+
console.log('adjustData2MapboxCoordinatesadjustData2MapboxCoordinates')
206206
this.adjustData2MapboxCoordinates(mappedData);
207-
}
207+
// }
208208
return mappedData;
209209
}
210210

0 commit comments

Comments
 (0)