Skip to content

Commit

Permalink
【fix】wms130 bounds顺序跟投影轴顺序关联 review by xiongjj
Browse files Browse the repository at this point in the history
  • Loading branch information
songyumeng committed Dec 13, 2024
1 parent 80081e6 commit 7b27cfb
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/common/mapping/WebMapV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,12 +838,17 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
width: 256,
height: 256
};
if (version === '1.3.0') {
options.bbox = this.baseProjection === 'EPSG:4326' ? '{bbox-wms-1.3.0}' : '{bbox-epsg-3857}';
options.crs = this.baseProjection;
} else {
options.bbox = '{bbox-epsg-3857}';
options.srs = this.baseProjection;
options.bbox = '{bbox}';
options.crs = this.baseProjection;
if (version === '1.3.0' ) {
if (this.baseProjection === 'EPSG:4326') {
options.bbox = '{bbox-wms-1.3.0}';
} else {
const proj = crsManager.getProj4().defs(this.baseProjection);
if (proj.axis && proj.axis.indexOf('ne') === 0) {
options.bbox = '{bbox-wms-1.3.0}';
}
}
}
return Util.urlAppend(url, this._getParamString(options, url));
}
Expand Down
26 changes: 26 additions & 0 deletions test/mapboxgl/mapping/WebMapV2Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,32 @@ describe('mapboxgl_WebMapV2', () => {
datavizWebmap.on('mapcreatesucceeded', callback);
});

it('add wmsLayer with 2326WKT and version is 1.3.0', (done) => {
spyOn(FetchRequest, 'get').and.callFake((url) => {
if (url.indexOf('map-world/wms130') > -1) {
return Promise.resolve(new Response(wmsCapabilitiesTextWith130));
}
return Promise.resolve(new Response(JSON.stringify({})));
});
const callback = function (data) {
expect(data).not.toBeUndefined();
expect(data.map.getSource('世界地图_Day').tiles[0].indexOf('{bbox-wms-1.3.0}')).toBeGreaterThan(-1);
done();
};
datavizWebmap = new WebMap({
...wmsLayer,
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\"]]',
center: { x: 113.90326937827093,y: 22.285836066567555 },
layers: [
{
...wmsLayer.layers[0],
url: 'http://fack/iserver/services/map-world/wms130/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE_Day?'
}
]
});
datavizWebmap.on('mapcreatesucceeded', callback);
});

it('add wmtsLayer with correct url', (done) => {
spyOn(FetchRequest, 'get').and.callFake((url) => {
if (url.indexOf('map-china400/wmts100') > -1) {
Expand Down
26 changes: 26 additions & 0 deletions test/maplibregl/mapping/WebMapV2Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,32 @@ describe('maplibregl_WebMapV2', () => {
datavizWebmap.on('mapcreatesucceeded', callback);
});

it('add wmsLayer with 2326WKT and version is 1.3.0', (done) => {
spyOn(FetchRequest, 'get').and.callFake((url) => {
if (url.indexOf('map-world/wms130') > -1) {
return Promise.resolve(new Response(wmsCapabilitiesTextWith130));
}
return Promise.resolve(new Response(JSON.stringify({})));
});
const callback = function (data) {
expect(data).not.toBeUndefined();
expect(data.map.getSource('世界地图_Day').tiles[0].indexOf('{bbox-wms-1.3.0}')).toBeGreaterThan(-1);
done();
};
datavizWebmap = new WebMap({
...wmsLayer,
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\"]]',
center: { x: 113.90326937827093,y: 22.285836066567555 },
layers: [
{
...wmsLayer.layers[0],
url: 'http://fack/iserver/services/map-world/wms130/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE_Day?'
}
]
});
datavizWebmap.on('mapcreatesucceeded', callback);
});

it('add wmtsLayer with correct url', (done) => {
spyOn(FetchRequest, 'get').and.callFake((url) => {
if (url.indexOf('map-china400/wmts100') > -1) {
Expand Down

0 comments on commit 7b27cfb

Please sign in to comment.