Skip to content

Commit 430abb7

Browse files
committed
2 parents b100ea3 + e2ce2b9 commit 430abb7

File tree

8 files changed

+472
-59
lines changed

8 files changed

+472
-59
lines changed

src/common/mapping/WebMapService.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,12 +1200,8 @@ export class WebMapService {
12001200
maxFeatures: -1,
12011201
returnContent: true
12021202
});
1203-
if (baseProjection) {
1204-
if (baseProjection === 'EPSG:3857' || baseProjection === 'EPSG:-1000') {
1205-
getFeatureBySQLParams.targetEpsgCode = 4326;
1206-
} else {
1207-
getFeatureBySQLParams.targetEpsgCode = +baseProjection.split(':')[1];
1208-
}
1203+
if (baseProjection && baseProjection !== 'EPSG:4326') {
1204+
getFeatureBySQLParams.targetEpsgCode = 4326;
12091205
}
12101206
const proxy = this.handleProxy();
12111207
let options = {

src/common/mapping/WebMapV2.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,9 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
405405

406406
if (layer.visibleScale) {
407407
const { minScale, maxScale } = layer.visibleScale;
408-
layer.minzoom = Math.max(this._transformScaleToZoom(minScale), 0);
409-
layer.maxzoom = Math.min(24, this._transformScaleToZoom(maxScale) + 0.0000001);
408+
const crs = this.map.getCRS();
409+
layer.minzoom = Math.max(this._transformScaleToZoom(minScale, crs), 0);
410+
layer.maxzoom = Math.min(24, this._transformScaleToZoom(maxScale, crs) + 0.0000001);
410411
}
411412

412413
if (type === 'tile') {
@@ -455,7 +456,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
455456
if (
456457
features &&
457458
projection &&
458-
(projection !== this.baseProjection || projection === 'EPSG:3857' || projection === 'EPSG:-1000') &&
459+
projection !== 'EPSG:4326' &&
459460
layerInfo.dataSource &&
460461
layerInfo.dataSource.type !== 'REST_DATA'
461462
) {
@@ -884,7 +885,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
884885
layerID: layerInfo.layerID
885886
});
886887

887-
if (layerInfo.projection === 'EPSG:3857') {
888+
if (layerInfo.projection !== 'EPSG:4326') {
888889
features = this.transformFeatures(features);
889890
}
890891
if (layerInfo.filterCondition) {
@@ -2837,8 +2838,8 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
28372838
}
28382839

28392840
_transformScaleToZoom(scale, crs) {
2840-
const extent = (crs || this.map.getCRS()).getExtent();
2841-
const unit = (crs || this.map.getCRS()).unit;
2841+
const extent = crs.getExtent();
2842+
const unit = crs.unit;
28422843
const scaleBase = 1.0 / Util.getScaleFromResolutionDpi((extent[2] - extent[0]) / 512, 96, unit);
28432844
const scaleDenominator = scale.split(':')[1];
28442845
return Math.min(24, +Math.log2(scaleBase / +scaleDenominator).toFixed(2));

test/common/mapping/WebMapServiceSpec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,9 @@ describe('WebMapServiceSpec.js', () => {
860860
});
861861

862862
it('get Layer Features from rest_data and dataSource is Chinese', done => {
863-
spyOn(FetchRequest, 'post').and.callFake(() => {
863+
let getFeatureBySQLParams;
864+
spyOn(FetchRequest, 'post').and.callFake((url, options) => {
865+
getFeatureBySQLParams = options;
864866
return Promise.resolve(new Response(JSON.stringify(REST_DATA_SQL_RESULT)));
865867
});
866868
const type = 'rest_data';
@@ -880,6 +882,8 @@ describe('WebMapServiceSpec.js', () => {
880882
expect(params[0]).toBe(layer.dataSource.url);
881883
expect(params[1]).toEqual(["中国矢量数据:飞机场"]);
882884
expect(params[4]).toEqual(baseProjection);
885+
expect(typeof getFeatureBySQLParams).toBe('string');
886+
expect(getFeatureBySQLParams).toContain(`'targetEpsgCode':4326`);
883887
done();
884888
});
885889
});

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,9 +1846,7 @@ describe('mapboxgl_WebMapV2', () => {
18461846
center: [107.7815, 39.9788],
18471847
zoom: 5,
18481848
renderWorldCopies: false,
1849-
crs: {
1850-
epsgCode: 'EPSG:3857'
1851-
},
1849+
crs: 'EPSG:3857',
18521850
minzoom: 0,
18531851
maxzoom: 22
18541852
};
@@ -1886,9 +1884,7 @@ describe('mapboxgl_WebMapV2', () => {
18861884
center: [107.7815, 39.9788],
18871885
zoom: 5,
18881886
renderWorldCopies: false,
1889-
crs: {
1890-
epsgCode: 'EPSG:3857'
1891-
},
1887+
crs: 'EPSG:3857',
18921888
minzoom: 0,
18931889
maxzoom: 22
18941890
};
@@ -1927,9 +1923,7 @@ describe('mapboxgl_WebMapV2', () => {
19271923
center: [107.7815, 39.9788],
19281924
zoom: 5,
19291925
renderWorldCopies: false,
1930-
crs: {
1931-
epsgCode: 'EPSG:3857'
1932-
},
1926+
crs: 'EPSG:3857',
19331927
minzoom: 0,
19341928
maxzoom: 22
19351929
};
@@ -2734,4 +2728,55 @@ describe('mapboxgl_WebMapV2', () => {
27342728
};
27352729
datavizWebmap.once('mapcreatesucceeded', callback);
27362730
});
2731+
2732+
it('overlay projection is no EPSG:4326', (done) => {
2733+
spyOn(FetchRequest, 'get').and.callFake((url) => {
2734+
if (url.indexOf('portal.json') > -1) {
2735+
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
2736+
}
2737+
if (url.indexOf('map.json') > -1) {
2738+
return Promise.resolve(new Response(JSON.stringify(projection4548)));
2739+
}
2740+
if (url.indexOf('map4548%40fl-new/prjCoordSys.wkt') > -1) {
2741+
return Promise.resolve(new Response(projection_4548_wkt));
2742+
}
2743+
if (url.indexOf('/map4548%40fl-new.json') > -1) {
2744+
return Promise.resolve(
2745+
new Response(JSON.stringify({
2746+
bounds: {
2747+
top: 5178663.047080055,
2748+
left: 328182.9260637246,
2749+
bottom: 2289622.79728123,
2750+
leftBottom: {
2751+
x: 328182.9260637246,
2752+
y: 2289622.79728123
2753+
},
2754+
right: 629000.9570381088,
2755+
rightTop: {
2756+
x: 629000.9570381088,
2757+
y: 5178663.047080055
2758+
}
2759+
}
2760+
}))
2761+
);
2762+
}
2763+
if (url.indexOf('/content.json') > -1) {
2764+
return Promise.resolve(new Response(JSON.stringify(projection_4548_content)));
2765+
}
2766+
});
2767+
spyOn(FetchRequest, 'post').and.callFake(url => {
2768+
if (url.indexOf('/featureResults') > -1) {
2769+
return Promise.resolve(new Response(JSON.stringify(projection_4548_featureResults)));
2770+
}
2771+
});
2772+
datavizWebmap = new WebMap(id, {
2773+
server: server
2774+
});
2775+
2776+
datavizWebmap.on('mapcreatesucceeded', ({ layers, map }) => {
2777+
expect(layers.length).toBe(3);
2778+
expect(datavizWebmap._handler._unprojectProjection).toBe('EPSG:4548');
2779+
done();
2780+
});
2781+
});
27372782
});

test/maplibregl/mapping/WebMapV2Spec.js

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,9 +1847,7 @@ describe('maplibregl_WebMapV2', () => {
18471847
center: [107.7815, 39.9788],
18481848
zoom: 5,
18491849
renderWorldCopies: false,
1850-
crs: {
1851-
epsgCode: 'EPSG:3857'
1852-
},
1850+
crs: 'EPSG:3857',
18531851
minzoom: 0,
18541852
maxzoom: 22
18551853
};
@@ -1887,9 +1885,7 @@ describe('maplibregl_WebMapV2', () => {
18871885
center: [107.7815, 39.9788],
18881886
zoom: 5,
18891887
renderWorldCopies: false,
1890-
crs: {
1891-
epsgCode: 'EPSG:3857'
1892-
},
1888+
crs: 'EPSG:3857',
18931889
minzoom: 0,
18941890
maxzoom: 22
18951891
};
@@ -1928,9 +1924,7 @@ describe('maplibregl_WebMapV2', () => {
19281924
center: [107.7815, 39.9788],
19291925
zoom: 5,
19301926
renderWorldCopies: false,
1931-
crs: {
1932-
epsgCode: 'EPSG:3857'
1933-
},
1927+
crs: 'EPSG:3857',
19341928
minzoom: 0,
19351929
maxzoom: 22
19361930
};
@@ -2734,4 +2728,55 @@ describe('maplibregl_WebMapV2', () => {
27342728
};
27352729
datavizWebmap.once('mapcreatesucceeded', callback);
27362730
});
2731+
2732+
it('overlay projection is no EPSG:4326', (done) => {
2733+
spyOn(FetchRequest, 'get').and.callFake((url) => {
2734+
if (url.indexOf('portal.json') > -1) {
2735+
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
2736+
}
2737+
if (url.indexOf('map.json') > -1) {
2738+
return Promise.resolve(new Response(JSON.stringify(projection4548)));
2739+
}
2740+
if (url.indexOf('map4548%40fl-new/prjCoordSys.wkt') > -1) {
2741+
return Promise.resolve(new Response(projection_4548_wkt));
2742+
}
2743+
if (url.indexOf('/map4548%40fl-new.json') > -1) {
2744+
return Promise.resolve(
2745+
new Response(JSON.stringify({
2746+
bounds: {
2747+
top: 5178663.047080055,
2748+
left: 328182.9260637246,
2749+
bottom: 2289622.79728123,
2750+
leftBottom: {
2751+
x: 328182.9260637246,
2752+
y: 2289622.79728123
2753+
},
2754+
right: 629000.9570381088,
2755+
rightTop: {
2756+
x: 629000.9570381088,
2757+
y: 5178663.047080055
2758+
}
2759+
}
2760+
}))
2761+
);
2762+
}
2763+
if (url.indexOf('/content.json') > -1) {
2764+
return Promise.resolve(new Response(JSON.stringify(projection_4548_content)));
2765+
}
2766+
});
2767+
spyOn(FetchRequest, 'post').and.callFake(url => {
2768+
if (url.indexOf('/featureResults') > -1) {
2769+
return Promise.resolve(new Response(JSON.stringify(projection_4548_featureResults)));
2770+
}
2771+
});
2772+
datavizWebmap = new WebMap(id, {
2773+
server: server
2774+
});
2775+
2776+
datavizWebmap.on('mapcreatesucceeded', ({ layers, map }) => {
2777+
expect(layers.length).toBe(3);
2778+
expect(datavizWebmap._handler._unprojectProjection).toBe('EPSG:4548');
2779+
done();
2780+
});
2781+
});
27372782
});

0 commit comments

Comments
 (0)