Skip to content

Commit 7b27cfb

Browse files
committed
【fix】wms130 bounds顺序跟投影轴顺序关联 review by xiongjj
1 parent 80081e6 commit 7b27cfb

File tree

3 files changed

+63
-6
lines changed

3 files changed

+63
-6
lines changed

src/common/mapping/WebMapV2.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -838,12 +838,17 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
838838
width: 256,
839839
height: 256
840840
};
841-
if (version === '1.3.0') {
842-
options.bbox = this.baseProjection === 'EPSG:4326' ? '{bbox-wms-1.3.0}' : '{bbox-epsg-3857}';
843-
options.crs = this.baseProjection;
844-
} else {
845-
options.bbox = '{bbox-epsg-3857}';
846-
options.srs = this.baseProjection;
841+
options.bbox = '{bbox}';
842+
options.crs = this.baseProjection;
843+
if (version === '1.3.0' ) {
844+
if (this.baseProjection === 'EPSG:4326') {
845+
options.bbox = '{bbox-wms-1.3.0}';
846+
} else {
847+
const proj = crsManager.getProj4().defs(this.baseProjection);
848+
if (proj.axis && proj.axis.indexOf('ne') === 0) {
849+
options.bbox = '{bbox-wms-1.3.0}';
850+
}
851+
}
847852
}
848853
return Util.urlAppend(url, this._getParamString(options, url));
849854
}

test/mapboxgl/mapping/WebMapV2Spec.js

+26
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,32 @@ describe('mapboxgl_WebMapV2', () => {
17671767
datavizWebmap.on('mapcreatesucceeded', callback);
17681768
});
17691769

1770+
it('add wmsLayer with 2326WKT and version is 1.3.0', (done) => {
1771+
spyOn(FetchRequest, 'get').and.callFake((url) => {
1772+
if (url.indexOf('map-world/wms130') > -1) {
1773+
return Promise.resolve(new Response(wmsCapabilitiesTextWith130));
1774+
}
1775+
return Promise.resolve(new Response(JSON.stringify({})));
1776+
});
1777+
const callback = function (data) {
1778+
expect(data).not.toBeUndefined();
1779+
expect(data.map.getSource('世界地图_Day').tiles[0].indexOf('{bbox-wms-1.3.0}')).toBeGreaterThan(-1);
1780+
done();
1781+
};
1782+
datavizWebmap = new WebMap({
1783+
...wmsLayer,
1784+
projection: 'PROJCS[\"Hong Kong 1980 Grid System\", \r\n GEOGCS[\"Hong Kong 1980\", \r\n DATUM[\"Hong Kong 1980\", \r\n SPHEROID[\"International 1924\", 6378388.0, 297.0, AUTHORITY[\"EPSG\",\"7022\"]], \r\n TOWGS84[-162.619, -276.959, -161.764, 0.067753, -2.243649, -1.158827, -1.094246], \r\n AUTHORITY[\"EPSG\",\"6611\"]], \r\n PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], \r\n UNIT[\"degree\", 0.017453292519943295], \r\n AXIS[\"lat\", NORTH], \r\n AXIS[\"lon\", EAST], \r\n AUTHORITY[\"EPSG\",\"4611\"]], \r\n PROJECTION[\"Transverse_Mercator\", AUTHORITY[\"EPSG\",\"9807\"]], \r\n PARAMETER[\"central_meridian\", 114.17855555555556], \r\n PARAMETER[\"latitude_of_origin\", 22.312133333333335], \r\n PARAMETER[\"scale_factor\", 1.0], \r\n PARAMETER[\"false_easting\", 836694.05], \r\n PARAMETER[\"false_northing\", 819069.8], \r\n UNIT[\"m\", 1.0], \r\n AXIS[\"Northing\", NORTH], \r\n AXIS[\"Easting\", EAST], \r\n AUTHORITY[\"EPSG\",\"2326\"]]',
1785+
center: { x: 113.90326937827093,y: 22.285836066567555 },
1786+
layers: [
1787+
{
1788+
...wmsLayer.layers[0],
1789+
url: 'http://fack/iserver/services/map-world/wms130/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE_Day?'
1790+
}
1791+
]
1792+
});
1793+
datavizWebmap.on('mapcreatesucceeded', callback);
1794+
});
1795+
17701796
it('add wmtsLayer with correct url', (done) => {
17711797
spyOn(FetchRequest, 'get').and.callFake((url) => {
17721798
if (url.indexOf('map-china400/wmts100') > -1) {

test/maplibregl/mapping/WebMapV2Spec.js

+26
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,32 @@ describe('maplibregl_WebMapV2', () => {
17131713
datavizWebmap.on('mapcreatesucceeded', callback);
17141714
});
17151715

1716+
it('add wmsLayer with 2326WKT and version is 1.3.0', (done) => {
1717+
spyOn(FetchRequest, 'get').and.callFake((url) => {
1718+
if (url.indexOf('map-world/wms130') > -1) {
1719+
return Promise.resolve(new Response(wmsCapabilitiesTextWith130));
1720+
}
1721+
return Promise.resolve(new Response(JSON.stringify({})));
1722+
});
1723+
const callback = function (data) {
1724+
expect(data).not.toBeUndefined();
1725+
expect(data.map.getSource('世界地图_Day').tiles[0].indexOf('{bbox-wms-1.3.0}')).toBeGreaterThan(-1);
1726+
done();
1727+
};
1728+
datavizWebmap = new WebMap({
1729+
...wmsLayer,
1730+
projection: 'PROJCS[\"Hong Kong 1980 Grid System\", \r\n GEOGCS[\"Hong Kong 1980\", \r\n DATUM[\"Hong Kong 1980\", \r\n SPHEROID[\"International 1924\", 6378388.0, 297.0, AUTHORITY[\"EPSG\",\"7022\"]], \r\n TOWGS84[-162.619, -276.959, -161.764, 0.067753, -2.243649, -1.158827, -1.094246], \r\n AUTHORITY[\"EPSG\",\"6611\"]], \r\n PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], \r\n UNIT[\"degree\", 0.017453292519943295], \r\n AXIS[\"lat\", NORTH], \r\n AXIS[\"lon\", EAST], \r\n AUTHORITY[\"EPSG\",\"4611\"]], \r\n PROJECTION[\"Transverse_Mercator\", AUTHORITY[\"EPSG\",\"9807\"]], \r\n PARAMETER[\"central_meridian\", 114.17855555555556], \r\n PARAMETER[\"latitude_of_origin\", 22.312133333333335], \r\n PARAMETER[\"scale_factor\", 1.0], \r\n PARAMETER[\"false_easting\", 836694.05], \r\n PARAMETER[\"false_northing\", 819069.8], \r\n UNIT[\"m\", 1.0], \r\n AXIS[\"Northing\", NORTH], \r\n AXIS[\"Easting\", EAST], \r\n AUTHORITY[\"EPSG\",\"2326\"]]',
1731+
center: { x: 113.90326937827093,y: 22.285836066567555 },
1732+
layers: [
1733+
{
1734+
...wmsLayer.layers[0],
1735+
url: 'http://fack/iserver/services/map-world/wms130/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE_Day?'
1736+
}
1737+
]
1738+
});
1739+
datavizWebmap.on('mapcreatesucceeded', callback);
1740+
});
1741+
17161742
it('add wmtsLayer with correct url', (done) => {
17171743
spyOn(FetchRequest, 'get').and.callFake((url) => {
17181744
if (url.indexOf('map-china400/wmts100') > -1) {

0 commit comments

Comments
 (0)