Skip to content

Commit

Permalink
【test】>12 使用转换坐标的offset
Browse files Browse the repository at this point in the history
  • Loading branch information
songyumeng committed Apr 14, 2024
1 parent a53ae1c commit 357f737
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CoordinateSystem,
ICoordinateSystemService,
} from './ICoordinateSystemService';
import { transformOffset } from '../../../../maps/src/mapbox/utils';

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

Expand Down Expand Up @@ -106,7 +107,8 @@ export default class CoordinateSystemService
}

public getViewportCenter(): [number, number] {
return this.viewportCenter;
return transformOffset([Math.fround(this.viewportCenter[0]), Math.fround(this.viewportCenter[1])], window.map, 512)
// return this.viewportCenter;
}

public getViewportCenterProjection(): [number, number, number, number] {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/shaders/projection.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ vec4 project_offset(vec4 offset) {
float dy = offset.y;
dy = clamp(dy, -1., 1.);
vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;
return vec4(offset.xyz * pixels_per_unit, offset.w);
return vec4(offset.xyz , offset.w);
}

vec3 project_normal(vec3 normal) {
Expand Down Expand Up @@ -105,8 +105,8 @@ vec4 project_position(vec4 position) {

if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
|| u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
float X = position.x - u_ViewportCenter.x;
float Y = position.y - u_ViewportCenter.y;
float X = (position.x - u_ViewportCenter.x)* u_ZoomScale ;
float Y = ( position.y - u_ViewportCenter.y)* u_ZoomScale ;
return project_offset(vec4(X, Y, position.z, position.w));
}
if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {
Expand Down
6 changes: 3 additions & 3 deletions packages/layers/src/plugins/DataMappingPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ export default class DataMappingPlugin implements ILayerPlugin {

// 调整数据兼容 SimpleCoordinates
this.adjustData2SimpleCoordinates(mappedData);
if (this.mapService.map.getZoom() < 12) {

// if (this.mapService.map.getZoom() < 12) {
console.log('adjustData2MapboxCoordinatesadjustData2MapboxCoordinates')
this.adjustData2MapboxCoordinates(mappedData);
}
// }
return mappedData;
}

Expand Down

0 comments on commit 357f737

Please sign in to comment.